From 9cc964926891b9655571d553fbf0bbf2bc4174f2 Mon Sep 17 00:00:00 2001 From: jbion Date: Sun, 25 Dec 2016 15:54:58 +0100 Subject: Add proper test for military victory/defeat points --- .../java/org/luxons/sevenwonders/game/boards/Military.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/main/java/org/luxons') 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)); + } + } } -- cgit