FIX IT. (and curse Java)
[troll.git] / src / main / java / com / codingame / game / Referee.java
index fb99ef9..7a718e9 100644 (file)
@@ -81,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();
                     }
@@ -92,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();
                     }