summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2016-12-23 01:34:11 +0100
committerjbion <joffrey.bion@amadeus.com>2016-12-23 01:34:11 +0100
commit6588478ae08365a6b29fdb0771bafd4588390726 (patch)
tree6d072f56cd95b8b5266dfed9f25249509f9a3500 /src/main/java
parentAdd tests for ScienceProgress (diff)
downloadseven-wonders-6588478ae08365a6b29fdb0771bafd4588390726.tar.gz
seven-wonders-6588478ae08365a6b29fdb0771bafd4588390726.tar.bz2
seven-wonders-6588478ae08365a6b29fdb0771bafd4588390726.zip
Fix science points computation
Missing values for some science types used to mess up the points calculation. Now, even if the value is missing for a science type, it is properly considered as a 0.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/boards/Science.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/java/org/luxons/sevenwonders/game/boards/Science.java b/src/main/java/org/luxons/sevenwonders/game/boards/Science.java
index 71687657..5be8e23e 100644
--- a/src/main/java/org/luxons/sevenwonders/game/boards/Science.java
+++ b/src/main/java/org/luxons/sevenwonders/game/boards/Science.java
@@ -36,7 +36,11 @@ public class Science {
}
public int computePoints() {
- Integer[] values = quantities.values().toArray(new Integer[quantities.size()]);
+ ScienceType[] types = ScienceType.values();
+ Integer[] values = new Integer[types.length];
+ for (int i = 0; i < types.length; i++) {
+ values[i] = quantities.getOrDefault(types[i], 0);
+ }
return computePoints(values, jokers);
}
bgstack15