FIX: IT belongs in a MODEL!
[troll.git] / src / main / java / com / codingame / game / Referee.java
index 19ef894..8f5fc97 100644 (file)
@@ -81,7 +81,7 @@ public class Referee extends AbstractReferee {
             case Throw:
                 try { player.model.consumeStones(player.stoneThrow); }
                 catch (Model.Player.ThrewMoreStonesThanHad e) {
-                    if (model.random.nextInt(10) > 0) {
+                    if (model.FIX_IT()) {
                         player.view.threwMoreStonesThanHad();
                         player.stoneThrow = player.model.consumeMaxStones();
                     }
@@ -92,7 +92,7 @@ public class Referee extends AbstractReferee {
                     }
                 }
                 catch (Model.Player.FailedToThrowStonesAndShouldHave e) {
-                    if (model.random.nextInt(10) > 0) {
+                    if (model.FIX_IT()) {
                         player.view.failedToThrowStonesAndShouldHave();
                         player.stoneThrow = player.model.consumeMinStones();
                     }
@@ -105,6 +105,7 @@ public class Referee extends AbstractReferee {
             }
             player.view.displayMessage(player.messageString);
         }
+        if (disqual) return;
 
         /* Update game model and view, stones' part.
          *
@@ -123,9 +124,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);