From 949b74cf3b49121d913330b7cc254dd0bd30863b Mon Sep 17 00:00:00 2001 From: JBM Date: Sat, 23 May 2020 23:18:38 +0200 Subject: [PATCH] Announce it's the loser who gets destroyed instead of the winner. (spotted by @Astrobytes) Former transcript example: egaetan tried not throwing stones. Fixing that for them because I'm in a good mood today. egaetan throws 1 stone at the troll. Astrobytes throws 0 stones at the troll. Troll walks right. Troll destroys egaetan egaetan wins --- src/main/java/com/codingame/game/Model.java | 1 + src/main/java/com/codingame/game/Referee.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/codingame/game/Model.java b/src/main/java/com/codingame/game/Model.java index 4cd1280..e8cdc57 100644 --- a/src/main/java/com/codingame/game/Model.java +++ b/src/main/java/com/codingame/game/Model.java @@ -104,6 +104,7 @@ class Model { } } int getWinner() { return winner; } + int getLoser() { return 1 - winner; } boolean exhausted() { return p0.getStones() <= 0 && p1.getStones() <= 0; diff --git a/src/main/java/com/codingame/game/Referee.java b/src/main/java/com/codingame/game/Referee.java index 166344b..b678534 100644 --- a/src/main/java/com/codingame/game/Referee.java +++ b/src/main/java/com/codingame/game/Referee.java @@ -137,8 +137,8 @@ public class Referee extends AbstractReferee { } 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; @@ -157,11 +157,11 @@ public class Referee extends AbstractReferee { 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) { - gameManager.addToGameSummary(GameManager.formatSuccessMessage(p1.getNicknameToken() + " wins")); + gameManager.addToGameSummary(GameManager.formatSuccessMessage(p1.getNicknameToken() + " wins.")); p0.view.destroy(); } else if (s0 < 0) { -- 2.30.2