X-Git-Url: https://troll.desast.re/troll.git/blobdiff_plain/d937965ea7311dee330b5c40fdce2a13a3a94676..055ce8e682c4b82d5b52362e88df2f9d6a7d53d6:/src/main/java/com/codingame/game/Model.java diff --git a/src/main/java/com/codingame/game/Model.java b/src/main/java/com/codingame/game/Model.java index 405db66..46841db 100644 --- a/src/main/java/com/codingame/game/Model.java +++ b/src/main/java/com/codingame/game/Model.java @@ -1,7 +1,9 @@ package com.codingame.game; import java.util.Random; +import java.util.Properties; +import com.codingame.gameengine.core.GameManager; import com.codingame.gameengine.core.MultiplayerGameManager; import com.google.inject.Inject; @@ -93,6 +95,40 @@ class Model { break; } + Properties ps = gameManager.getGameParameters(); + String buf = ps.getProperty("roadLength"); + if (buf != null) { + try { + int i = Integer.parseInt(buf); + if (i < 0 || i > 20 || (i & 1) != 0) { + gameManager.addToGameSummary(GameManager.formatErrorMessage("Ignoring invalid road length: " + buf)); + } + else { + roadLength = i; + gameManager.addToGameSummary("Road length overridden to " + i); + } + } + catch(NumberFormatException e) { + gameManager.addToGameSummary(GameManager.formatErrorMessage("Ill-formed road length: " + buf)); + } + } + buf = ps.getProperty("initialStones"); + if (buf != null) { + try { + int i = Integer.parseInt(buf); + if (i > 50) { + gameManager.addToGameSummary(GameManager.formatErrorMessage("Ignoring invalid initial stone count: " + buf)); + } + else { + initialStones = i; + gameManager.addToGameSummary("Initial stone count overridden to " + buf); + } + } + catch (NumberFormatException e) { + gameManager.addToGameSummary(GameManager.formatErrorMessage("Ill-formed initial stone count: " + buf)); + } + } + trollPosition = roadLength / 2; p0 = new Player(0);