summaryrefslogtreecommitdiff
path: root/backend/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'backend/src/main/java')
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/game/Game.java3
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/game/api/PlayerTurnInfo.java12
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/game/api/Table.java22
3 files changed, 37 insertions, 0 deletions
diff --git a/backend/src/main/java/org/luxons/sevenwonders/game/Game.java b/backend/src/main/java/org/luxons/sevenwonders/game/Game.java
index 62cbab88..c34880d2 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/game/Game.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/game/Game.java
@@ -78,6 +78,9 @@ public class Game {
Action action = determineAction(hand, table.getBoard(playerIndex));
pti.setAction(action);
pti.setMessage(action.getMessage());
+ if (action == Action.PICK_NEIGHBOR_GUILD) {
+ pti.setNeighbourGuildCards(table.getNeighbourGuildCards(playerIndex));
+ }
return pti;
}
diff --git a/backend/src/main/java/org/luxons/sevenwonders/game/api/PlayerTurnInfo.java b/backend/src/main/java/org/luxons/sevenwonders/game/api/PlayerTurnInfo.java
index ccb045c2..3d92d40b 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/game/api/PlayerTurnInfo.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/game/api/PlayerTurnInfo.java
@@ -2,6 +2,8 @@ package org.luxons.sevenwonders.game.api;
import java.util.List;
+import org.luxons.sevenwonders.game.cards.Card;
+
public class PlayerTurnInfo {
private final int playerIndex;
@@ -14,6 +16,8 @@ public class PlayerTurnInfo {
private List<HandCard> hand;
+ private List<Card> neighbourGuildCards;
+
private String message;
public PlayerTurnInfo(int playerIndex, Table table) {
@@ -42,6 +46,14 @@ public class PlayerTurnInfo {
this.hand = hand;
}
+ public List<Card> getNeighbourGuildCards() {
+ return neighbourGuildCards;
+ }
+
+ public void setNeighbourGuildCards(List<Card> neighbourGuildCards) {
+ this.neighbourGuildCards = neighbourGuildCards;
+ }
+
public Action getAction() {
return action;
}
diff --git a/backend/src/main/java/org/luxons/sevenwonders/game/api/Table.java b/backend/src/main/java/org/luxons/sevenwonders/game/api/Table.java
index 8b831527..82f9055a 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/game/api/Table.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/game/api/Table.java
@@ -1,11 +1,16 @@
package org.luxons.sevenwonders.game.api;
+import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
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.Color;
import org.luxons.sevenwonders.game.cards.HandRotationDirection;
import org.luxons.sevenwonders.game.moves.Move;
+import org.luxons.sevenwonders.game.resources.Provider;
/**
* The table contains what is visible by all the players in the game: the boards and their played cards, and the
@@ -81,4 +86,21 @@ public class Table {
board2.getMilitary().defeat();
}
}
+
+ public List<Card> getNeighbourGuildCards(int playerIndex) {
+ return getNeighbourBoards(playerIndex).stream()
+ .map(Board::getPlayedCards)
+ .flatMap(List::stream)
+ .filter(c -> c.getColor() == Color.PURPLE)
+ .collect(Collectors.toList());
+ }
+
+ private List<Board> getNeighbourBoards(int playerIndex) {
+ Provider[] providers = Provider.values();
+ List<Board> boards = new ArrayList<>(providers.length);
+ for (Provider provider : providers) {
+ boards.add(getBoard(playerIndex, provider.getBoardPosition()));
+ }
+ return boards;
+ }
}
bgstack15