Announce it's the loser who gets destroyed instead of the winner. (spotted by @Astrob...
[troll.git] / src / main / java / com / codingame / game / Referee.java
index b56cade..b678534 100644 (file)
@@ -35,6 +35,7 @@ public class Referee extends AbstractReferee {
         }
 
         view.init(model);
         }
 
         view.init(model);
+
         gameManager.getPlayer(0).view = view.p0;
         gameManager.getPlayer(1).view = view.p1;
 
         gameManager.getPlayer(0).view = view.p0;
         gameManager.getPlayer(1).view = view.p1;
 
@@ -45,6 +46,8 @@ public class Referee extends AbstractReferee {
     public void gameTurn(int turn) {
         // System.err.println("Starting turn " + turn);
 
     public void gameTurn(int turn) {
         // System.err.println("Starting turn " + turn);
 
+        view.startTurn();
+
         boolean disqual = false;
         boolean victory = false;
         boolean exhausted = false;
         boolean disqual = false;
         boolean victory = false;
         boolean exhausted = false;
@@ -61,6 +64,8 @@ public class Referee extends AbstractReferee {
             player.execute();
         }
 
             player.execute();
         }
 
+        // SDK @#%^&! arbitrary sequence point: last input < first output
+
         for (Player player : gameManager.getActivePlayers()) {
             Model.Player p = player.model;
 
         for (Player player : gameManager.getActivePlayers()) {
             Model.Player p = player.model;
 
@@ -87,6 +92,7 @@ public class Referee extends AbstractReferee {
                 }
                 else if (stones > 0) {
                     player.view.animateStones(stones);
                 }
                 else if (stones > 0) {
                     player.view.animateStones(stones);
+                    player.view.updateStoneCounter();
                 }
             }
             catch (InvalidAction e) {
                 }
             }
             catch (InvalidAction e) {
@@ -131,8 +137,8 @@ public class Referee extends AbstractReferee {
             }
 
             if (model.haveWinner()) {
             }
 
             if (model.haveWinner()) {
-                int winner = model.getWinner();
-                gameManager.addToGameSummary(GameManager.formatErrorMessage("Troll destroys " + gameManager.getPlayer(winner).getNicknameToken()));
+                int loser = model.getLoser();
+                gameManager.addToGameSummary(GameManager.formatErrorMessage("Troll destroys " + gameManager.getPlayer(loser).getNicknameToken()) + ".");
                 victory = true;
             }
             else if (model.exhausted()) exhausted = true;
                 victory = true;
             }
             else if (model.exhausted()) exhausted = true;
@@ -151,11 +157,11 @@ public class Referee extends AbstractReferee {
         int s1 = p1.getScore();
 
         if (s0 > s1) {
         int s1 = p1.getScore();
 
         if (s0 > s1) {
-            gameManager.addToGameSummary(GameManager.formatSuccessMessage(p0.getNicknameToken() + " wins"));
+            gameManager.addToGameSummary(GameManager.formatSuccessMessage(p0.getNicknameToken() + " wins."));
             p1.view.destroy();
         }
         else if (s0 < s1) {
             p1.view.destroy();
         }
         else if (s0 < s1) {
-            gameManager.addToGameSummary(GameManager.formatSuccessMessage(p1.getNicknameToken() + " wins"));
+            gameManager.addToGameSummary(GameManager.formatSuccessMessage(p1.getNicknameToken() + " wins."));
             p0.view.destroy();
         }
         else if (s0 < 0) {
             p0.view.destroy();
         }
         else if (s0 < 0) {