diff options
Diffstat (limited to 'src')
3 files changed, 21 insertions, 9 deletions
diff --git a/src/main/java/org/luxons/sevenwonders/game/Game.java b/src/main/java/org/luxons/sevenwonders/game/Game.java index 53b8bc53..d9dec5fd 100644 --- a/src/main/java/org/luxons/sevenwonders/game/Game.java +++ b/src/main/java/org/luxons/sevenwonders/game/Game.java @@ -108,7 +108,7 @@ public class Game { table.placeCard(playerIndex, decks.getCard(move.getCardName())); break; case UPGRADE_WONDER: - // TODO pre-upgrade the level of wonder without effect + table.upgradeWonderStage(playerIndex); break; case DISCARD: discardedCards.add(decks.getCard(move.getCardName())); @@ -121,10 +121,10 @@ public class Game { preparedMoves.forEach((playerIndex, move) -> { switch (move.getType()) { case PLAY: - table.playCard(playerIndex, decks.getCard(move.getCardName())); + table.activateCard(playerIndex, decks.getCard(move.getCardName())); break; case UPGRADE_WONDER: - table.upgradeWonder(playerIndex); + table.activateCurrentWonderStage(playerIndex); break; case DISCARD: table.discard(playerIndex, settings.getDiscardedCardGold()); diff --git a/src/main/java/org/luxons/sevenwonders/game/api/Table.java b/src/main/java/org/luxons/sevenwonders/game/api/Table.java index 7a2e20dc..44813ee9 100644 --- a/src/main/java/org/luxons/sevenwonders/game/api/Table.java +++ b/src/main/java/org/luxons/sevenwonders/game/api/Table.java @@ -47,18 +47,23 @@ public class Table { board.addCard(card); } - public void upgradeWonder(int playerIndex) { + public void upgradeWonderStage(int playerIndex) { + Board board = boards.get(playerIndex); + board.increaseWonderLevel(); + } + + public void activateCard(int playerIndex, Card card) { Board board = boards.get(playerIndex); Board left = boards.get(wrapIndex(playerIndex - 1)); Board right = boards.get(wrapIndex(playerIndex + 1)); - board.upgradeWonderLevel(left, right); + card.applyTo(board, left, right); } - public void playCard(int playerIndex, Card card) { + public void activateCurrentWonderStage(int playerIndex) { Board board = boards.get(playerIndex); Board left = boards.get(wrapIndex(playerIndex - 1)); Board right = boards.get(wrapIndex(playerIndex + 1)); - card.applyTo(board, left, right); + board.activateCurrentWonderLevel(left, right); } public void discard(int playerIndex, int goldBonus) { 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 08bedb89..1ac70daf 100644 --- a/src/main/java/org/luxons/sevenwonders/game/boards/Board.java +++ b/src/main/java/org/luxons/sevenwonders/game/boards/Board.java @@ -81,13 +81,20 @@ public class Board { return wonderLevel; } - public void upgradeWonderLevel(Board leftNeighbourBoard, Board rightNeighbourBoard) { + public void increaseWonderLevel() { int maxLevel = wonder.getLevels().size(); if (maxLevel == wonderLevel) { throw new IllegalStateException("This wonder has already reached its maximum level"); } this.wonderLevel++; - wonder.getLevels().get(wonderLevel).activate(this, leftNeighbourBoard, rightNeighbourBoard); + } + + public void activateCurrentWonderLevel(Board leftNeighbourBoard, Board rightNeighbourBoard) { + activateWonderLevel(wonderLevel, leftNeighbourBoard, rightNeighbourBoard); + } + + public void activateWonderLevel(int level, Board leftNeighbourBoard, Board rightNeighbourBoard) { + wonder.getLevels().get(level).activate(this, leftNeighbourBoard, rightNeighbourBoard); } public int getNbWarSymbols() { |