diff options
3 files changed, 12 insertions, 18 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++; } diff --git a/backend/src/test/java/org/luxons/sevenwonders/game/boards/MilitaryTest.java b/backend/src/test/java/org/luxons/sevenwonders/game/boards/MilitaryTest.java index 7ef253db..16073e91 100644 --- a/backend/src/test/java/org/luxons/sevenwonders/game/boards/MilitaryTest.java +++ b/backend/src/test/java/org/luxons/sevenwonders/game/boards/MilitaryTest.java @@ -10,11 +10,9 @@ import org.junit.experimental.theories.Theories; import org.junit.experimental.theories.Theory; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.luxons.sevenwonders.game.Settings; -import org.luxons.sevenwonders.game.api.CustomizableSettings; import org.luxons.sevenwonders.game.boards.Military.UnknownAgeException; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; @RunWith(Theories.class) public class MilitaryTest { @@ -35,13 +33,7 @@ public class MilitaryTest { private static Military createMilitary(int age, int nbPointsPerVictory, int nbPointsPerDefeat) { Map<Integer, Integer> wonPointsPerAge = new HashMap<>(); wonPointsPerAge.put(age, nbPointsPerVictory); - - CustomizableSettings customSettings = new CustomizableSettings(); - customSettings.setWonPointsPerVictoryPerAge(wonPointsPerAge); - customSettings.setLostPointsPerDefeat(nbPointsPerDefeat); - - Settings settings = new Settings(5, customSettings); - return new Military(settings); + return new Military(nbPointsPerDefeat, wonPointsPerAge); } @Theory |