Ça trolle…
/
troll.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fddaf46
)
FIX IT. (and curse Java)
author
JBM
<jbm@codingame.com>
Sun, 14 Jun 2020 22:39:49 +0000
(
00:39
+0200)
committer
JBM
<jbm@codingame.com>
Sun, 14 Jun 2020 22:39:49 +0000
(
00:39
+0200)
src/main/java/com/codingame/game/JavaLimitationError.java
[new file with mode: 0644]
patch
|
blob
src/main/java/com/codingame/game/LeagueManager.java
patch
|
blob
|
history
src/main/java/com/codingame/game/Referee.java
patch
|
blob
|
history
diff --git a/src/main/java/com/codingame/game/JavaLimitationError.java
b/src/main/java/com/codingame/game/JavaLimitationError.java
new file mode 100644
(file)
index 0000000..
4778a13
--- /dev/null
+++ b/
src/main/java/com/codingame/game/JavaLimitationError.java
@@ -0,0
+1,3
@@
+package com.codingame.game;
+
+class JavaLimitationError extends InternalError {}
diff --git
a/src/main/java/com/codingame/game/LeagueManager.java
b/src/main/java/com/codingame/game/LeagueManager.java
index
fe2187c
..
78f15f1
100644
(file)
--- a/
src/main/java/com/codingame/game/LeagueManager.java
+++ b/
src/main/java/com/codingame/game/LeagueManager.java
@@
-21,6
+21,9
@@
class LeagueManager {
}
MapLevel mapLevel;
}
MapLevel mapLevel;
+ enum FixLevel { SOMETIMES, NEVER }
+ FixLevel fixLevel;
+
@Inject
LeagueManager(MultiplayerGameManager<AbstractMultiplayerPlayer> gameManager)
{
@Inject
LeagueManager(MultiplayerGameManager<AbstractMultiplayerPlayer> gameManager)
{
@@
-37,5
+40,6
@@
class LeagueManager {
: level <= 2 ? MapLevel.DISCRETE
: MapLevel.CONTINUOUS;
: level <= 2 ? MapLevel.DISCRETE
: MapLevel.CONTINUOUS;
+ fixLevel = level <= 1 ? FixLevel.SOMETIMES : FixLevel.NEVER;
}
}
}
}
diff --git
a/src/main/java/com/codingame/game/Referee.java
b/src/main/java/com/codingame/game/Referee.java
index
fb99ef9
..
7a718e9
100644
(file)
--- a/
src/main/java/com/codingame/game/Referee.java
+++ b/
src/main/java/com/codingame/game/Referee.java
@@
-81,7
+81,17
@@
public class Referee extends AbstractReferee {
case Throw:
try { player.model.consumeStones(player.stoneThrow); }
catch (Model.Player.ThrewMoreStonesThanHad e) {
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();
}
player.view.threwMoreStonesThanHad();
player.stoneThrow = player.model.consumeMaxStones();
}
@@
-92,7
+102,17
@@
public class Referee extends AbstractReferee {
}
}
catch (Model.Player.FailedToThrowStonesAndShouldHave e) {
}
}
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();
}
player.view.failedToThrowStonesAndShouldHave();
player.stoneThrow = player.model.consumeMinStones();
}