Repair gauges
authorJBM <jbm@codingame.com>
Fri, 22 May 2020 21:30:55 +0000 (23:30 +0200)
committerJBM <jbm@codingame.com>
Wed, 27 May 2020 14:53:54 +0000 (16:53 +0200)
src/main/java/com/codingame/game/Referee.java
src/main/java/com/codingame/game/View.java

index b56cade..e6c941f 100644 (file)
@@ -35,6 +35,7 @@ public class Referee extends AbstractReferee {
         }
 
         view.init(model);
+
         gameManager.getPlayer(0).view = view.p0;
         gameManager.getPlayer(1).view = view.p1;
 
@@ -61,6 +62,8 @@ public class Referee extends AbstractReferee {
             player.execute();
         }
 
+        // SDK @#%^&! arbitrary sequence point: last input < first output
+
         for (Player player : gameManager.getActivePlayers()) {
             Model.Player p = player.model;
 
@@ -87,6 +90,7 @@ public class Referee extends AbstractReferee {
                 }
                 else if (stones > 0) {
                     player.view.animateStones(stones);
+                    player.view.updateStoneCounter();
                 }
             }
             catch (InvalidAction e) {
index dd350fe..7f883aa 100644 (file)
@@ -38,8 +38,6 @@ class View {
             int y = 220;
 
             Sprite border1 = graphicEntityModule.createSprite()
-            //    .setX(x)
-            //    .setY(y)
                 .setImage("frame.png")
                 .setAnchor(0.5)
                 .setScale(p0 ? -1 : 1)
@@ -47,15 +45,11 @@ class View {
                 .setTint(colorToken);
 
             Sprite border2 = graphicEntityModule.createSprite()
-            //    .setX(x)
-            //    .setY(y)
                 .setImage("frame_bg.png")
                 .setAnchor(0.5)
                 .setZIndex(20);
 
             Sprite avatarSprite = graphicEntityModule.createSprite()
-            //    .setX(x)
-            //    .setY(y)
                 .setZIndex(21)
                 .setImage(avatarToken)
                 .setAnchor(0.5)
@@ -74,13 +68,14 @@ class View {
                     .setFillColor(0x7f3f00)
                     .setAnchor(0.5);
 
-            stoneCounter = graphicEntityModule.createText("S")
+            stoneCounter = graphicEntityModule.createText()
                 .setX(x)
                 .setY(y+200)
                 .setZIndex(20)
                 .setFontSize(40)
                 .setFillColor(0x7f3f00)
                 .setAnchor(0.5);
+            updateStoneCounter();
 
             message = graphicEntityModule.createText()
                 .setX(p0 ? 15 : 1920-15)
@@ -110,7 +105,7 @@ class View {
                 .setAlpha(0);
         }
 
-        void setStone() {
+        void updateStoneCounter() {
             int stones = model.getStones();
             if (stones <= 0) {
                 stoneCounter.setText("Out of stones!");
@@ -197,6 +192,8 @@ class View {
             .setX(1980/2)
             .setY(980)
             .setFillColor(0xffffff);
+
+        moveTroll();
     }
 
     void moveTroll() {