summaryrefslogtreecommitdiff
path: root/src/main/java/org/luxons
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2016-12-25 15:06:05 +0100
committerjbion <joffrey.bion@amadeus.com>2016-12-25 15:06:05 +0100
commit4f98ee8c5ecdab75c280211b894c5631eea1ed4b (patch)
treed56967419a29fd2c171d72eb90fa324521892668 /src/main/java/org/luxons
parentMake use of addGold instead of setGold when possible (diff)
downloadseven-wonders-4f98ee8c5ecdab75c280211b894c5631eea1ed4b.tar.gz
seven-wonders-4f98ee8c5ecdab75c280211b894c5631eea1ed4b.tar.bz2
seven-wonders-4f98ee8c5ecdab75c280211b894c5631eea1ed4b.zip
Add military conflict resolution at end of age
Diffstat (limited to 'src/main/java/org/luxons')
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/Game.java2
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/api/Table.java20
2 files changed, 21 insertions, 1 deletions
diff --git a/src/main/java/org/luxons/sevenwonders/game/Game.java b/src/main/java/org/luxons/sevenwonders/game/Game.java
index 7a2f72d2..a2ebf618 100644
--- a/src/main/java/org/luxons/sevenwonders/game/Game.java
+++ b/src/main/java/org/luxons/sevenwonders/game/Game.java
@@ -190,7 +190,7 @@ public class Game {
}
private void executeEndOfAgeEvents() {
- // TODO resolve military conflicts
+ table.resolveMilitaryConflicts(currentAge);
}
private int getHandRotationOffset() {
diff --git a/src/main/java/org/luxons/sevenwonders/game/api/Table.java b/src/main/java/org/luxons/sevenwonders/game/api/Table.java
index 87187a75..9655cb36 100644
--- a/src/main/java/org/luxons/sevenwonders/game/api/Table.java
+++ b/src/main/java/org/luxons/sevenwonders/game/api/Table.java
@@ -72,4 +72,24 @@ public class Table {
Board board = boards.get(playerIndex);
board.addGold(goldBonus);
}
+
+ public void resolveMilitaryConflicts(int age) {
+ for (int i = 0; i < nbPlayers; i++) {
+ Board board1 = getBoard(i);
+ Board board2 = getBoard((i + 1) % nbPlayers);
+ resolveConflict(board1, board2, age);
+ }
+ }
+
+ private static void resolveConflict(Board board1, Board board2, int age) {
+ int shields1 = board1.getMilitary().getNbShields();
+ int shields2 = board2.getMilitary().getNbShields();
+ if (shields1 < shields2) {
+ board2.getMilitary().victory(age);
+ board1.getMilitary().defeat();
+ } else if (shields1 > shields2) {
+ board1.getMilitary().victory(age);
+ board2.getMilitary().defeat();
+ }
+ }
}
bgstack15