diff options
Diffstat (limited to 'src/main/java/org/luxons/sevenwonders')
-rw-r--r-- | src/main/java/org/luxons/sevenwonders/game/Game.java | 2 | ||||
-rw-r--r-- | src/main/java/org/luxons/sevenwonders/game/api/Table.java | 20 |
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(); + } + } } |