Update statement to stabilize rule changes
[troll.git] / src / main / java / com / codingame / game / View.java
index 52cfa64..40aae3d 100644 (file)
@@ -26,25 +26,22 @@ class View {
      *   - first half: stone throw
      *   - second half: troll move
      * The troll message is anchored around the troll move.
      *   - first half: stone throw
      *   - second half: troll move
      * The troll message is anchored around the troll move.
-     *
-     * The castle destruction is currently ad hoc simultaneously with
-     * the troll move, but this ought to change if I get some
-     * lengthened frame system ready.
-     *
-     * The endgame message is completely ad hoc, and really ought to
-     * improve.
      */
      */
-    private final double AVATAR_ANIMATION_START = 0.5;
     private final double STONE_THROW_START = 0.0;
     private final double STONE_THROW_PEAK = 0.25;
     private final double STONE_THROW_END = 0.5;
     private final double STONE_THROW_START = 0.0;
     private final double STONE_THROW_PEAK = 0.25;
     private final double STONE_THROW_END = 0.5;
-    private final double CASTLE_DESTRUCTION_START = 0.5;
-    private final double CASTLE_DESTRUCTION_END = 1.0;
     private final double TROLL_MOVE_START = 0.5;
     private final double TROLL_MOVE_END = 1.0;
     private final double TROLL_MESSAGE_START = 0.5;
     private final double TROLL_MESSAGE_END = 1.0;
     private final double TROLL_MOVE_START = 0.5;
     private final double TROLL_MOVE_END = 1.0;
     private final double TROLL_MESSAGE_START = 0.5;
     private final double TROLL_MESSAGE_END = 1.0;
-    private final double ENDGAME_MESSAGE_START = 0.25;
+
+    /*
+     * Castle destruction and endgame message pertain to an endgame
+     * frame only.
+     */
+    private final double AVATAR_ANIMATION_START = 0.5;
+    private final double CASTLE_DESTRUCTION_START = 0.0;
+    private final double CASTLE_DESTRUCTION_END = 0.5;
 
     class Player {
         Model.Player model;
 
     class Player {
         Model.Player model;
@@ -158,6 +155,7 @@ class View {
 
         void victory() {
             gameManager.addToGameSummary(GameManager.formatSuccessMessage(nicknameToken + " wins."));
 
         void victory() {
             gameManager.addToGameSummary(GameManager.formatSuccessMessage(nicknameToken + " wins."));
+            View.this.endgameFrame();
             markWinner();
         }
 
             markWinner();
         }
 
@@ -221,6 +219,7 @@ class View {
             else {
                 stoneCounter.setText(stones + " stones");
             }
             else {
                 stoneCounter.setText(stones + " stones");
             }
+            graphicEntityModule.commitEntityState(STONE_THROW_PEAK, stoneCounter);
         }
 
         void animateStones(int stones) {
         }
 
         void animateStones(int stones) {
@@ -303,13 +302,19 @@ class View {
         animateTurnCounter();
     }
 
         animateTurnCounter();
     }
 
+    void endgameFrame() {
+        gameManager.setFrameDuration(2000);
+    }
+
     void doubleDefeat() {
         gameManager.addToGameSummary(GameManager.formatErrorMessage("Everybody loses!"));
     void doubleDefeat() {
         gameManager.addToGameSummary(GameManager.formatErrorMessage("Everybody loses!"));
+        endgameFrame();
         animateLoss(1920/2, 680, 150, "L0SERZ!");
     }
 
     void draw() {
         gameManager.addToGameSummary("Draw.");
         animateLoss(1920/2, 680, 150, "L0SERZ!");
     }
 
     void draw() {
         gameManager.addToGameSummary("Draw.");
+        endgameFrame();
         animateLoss(1920/2, 680, 200, "DRAW");
     }
 
         animateLoss(1920/2, 680, 200, "DRAW");
     }
 
@@ -513,7 +518,7 @@ class View {
         pantsModule.displayOnToggleState(trollMessage, "verboseTrolling", true);
     }
 
         pantsModule.displayOnToggleState(trollMessage, "verboseTrolling", true);
     }
 
-    private void moveTroll() {
+    void moveTroll() {
         graphicEntityModule.commitEntityState(TROLL_MOVE_START, troll, trollPositionGauge);
         int x0 = p0.castle.getX(), x1 = p1.castle.getX();
         int y0 = p0.castle.getY(), y1 = p1.castle.getY();
         graphicEntityModule.commitEntityState(TROLL_MOVE_START, troll, trollPositionGauge);
         int x0 = p0.castle.getX(), x1 = p1.castle.getX();
         int y0 = p0.castle.getY(), y1 = p1.castle.getY();
@@ -641,7 +646,7 @@ class View {
             .setFillColor(0xff7f7f)
             .setFontWeight(Text.FontWeight.BOLD)
             .setTextAlign(TextBasedEntity.TextAlign.CENTER);
             .setFillColor(0xff7f7f)
             .setFontWeight(Text.FontWeight.BOLD)
             .setTextAlign(TextBasedEntity.TextAlign.CENTER);
-        graphicEntityModule.commitEntityState(ENDGAME_MESSAGE_START, msg);
+        graphicEntityModule.commitEntityState(0.0, msg);
         Curve curve = Curve.ELASTIC;
         msg.setX(x, Curve.EASE_OUT)
             .setY(y, Curve.ELASTIC)
         Curve curve = Curve.ELASTIC;
         msg.setX(x, Curve.EASE_OUT)
             .setY(y, Curve.ELASTIC)