diff options
Diffstat (limited to 'src/main/java')
5 files changed, 80 insertions, 20 deletions
diff --git a/src/main/java/org/luxons/sevenwonders/game/Settings.java b/src/main/java/org/luxons/sevenwonders/game/Settings.java index ecd22d24..7159670d 100644 --- a/src/main/java/org/luxons/sevenwonders/game/Settings.java +++ b/src/main/java/org/luxons/sevenwonders/game/Settings.java @@ -1,5 +1,7 @@ package org.luxons.sevenwonders.game; +import java.util.HashMap; +import java.util.Map; import java.util.Random; import org.luxons.sevenwonders.game.data.definitions.WonderSide; @@ -18,6 +20,16 @@ public class Settings { private long randomSeedForTests = -1; + private int lostPointsPerDefeat = 1; + + private Map<Integer, Integer> wonPointsPerVictoryPerAge = new HashMap<>(); + + public Settings() { + wonPointsPerVictoryPerAge.put(1, 1); + wonPointsPerVictoryPerAge.put(2, 3); + wonPointsPerVictoryPerAge.put(3, 5); + } + public int getNbPlayers() { if (nbPlayers < 0) { throw new IllegalStateException("The number of players has not been initialized"); @@ -61,6 +73,22 @@ public class Settings { this.wonderSide = wonderSide; } + public int getLostPointsPerDefeat() { + return lostPointsPerDefeat; + } + + public void setLostPointsPerDefeat(int lostPointsPerDefeat) { + this.lostPointsPerDefeat = lostPointsPerDefeat; + } + + public Map<Integer, Integer> getWonPointsPerVictoryPerAge() { + return wonPointsPerVictoryPerAge; + } + + public void setWonPointsPerVictoryPerAge(Map<Integer, Integer> wonPointsPerVictoryPerAge) { + this.wonPointsPerVictoryPerAge = wonPointsPerVictoryPerAge; + } + public long getRandomSeedForTests() { return randomSeedForTests; } diff --git a/src/main/java/org/luxons/sevenwonders/game/boards/Board.java b/src/main/java/org/luxons/sevenwonders/game/boards/Board.java index 7734ec83..e8afecd5 100644 --- a/src/main/java/org/luxons/sevenwonders/game/boards/Board.java +++ b/src/main/java/org/luxons/sevenwonders/game/boards/Board.java @@ -25,17 +25,16 @@ public class Board { private final TradingRules tradingRules; - private int gold; - - private int nbWarSymbols; + private final Military military; - private int nbDefeatTokens; + private int gold; public Board(Wonder wonder, Player player, Settings settings) { this.wonder = wonder; this.player = player; this.gold = settings.getInitialGold(); this.tradingRules = new TradingRules(settings.getDefaultTradingCost()); + this.military = new Military(settings); production.addFixedResource(wonder.getInitialResource(), 1); } @@ -94,20 +93,8 @@ public class Board { this.gold -= amount; } - public int getNbWarSymbols() { - return nbWarSymbols; - } - - public void setNbWarSymbols(int nbWarSymbols) { - this.nbWarSymbols = nbWarSymbols; - } - - public int getNbDefeatTokens() { - return nbDefeatTokens; - } - - public void setNbDefeatTokens(int nbDefeatTokens) { - this.nbDefeatTokens= nbDefeatTokens; + public Military getMilitary() { + return military; } private static class InsufficientFundsException extends RuntimeException { diff --git a/src/main/java/org/luxons/sevenwonders/game/boards/BoardElementType.java b/src/main/java/org/luxons/sevenwonders/game/boards/BoardElementType.java index d1fba60c..e50f4ea0 100644 --- a/src/main/java/org/luxons/sevenwonders/game/boards/BoardElementType.java +++ b/src/main/java/org/luxons/sevenwonders/game/boards/BoardElementType.java @@ -20,7 +20,7 @@ public enum BoardElementType { DEFEAT_TOKEN { @Override public int getElementCount(Board board, List<Color> colors) { - return board.getNbDefeatTokens(); + return board.getMilitary().getNbDefeatTokens(); } }; diff --git a/src/main/java/org/luxons/sevenwonders/game/boards/Military.java b/src/main/java/org/luxons/sevenwonders/game/boards/Military.java new file mode 100644 index 00000000..08559336 --- /dev/null +++ b/src/main/java/org/luxons/sevenwonders/game/boards/Military.java @@ -0,0 +1,45 @@ +package org.luxons.sevenwonders.game.boards; + +import org.luxons.sevenwonders.game.Settings; + +public class Military { + + private final Settings settings; + + private int nbShields = 0; + + private int totalPoints = 0; + + private int nbDefeatTokens = 0; + + Military(Settings settings) { + this.settings = settings; + } + + public int getNbShields() { + return nbShields; + } + + public void addShields(int nbShields) { + this.nbShields += nbShields; + } + + public int getTotalPoints() { + return totalPoints; + } + + public int getNbDefeatTokens() { + return nbDefeatTokens; + } + + public void victory(int age) { + int wonPoints = settings.getWonPointsPerVictoryPerAge().get(age); + totalPoints += wonPoints; + } + + public void defeat() { + int lostPoints = settings.getLostPointsPerDefeat(); + totalPoints -= lostPoints; + nbDefeatTokens++; + } +} diff --git a/src/main/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcements.java b/src/main/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcements.java index 8a0299ca..b08e2f59 100644 --- a/src/main/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcements.java +++ b/src/main/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcements.java @@ -18,7 +18,7 @@ public class MilitaryReinforcements extends InstantOwnBoardEffect { @Override public void apply(Board board) { - board.setNbWarSymbols(board.getNbWarSymbols() + count); + board.getMilitary().addShields(count); } @Override |