X-Git-Url: https://troll.desast.re/troll.git/blobdiff_plain/20c63dac92d830a4c61f6d17ecfb8e7e0d04e58d..798b92dbe890d45ae15aa896f78a6f60dd84b89e:/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 f087503..edcafe2 100644 --- a/src/main/java/com/codingame/game/Referee.java +++ b/src/main/java/com/codingame/game/Referee.java @@ -21,37 +21,16 @@ public class Referee extends AbstractReferee { @Inject private MultiplayerGameManager gameManager; @Inject private GraphicEntityModule graphicEntityModule; + @Inject private View view; + Model model = new Model(); // Hybrid :-( Player p0, p1; - // View - View view = new View(); - @Override public void init() { - model.random = new Random(gameManager.getSeed()); - switch (model.random.nextInt(4)) { - case 0: - model.roadLength = 6; - model.initialStones = 15; - break; - case 1: - model.roadLength = 6; - model.initialStones = 30; - break; - case 2: - model.roadLength = 14; - model.initialStones = 30; - break; - case 3: - model.roadLength = 14; - model.initialStones = 50; - break; - } - - model.trollPosition = model.roadLength / 2; + model.init(gameManager.getSeed()); p0 = gameManager.getPlayer(0); p0.setCastlePosition(0); @@ -65,21 +44,14 @@ public class Referee extends AbstractReferee { p1.adjustScore(model.trollPosition); p1.sendInputLine(String.format("%d %d", model.roadLength, model.initialStones)); - drawBackground(); + view.init(); drawPlayer(); - drawTroll(); // result in text display, so do last: p0.setStones(model.initialStones); p1.setStones(model.initialStones); - gameManager.setFrameDuration(2000); - } - - private void drawBackground() { - graphicEntityModule.createSprite() - .setImage("background.png") - .setAnchor(0); + gameManager.setFrameDuration(2000); // XXX } private void drawPlayer() { @@ -162,23 +134,6 @@ public class Referee extends AbstractReferee { } } - private void drawTroll() { - view.troll = graphicEntityModule.createSprite() - .setImage("troll.png") - .setAnchorX(0.5) - .setAnchorY(1) - .setX(1920/2) - .setY(880) - .setZIndex(2); - view.trollPositionGauge = graphicEntityModule.createText() - .setZIndex(2) - .setAnchor(0.5) - .setFontSize(40) - .setX(1980/2) - .setY(980) - .setFillColor(0xffffff); - } - private void moveTroll() { graphicEntityModule.commitEntityState(0.5, view.troll, view.trollPositionGauge); int x0 = p0.castle.getX(), x1 = p1.castle.getX(); @@ -218,7 +173,7 @@ public class Referee extends AbstractReferee { try { int stones = player.getAction(); if (stones == 0 && player.getStones() > 0) { - if (view.random.nextInt(10) > 0) { + if (model.random.nextInt(10) > 0) { gameManager.addToGameSummary(GameManager.formatErrorMessage(player.getNicknameToken() + " tried not throwing stones. Fixing that for them because I'm in a good mood today.")); stones = 1; }