Ça trolle…
/
troll.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Leaguify cheating
[troll.git]
/
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
00701d1
..
217388a
100644
(file)
--- a/
src/main/java/com/codingame/game/Model.java
+++ b/
src/main/java/com/codingame/game/Model.java
@@
-9,6
+9,7
@@
import com.google.inject.Inject;
class Model {
@Inject private MultiplayerGameManager<com.codingame.game.Player> gameManager;
class Model {
@Inject private MultiplayerGameManager<com.codingame.game.Player> gameManager;
+ long seed;
Random random;
int roadLength;
int initialStones;
Random random;
int roadLength;
int initialStones;
@@
-18,8
+19,17
@@
class Model {
class Player {
com.codingame.game.Player gp;
int index;
class Player {
com.codingame.game.Player gp;
int index;
+ boolean hit;
- Player(int i) { index = i; }
+ Player(int i) {
+ index = i;
+ hit = false;
+ }
+
+ void loseRound() {
+ hit = true;
+ winner = 1 - index;
+ }
private int castlePosition;
public int getCastlePosition() { return castlePosition; }
private int castlePosition;
public int getCastlePosition() { return castlePosition; }
@@
-66,7
+76,9
@@
class Model {
}
public void adjustScore(int trollPosition) {
}
public void adjustScore(int trollPosition) {
- gp.setScore(Math.abs(castlePosition - trollPosition));
+ if (gp.isActive()) {
+ gp.setScore(Math.abs(castlePosition - trollPosition));
+ }
}
public int getTrollDistance() {
}
public int getTrollDistance() {
@@
-74,7
+86,8
@@
class Model {
}
}
}
}
- void init(long seed) {
+ void init() {
+ seed = gameManager.getSeed();
random = new Random(seed);
switch (random.nextInt(4)) {
case 0:
random = new Random(seed);
switch (random.nextInt(4)) {
case 0:
@@
-149,24
+162,30
@@
class Model {
p1.setStones(initialStones);
}
p1.setStones(initialStones);
}
- private int winner;
- boolean haveWinner() {
- if (trollPosition == 0) {
+ void moveTroll(int delta) {
+ trollPosition += delta;
+ if (trollPosition <= 0) {
+ trollPosition = 0;
winner = 1;
winner = 1;
- return true;
}
}
- else if (trollPosition == roadLength) {
+ if (trollPosition >= roadLength) {
+ trollPosition = roadLength;
winner = 0;
winner = 0;
- return true;
- }
- else {
- return false;
}
}
+
+ p0.adjustScore(trollPosition);
+ p1.adjustScore(trollPosition);
+ }
+
+ private Integer winner;
+ boolean haveWinner() {
+ return winner != null;
}
}
+
int getWinner() { return winner; }
int getLoser() { return 1 - winner; }
boolean exhausted() {
int getWinner() { return winner; }
int getLoser() { return 1 - winner; }
boolean exhausted() {
- return p0.getStones() <= 0
&&
p1.getStones() <= 0;
+ return p0.getStones() <= 0
||
p1.getStones() <= 0;
}
}
}
}