summaryrefslogtreecommitdiff
path: root/src/main/java/org/luxons/sevenwonders
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2016-12-25 15:54:58 +0100
committerjbion <joffrey.bion@amadeus.com>2016-12-25 15:55:13 +0100
commit9cc964926891b9655571d553fbf0bbf2bc4174f2 (patch)
tree9d6747b329f5b0578b06b7e9ee1873b681d6a5dd /src/main/java/org/luxons/sevenwonders
parentAdd military conflict resolution at end of age (diff)
downloadseven-wonders-9cc964926891b9655571d553fbf0bbf2bc4174f2.tar.gz
seven-wonders-9cc964926891b9655571d553fbf0bbf2bc4174f2.tar.bz2
seven-wonders-9cc964926891b9655571d553fbf0bbf2bc4174f2.zip
Add proper test for military victory/defeat points
Diffstat (limited to 'src/main/java/org/luxons/sevenwonders')
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/boards/Military.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/org/luxons/sevenwonders/game/boards/Military.java b/src/main/java/org/luxons/sevenwonders/game/boards/Military.java
index 08559336..fb93fa96 100644
--- a/src/main/java/org/luxons/sevenwonders/game/boards/Military.java
+++ b/src/main/java/org/luxons/sevenwonders/game/boards/Military.java
@@ -33,7 +33,10 @@ public class Military {
}
public void victory(int age) {
- int wonPoints = settings.getWonPointsPerVictoryPerAge().get(age);
+ Integer wonPoints = settings.getWonPointsPerVictoryPerAge().get(age);
+ if (wonPoints == null) {
+ throw new UnknownAgeException(age);
+ }
totalPoints += wonPoints;
}
@@ -42,4 +45,10 @@ public class Military {
totalPoints -= lostPoints;
nbDefeatTokens++;
}
+
+ static final class UnknownAgeException extends IllegalArgumentException {
+ UnknownAgeException(int unknownAge) {
+ super(String.valueOf(unknownAge));
+ }
+ }
}
bgstack15