X-Git-Url: https://troll.desast.re/troll.git/blobdiff_plain/2032e4c0fbf3f7a170640aecdf41698f85dd9753..e0290aa2bf6fe6c998d30101fcad648baa2cfcd5:/src/main/java/com/codingame/game/Referee.java?ds=sidebyside diff --git a/src/main/java/com/codingame/game/Referee.java b/src/main/java/com/codingame/game/Referee.java index 3de5140..7a718e9 100644 --- a/src/main/java/com/codingame/game/Referee.java +++ b/src/main/java/com/codingame/game/Referee.java @@ -14,6 +14,7 @@ import com.google.inject.Provider; public class Referee extends AbstractReferee { @Inject private GameManager gameManager; @Inject private GodModeManager gm; + @Inject private LeagueManager league; @Inject private View view; @Inject private Model model; @@ -80,7 +81,17 @@ public class Referee extends AbstractReferee { case Throw: try { player.model.consumeStones(player.stoneThrow); } catch (Model.Player.ThrewMoreStonesThanHad e) { - if (model.random.nextInt(10) > 0) { + boolean FIX_IT; + switch (league.fixLevel) { + case SOMETIMES: + FIX_IT = model.random.nextInt(10) > 0; + break; + case NEVER: + FIX_IT = false; + break; + default: throw new JavaLimitationError(); + } + if (FIX_IT) { player.view.threwMoreStonesThanHad(); player.stoneThrow = player.model.consumeMaxStones(); } @@ -91,7 +102,17 @@ public class Referee extends AbstractReferee { } } catch (Model.Player.FailedToThrowStonesAndShouldHave e) { - if (model.random.nextInt(10) > 0) { + boolean FIX_IT; + switch (league.fixLevel) { + case SOMETIMES: + FIX_IT = model.random.nextInt(10) > 0; + break; + case NEVER: + FIX_IT = false; + break; + default: throw new JavaLimitationError(); + } + if (FIX_IT) { player.view.failedToThrowStonesAndShouldHave(); player.stoneThrow = player.model.consumeMinStones(); } @@ -104,6 +125,7 @@ public class Referee extends AbstractReferee { } player.view.displayMessage(player.messageString); } + if (disqual) return; /* Update game model and view, stones' part. * @@ -122,9 +144,19 @@ public class Referee extends AbstractReferee { delta += player.model.getMultiplier() * player.stoneThrow; if (player.stoneThrow < 0) { - disqualify(player, "CHEAT", "cheated. Banning account."); - player.view.markCheat(); - disqual = true; + switch(league.cheatLevel) { + case ALLOWED: + break; + case TOLERATED: + player.view.markCheat(); + if (model.random.nextInt(2) == 0) player.model.loseRound(); + break; + case FORBIDDEN: + disqualify(player, "CHEAT", "cheated. Banning account."); + player.view.markCheat(); + disqual = true; + break; + } } if (player.stoneThrow != 0) { player.view.animateStones(player.stoneThrow);