diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2017-02-01 22:35:52 +0100 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2017-02-01 22:35:52 +0100 |
commit | 4a9a8999fe13e16505ca2c837eb4fcac467b53d7 (patch) | |
tree | 1689faeeace4672447d174af116f760ec4eb08a1 /backend/src/main | |
parent | Add first tests for Requirements (diff) | |
download | seven-wonders-4a9a8999fe13e16505ca2c837eb4fcac467b53d7.tar.gz seven-wonders-4a9a8999fe13e16505ca2c837eb4fcac467b53d7.tar.bz2 seven-wonders-4a9a8999fe13e16505ca2c837eb4fcac467b53d7.zip |
Refactor Military to be independent of Settings
Diffstat (limited to 'backend/src/main')
-rw-r--r-- | backend/src/main/java/org/luxons/sevenwonders/game/boards/Board.java | 2 | ||||
-rw-r--r-- | backend/src/main/java/org/luxons/sevenwonders/game/boards/Military.java | 16 |
2 files changed, 10 insertions, 8 deletions
diff --git a/backend/src/main/java/org/luxons/sevenwonders/game/boards/Board.java b/backend/src/main/java/org/luxons/sevenwonders/game/boards/Board.java index 6ba776c7..0d85ac51 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/game/boards/Board.java +++ b/backend/src/main/java/org/luxons/sevenwonders/game/boards/Board.java @@ -52,7 +52,7 @@ public class Board { this.player = player; this.gold = settings.getInitialGold(); this.tradingRules = new TradingRules(settings.getDefaultTradingCost()); - this.military = new Military(settings); + this.military = new Military(settings.getLostPointsPerDefeat(), settings.getWonPointsPerVictoryPerAge()); this.pointsPer3Gold = settings.getPointsPer3Gold(); this.production.addFixedResource(wonder.getInitialResource(), 1); this.publicProduction.addFixedResource(wonder.getInitialResource(), 1); diff --git a/backend/src/main/java/org/luxons/sevenwonders/game/boards/Military.java b/backend/src/main/java/org/luxons/sevenwonders/game/boards/Military.java index fb93fa96..e5cc7033 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/game/boards/Military.java +++ b/backend/src/main/java/org/luxons/sevenwonders/game/boards/Military.java @@ -1,10 +1,12 @@ package org.luxons.sevenwonders.game.boards; -import org.luxons.sevenwonders.game.Settings; +import java.util.Map; public class Military { - private final Settings settings; + private final int lostPointsPerDefeat; + + private final Map<Integer, Integer> wonPointsPerVictoryPerAge; private int nbShields = 0; @@ -12,8 +14,9 @@ public class Military { private int nbDefeatTokens = 0; - Military(Settings settings) { - this.settings = settings; + Military(int lostPointsPerDefeat, Map<Integer, Integer> wonPointsPerVictoryPerAge) { + this.lostPointsPerDefeat = lostPointsPerDefeat; + this.wonPointsPerVictoryPerAge = wonPointsPerVictoryPerAge; } public int getNbShields() { @@ -33,7 +36,7 @@ public class Military { } public void victory(int age) { - Integer wonPoints = settings.getWonPointsPerVictoryPerAge().get(age); + Integer wonPoints = wonPointsPerVictoryPerAge.get(age); if (wonPoints == null) { throw new UnknownAgeException(age); } @@ -41,8 +44,7 @@ public class Military { } public void defeat() { - int lostPoints = settings.getLostPointsPerDefeat(); - totalPoints -= lostPoints; + totalPoints -= lostPointsPerDefeat; nbDefeatTokens++; } |