[from now] 2014/12/08 19:15:07

diff --git a/src/main/java/org/jenkinsci/plugins/emotional_mascot/Emotion.java b/src/main/java/org/jenkinsci/plugins/emotional_mascot/Emotion.java
index ef1be1c..83f4fd1 100644
--- a/src/main/java/org/jenkinsci/plugins/emotional_mascot/Emotion.java
+++ b/src/main/java/org/jenkinsci/plugins/emotional_mascot/Emotion.java
@@ -6,7 +6,7 @@ import hudson.model.Result;
  * Created by Hi on 2014/11/15.
  */
 public enum Emotion {
-    GREAT, BAD, NORMAL;
+    GREAT, BAD, WORRY;

     public static Emotion get(final Result result) {
         Emotion emotion;
@@ -15,7 +15,7 @@ public enum Emotion {
         } else if (Result.SUCCESS.equals(result)) {
             emotion = GREAT;
         } else {
-            emotion = NORMAL;
+            emotion = WORRY;
         }
         return emotion;
     }
diff --git a/src/main/java/org/jenkinsci/plugins/emotional_mascot/EmotionalMascotRecorder.java b/src/main/java/org/jenkinsci/plugins/emotional_mascot/EmotionalMascotRecorder.java
index 86eac47..2d10cba 100644
--- a/src/main/java/org/jenkinsci/plugins/emotional_mascot/EmotionalMascotRecorder.java
+++ b/src/main/java/org/jenkinsci/plugins/emotional_mascot/EmotionalMascotRecorder.java
@@ -22,7 +22,7 @@ public class EmotionalMascotRecorder extends Recorder {

     @Override
     public final Action getProjectAction(final AbstractProject<?, ?> project) {
-        Action action = new EmotionalMascotAction(Emotion.NORMAL);
+        Action action = new EmotionalMascotAction(Emotion.WORRY);
         return action;
     }

diff --git a/src/main/webapp/images/normal-jenkins.png b/src/main/webapp/images/normal-jenkins.png
deleted file mode 100644
index 09aa089..0000000
Binary files a/src/main/webapp/images/normal-jenkins.png and /dev/null differ
diff --git a/src/main/webapp/images/worry-jenkins.png b/src/main/webapp/images/worry-jenkins.png
new file mode 100644
index 0000000..09aa089
Binary files /dev/null and b/src/main/webapp/images/worry-jenkins.png differ
[from now] 2014/12/08 21:49:54

diff --git a/src/main/java/org/jenkinsci/plugins/emotional_mascot/EmotionalMascotRecorder.java b/src/main/java/org/jenkinsci/plugins/emotional_mascot/EmotionalMascotRecorder.java
index 2d10cba..d2b936d 100644
--- a/src/main/java/org/jenkinsci/plugins/emotional_mascot/EmotionalMascotRecorder.java
+++ b/src/main/java/org/jenkinsci/plugins/emotional_mascot/EmotionalMascotRecorder.java
@@ -1,28 +1,53 @@
 package org.jenkinsci.plugins.emotional_mascot;

 import hudson.Launcher;
-import hudson.model.AbstractBuild;
-import hudson.model.AbstractProject;
-import hudson.model.Action;
-import hudson.model.BuildListener;
+import hudson.model.*;
+import hudson.model.Fingerprint.RangeSet;
 import hudson.tasks.BuildStepMonitor;
+import hudson.tasks.Builder;
 import hudson.tasks.Recorder;
 import org.kohsuke.stapler.DataBoundConstructor;

 import java.io.IOException;
+import java.lang.reflect.Array;
 import java.util.logging.Logger;

 public class EmotionalMascotRecorder extends Recorder {

-    private static final Logger LOGGER = Logger
-            .getLogger(EmotionalMascotRecorder.class.getName());
+    private static final Logger LOGGER = Logger.getLogger(EmotionalMascotRecorder.class.getName());

     @DataBoundConstructor
     public EmotionalMascotRecorder(){}

+    /*
+     *
+     */
     @Override
     public final Action getProjectAction(final AbstractProject<?, ?> project) {
-        Action action = new EmotionalMascotAction(Emotion.WORRY);
+        int currentBuildNum = project.getNextBuildNumber() - 1;
+        int successCount = 0;
+        Action action;
+        if(currentBuildNum >= 5){
+            for(int i = 0; i < 5; i++){
+                AbstractBuild<?, ?> build = project.getBuildByNumber(currentBuildNum - i);
+                if(Result.SUCCESS.equals(build.getResult())){
+                    successCount++;
+                }
+            }
+            if(successCount >= 5){
+                action = new EmotionalMascotAction(Emotion.GREAT);
+                LOGGER.info("GREAT");
+            }else if(successCount >= 3){
+                action = new EmotionalMascotAction(Emotion.WORRY);
+                LOGGER.info("WORRY");
+
+            }else{
+                action = new EmotionalMascotAction(Emotion.BAD);
+                LOGGER.info("BAD");
+            }
+        }else{
+            action = new EmotionalMascotAction(Emotion.get(project.getLastBuild().getResult()));
+        }
         return action;
     }