X-Git-Url: https://troll.desast.re/troll.git/blobdiff_plain/00ef746e66b9aa761ca570cffea2a695f007fd9e..927d39e66672341d9d1e281accf0633747ea715f:/src/main/java/com/codingame/game/Referee.java?ds=inline diff --git a/src/main/java/com/codingame/game/Referee.java b/src/main/java/com/codingame/game/Referee.java index 5b6ec3a..685b458 100644 --- a/src/main/java/com/codingame/game/Referee.java +++ b/src/main/java/com/codingame/game/Referee.java @@ -35,36 +35,36 @@ public class Referee extends AbstractReferee { random = new Random(gameManager.getSeed()); switch (random.nextInt(4)) { case 0: - roadLength = 7; + roadLength = 6; initialStones = 15; break; case 1: - roadLength = 7; + roadLength = 6; initialStones = 30; break; case 2: - roadLength = 15; + roadLength = 14; initialStones = 30; break; case 3: - roadLength = 15; + roadLength = 14; initialStones = 50; break; } - trollPosition = (roadLength - 1) / 2; + trollPosition = roadLength / 2; p0 = gameManager.getPlayer(0); p0.setCastlePosition(0); p0.setMultiplier(1); p0.adjustScore(trollPosition); - p0.sendInputLine(String.format("%d %d", roadLength - 1, initialStones)); + p0.sendInputLine(String.format("%d %d", roadLength, initialStones)); p1 = gameManager.getPlayer(1); - p1.setCastlePosition(roadLength-1); + p1.setCastlePosition(roadLength); p1.setMultiplier(-1); p1.adjustScore(trollPosition); - p1.sendInputLine(String.format("%d %d", roadLength - 1, initialStones)); + p1.sendInputLine(String.format("%d %d", roadLength, initialStones)); drawBackground(); drawPlayer(); @@ -134,6 +134,16 @@ public class Referee extends AbstractReferee { .setFillColor(0x7f3f00) .setAnchor(0.5); + player.message = graphicEntityModule.createText() + .setX(p0 ? 15 : 1920-15) + .setY(680) + .setZIndex(1) + .setFontSize(40) + .setStrokeColor(0x000000) + .setFillColor(0xffbf7f) + .setAnchorX(p0 ? 0 : 1) + .setAnchorY(1); + player.castle = graphicEntityModule.createSprite() .setImage("castle.png") .setTint(player.getColorToken()) @@ -150,7 +160,6 @@ public class Referee extends AbstractReferee { .setFillColor(0x12322a) .setAnchor(0.5) .setAlpha(0); - } } @@ -175,13 +184,13 @@ public class Referee extends AbstractReferee { graphicEntityModule.commitEntityState(0.5, troll, trollPositionGauge); int x0 = p0.castle.getX(), x1 = p1.castle.getX(); int y0 = p0.castle.getY(), y1 = p1.castle.getY(); - troll.setX(x0 + trollPosition * (x1-x0) / (roadLength - 1), + troll.setX(x0 + trollPosition * (x1-x0) / roadLength, Curve.ELASTIC); - troll.setY(y0 + trollPosition * (y1-y0) / (roadLength - 1), + troll.setY(y0 + trollPosition * (y1-y0) / roadLength, Curve.ELASTIC); trollPositionGauge.setX((trollPositionGauge.getX() + troll.getX()) / 2); - int delta = trollPosition - (roadLength - 1) / 2; + int delta = trollPosition - roadLength / 2; if (delta < 0) { trollPositionGauge.setText("← " + Math.abs(delta)); } @@ -266,6 +275,11 @@ public class Referee extends AbstractReferee { player.setScore(-1); endGame(); } + + player.message + .setText(player.getMessageString()); + // .setAnchorX(/*player == p0 ? 0 : */ 1); + graphicEntityModule.commitEntityState(0, player.message); } if (delta > 0) { @@ -304,23 +318,25 @@ public class Referee extends AbstractReferee { } private void endGame() { - gameManager.endGame(); + if (! gameManager.isGameEnd()) { + gameManager.endGame(); - if (p0.getScore() > p1.getScore()) { - gameManager.addToGameSummary(GameManager.formatSuccessMessage(p0.getNicknameToken() + " wins")); - destroyPlayer(p1); - } - else if (p0.getScore() < p1.getScore()) { - gameManager.addToGameSummary(GameManager.formatSuccessMessage(p1.getNicknameToken() + " wins")); - destroyPlayer(p0); - } - else if (p0.getScore() < 0) { - gameManager.addToGameSummary(GameManager.formatErrorMessage("Everybody loses!")); - destroyPlayer(p0); - destroyPlayer(p1); - } - else { - gameManager.addToGameSummary("Draw."); + if (p0.getScore() > p1.getScore()) { + gameManager.addToGameSummary(GameManager.formatSuccessMessage(p0.getNicknameToken() + " wins")); + destroyPlayer(p1); + } + else if (p0.getScore() < p1.getScore()) { + gameManager.addToGameSummary(GameManager.formatSuccessMessage(p1.getNicknameToken() + " wins")); + destroyPlayer(p0); + } + else if (p0.getScore() < 0) { + gameManager.addToGameSummary(GameManager.formatErrorMessage("Everybody loses!")); + destroyPlayer(p0); + destroyPlayer(p1); + } + else { + gameManager.addToGameSummary("Draw."); + } } } }