summaryrefslogtreecommitdiff
path: root/src/main/java/org/luxons
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/luxons')
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/api/Table.java29
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/moves/BuildWonderMove.java8
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/moves/DiscardMove.java5
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/moves/PlayCardMove.java7
4 files changed, 16 insertions, 33 deletions
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 7c3ff34e..a87ea6ae 100644
--- a/src/main/java/org/luxons/sevenwonders/game/api/Table.java
+++ b/src/main/java/org/luxons/sevenwonders/game/api/Table.java
@@ -2,12 +2,9 @@ package org.luxons.sevenwonders.game.api;
import java.util.List;
-import org.luxons.sevenwonders.game.moves.Move;
import org.luxons.sevenwonders.game.boards.Board;
import org.luxons.sevenwonders.game.boards.RelativeBoardPosition;
-import org.luxons.sevenwonders.game.cards.Card;
-import org.luxons.sevenwonders.game.cards.CardBack;
-import org.luxons.sevenwonders.game.resources.BoughtResources;
+import org.luxons.sevenwonders.game.moves.Move;
/**
* The table contains what is visible by all the players in the game: the boards and their played cards, and the
@@ -50,30 +47,6 @@ public class Table {
this.lastPlayedMoves = lastPlayedMoves;
}
- public void placeCard(int playerIndex, Card card) {
- Board board = boards.get(playerIndex);
- board.addCard(card);
- }
-
- public void buildWonderStage(int playerIndex, CardBack cardBack) {
- Board board = boards.get(playerIndex);
- board.getWonder().buildLevel(cardBack);
- }
-
- public void activateCard(int playerIndex, Card card, List<BoughtResources> boughtResources) {
- card.applyTo(this, playerIndex, boughtResources);
- }
-
- public void activateCurrentWonderStage(int playerIndex, List<BoughtResources> boughtResources) {
- Board board = boards.get(playerIndex);
- board.getWonder().activateLastBuiltStage(this, playerIndex, boughtResources);
- }
-
- public void giveGoldForDiscarded(int playerIndex, int goldBonus) {
- Board board = boards.get(playerIndex);
- board.addGold(goldBonus);
- }
-
public void resolveMilitaryConflicts(int age) {
for (int i = 0; i < nbPlayers; i++) {
Board board1 = getBoard(i);
diff --git a/src/main/java/org/luxons/sevenwonders/game/moves/BuildWonderMove.java b/src/main/java/org/luxons/sevenwonders/game/moves/BuildWonderMove.java
index 2e682fde..ebc9ac99 100644
--- a/src/main/java/org/luxons/sevenwonders/game/moves/BuildWonderMove.java
+++ b/src/main/java/org/luxons/sevenwonders/game/moves/BuildWonderMove.java
@@ -14,6 +14,7 @@ public class BuildWonderMove extends Move {
super(playerIndex, card, move);
}
+ @Override
public boolean isValid(Table table) {
Board board = table.getBoard(getPlayerIndex());
return board.getWonder().isNextStageBuildable(table, getPlayerIndex(), getBoughtResources());
@@ -21,11 +22,14 @@ public class BuildWonderMove extends Move {
@Override
public void place(Table table, List<Card> discardedCards, Settings settings) {
- table.buildWonderStage(getPlayerIndex(), getCard().getBack());
+ Board board = table.getBoard(getPlayerIndex());
+ board.getWonder().buildLevel(getCard().getBack());
}
@Override
public void activate(Table table, List<Card> discardedCards, Settings settings) {
- table.activateCurrentWonderStage(getPlayerIndex(), getBoughtResources());
+ int playerIndex = getPlayerIndex();
+ Board board = table.getBoard(playerIndex);
+ board.getWonder().activateLastBuiltStage(table, playerIndex, getBoughtResources());
}
}
diff --git a/src/main/java/org/luxons/sevenwonders/game/moves/DiscardMove.java b/src/main/java/org/luxons/sevenwonders/game/moves/DiscardMove.java
index 9e4bcd68..30c2472d 100644
--- a/src/main/java/org/luxons/sevenwonders/game/moves/DiscardMove.java
+++ b/src/main/java/org/luxons/sevenwonders/game/moves/DiscardMove.java
@@ -5,6 +5,7 @@ import java.util.List;
import org.luxons.sevenwonders.game.Settings;
import org.luxons.sevenwonders.game.api.PlayerMove;
import org.luxons.sevenwonders.game.api.Table;
+import org.luxons.sevenwonders.game.boards.Board;
import org.luxons.sevenwonders.game.cards.Card;
public class DiscardMove extends Move {
@@ -13,6 +14,7 @@ public class DiscardMove extends Move {
super(playerIndex, card, move);
}
+ @Override
public boolean isValid(Table table) {
return true;
}
@@ -24,6 +26,7 @@ public class DiscardMove extends Move {
@Override
public void activate(Table table, List<Card> discardedCards, Settings settings) {
- table.giveGoldForDiscarded(getPlayerIndex(), settings.getDiscardedCardGold());
+ Board board = table.getBoard(getPlayerIndex());
+ board.addGold(settings.getDiscardedCardGold());
}
}
diff --git a/src/main/java/org/luxons/sevenwonders/game/moves/PlayCardMove.java b/src/main/java/org/luxons/sevenwonders/game/moves/PlayCardMove.java
index ee4dbb11..ee8e2128 100644
--- a/src/main/java/org/luxons/sevenwonders/game/moves/PlayCardMove.java
+++ b/src/main/java/org/luxons/sevenwonders/game/moves/PlayCardMove.java
@@ -5,6 +5,7 @@ import java.util.List;
import org.luxons.sevenwonders.game.Settings;
import org.luxons.sevenwonders.game.api.PlayerMove;
import org.luxons.sevenwonders.game.api.Table;
+import org.luxons.sevenwonders.game.boards.Board;
import org.luxons.sevenwonders.game.cards.Card;
public class PlayCardMove extends Move {
@@ -13,17 +14,19 @@ public class PlayCardMove extends Move {
super(playerIndex, card, move);
}
+ @Override
public boolean isValid(Table table) {
return getCard().getRequirements().isAffordedBy(table, getPlayerIndex(), getBoughtResources());
}
@Override
public void place(Table table, List<Card> discardedCards, Settings settings) {
- table.placeCard(getPlayerIndex(), getCard());
+ Board board = table.getBoard(getPlayerIndex());
+ board.addCard(getCard());
}
@Override
public void activate(Table table, List<Card> discardedCards, Settings settings) {
- table.activateCard(getPlayerIndex(), getCard(), getBoughtResources());
+ getCard().applyTo(table, getPlayerIndex(), getBoughtResources());
}
}
bgstack15