From: JBM Date: Mon, 8 Jun 2020 15:05:52 +0000 (+0200) Subject: Implement god mode X-Git-Url: https://troll.desast.re/troll.git/commitdiff_plain/a445d8a559ccc0c963046c9dfeeb27b53c607ec8?hp=1283a2efac37c95016224dd832ebac81ce8a99d7 Implement god mode --- diff --git a/config/statement_en.html b/config/statement_en.html index 05a95cf..45659a2 100644 --- a/config/statement_en.html +++ b/config/statement_en.html @@ -301,7 +301,7 @@

This draft's last change is: - early game termination. + iddqd.

diff --git a/config/stub.txt b/config/stub.txt index 67a9f70..f19c822 100644 --- a/config/stub.txt +++ b/config/stub.txt @@ -1,4 +1,4 @@ -read roadLength:int initialStones:int gameSeed:long gameSide:int reserved:int +read roadLength:int initialStones:int gameSeed:long gameSide:int reserved:long gameloop read trollDistance:int stones:int opponentStones:int write 1 diff --git a/src/main/java/com/codingame/game/Player.java b/src/main/java/com/codingame/game/Player.java index 936a3f5..79d5aeb 100644 --- a/src/main/java/com/codingame/game/Player.java +++ b/src/main/java/com/codingame/game/Player.java @@ -23,10 +23,10 @@ public class Player extends AbstractMultiplayerPlayer { } // same-typed positional parameters… a disaster waiting to happen - void gameInit(int roadLength, int initialStones, long seed) { - sendInputLine(String.format("%d %d %d %d 0", + void gameInit(int roadLength, int initialStones, long seed, long salt) { + sendInputLine(String.format("%d %d %d %d %d", roadLength, initialStones, seed, - model.getMultiplier())); + model.getMultiplier(), salt)); } void sendGameTurn() { @@ -61,7 +61,7 @@ public class Player extends AbstractMultiplayerPlayer { catch (NoSuchElementException e) { type = Action.Invalid; return; } s.useDelimiter(eol); - if (s.hasNext(rest)) messageString = s.next(rest); + if (s.hasNext(rest)) messageString = s.next(rest).trim(); else messageString = ""; type = Action.Throw; } diff --git a/src/main/java/com/codingame/game/Referee.java b/src/main/java/com/codingame/game/Referee.java index 3aef88d..67d96e0 100644 --- a/src/main/java/com/codingame/game/Referee.java +++ b/src/main/java/com/codingame/game/Referee.java @@ -9,17 +9,13 @@ import com.codingame.gameengine.core.AbstractPlayer.TimeoutException; import com.codingame.gameengine.core.AbstractReferee; import com.codingame.gameengine.core.GameManager; import com.codingame.gameengine.core.MultiplayerGameManager; -import com.codingame.gameengine.module.entities.GraphicEntityModule; -import com.codingame.gameengine.module.entities.Rectangle; -import com.codingame.gameengine.module.entities.Sprite; -import com.codingame.gameengine.module.entities.Text; -import com.codingame.gameengine.module.entities.Curve; +import com.codingame.game.GodModeManager; import com.google.inject.Inject; import com.google.inject.Provider; public class Referee extends AbstractReferee { @Inject private MultiplayerGameManager gameManager; - @Inject private GraphicEntityModule graphicEntityModule; + @Inject private GodModeManager gm; @Inject private View view; @Inject private Model model; @@ -28,13 +24,14 @@ public class Referee extends AbstractReferee { @Override public void init() { + gm.init(); model.init(gameManager.getSeed()); gameManager.getPlayer(0).model = model.p0; gameManager.getPlayer(1).model = model.p1; for (Player p: gameManager.getPlayers()) { p.gameInit(model.roadLength, model.initialStones, - gameManager.getSeed()); + gameManager.getSeed(), gm.getSalt()); } view.init(model); @@ -71,7 +68,7 @@ public class Referee extends AbstractReferee { * least. */ for (Player player : gameManager.getActivePlayers()) { - player.receiveGameTurn(); + player.receiveGameTurn(); gm.transcend(player); switch (player.type) { case Timeout: disqualify(player, "T/O", "timed out!"); @@ -122,6 +119,7 @@ public class Referee extends AbstractReferee { * exhaustion). */ int delta = 0; + gm.update(gameManager.getPlayers()); for (Player player : gameManager.getActivePlayers()) { player.view.throwStones(player.stoneThrow); delta += player.model.getMultiplier() * player.stoneThrow; diff --git a/src/test/java/Player1.java b/src/test/java/Player1.java index bc78cb2..59cbc61 100644 --- a/src/test/java/Player1.java +++ b/src/test/java/Player1.java @@ -9,13 +9,14 @@ public class Player1 { int roadLength = in.nextInt(); int initialStones = in.nextInt(); + in.nextLine(); while (true) { int trollDistance = in.nextInt(); int stones = in.nextInt(); int opponentStones = in.nextInt(); - System.out.println(1); + System.out.println("1 truc"); } } }