java.lang.Object
polimi.ingsw.am21.codex.model.GameBoard.GameBoard
-
Constructor Summary
ConstructorsConstructorDescriptionGameBoard
(List<PlayableCard> starterCardsList, List<PlayableCard> resourceCardsList, List<PlayableCard> goldCardsList, List<ObjectiveCard> objectiveCardsList) Constructor Initializes the decks and draws the first cardsGameBoard
(CardsLoader loader) GameBoard
(Deck<PlayableCard> starterDeck, Deck<PlayableCard> resourceDeck, Deck<PlayableCard> goldDeck, Deck<ObjectiveCard> objectiveDeck, CardPair<PlayableCard> resourceCards, CardPair<PlayableCard> goldCards, CardPair<ObjectiveCard> objectiveCards) Constructor with the decks -
Method Summary
Modifier and TypeMethodDescriptiondrawCard
(DrawingCardSource drawingSource, DrawingDeckType deckType) drawCard
(DrawingCardSource drawingSource, DrawingDeckType deckType, Consumer<PlayableCard> replacedCardCallback) Draws a card from a player's deck pair.Draws a gold card from the deckDraws an objective card from the deckDraws a resource card from the deckdrawResourceCardFromDeck
(int n) Draws a resource card from the deckdrawResourceCardFromPair
(Boolean first) Draws the first or the second resource card from the game board and replaces it with a new one from the deckDraws a starter card from the deckstatic GameBoard
fromJSON
(org.json.JSONArray cards) static method to create a GameBoard from a JSON array Initializes the decks using a JSONArrayint
void
Inserts an objective card in the bottom of the deckvoid
Inserts a starter card in the bottom of the deckint
Returns the first card of the gold deck, without drawing itReturns the first card of the resource deck, without drawing itint
int
-
Constructor Details
-
GameBoard
-
GameBoard
public GameBoard(Deck<PlayableCard> starterDeck, Deck<PlayableCard> resourceDeck, Deck<PlayableCard> goldDeck, Deck<ObjectiveCard> objectiveDeck, CardPair<PlayableCard> resourceCards, CardPair<PlayableCard> goldCards, CardPair<ObjectiveCard> objectiveCards) Constructor with the decks- Parameters:
starterDeck
- The deck containing the starter cardsresourceDeck
- The deck containing the resource cardsgoldDeck
- The deck containing the gold cardsobjectiveDeck
- The deck containing the objective cardsresourceCards
- The pair of resource cardsobjectiveCards
- The pair of common objective cards
-
GameBoard
public GameBoard(List<PlayableCard> starterCardsList, List<PlayableCard> resourceCardsList, List<PlayableCard> goldCardsList, List<ObjectiveCard> objectiveCardsList) Constructor Initializes the decks and draws the first cards
-
-
Method Details
-
fromJSON
static method to create a GameBoard from a JSON array Initializes the decks using a JSONArray- Parameters:
cards
- the full list
-
peekGoldCardFromDeck
Returns the first card of the gold deck, without drawing it -
drawGoldCardFromDeck
Draws a gold card from the deck- Returns:
- a gold card drawn from the gold cards deck
- Throws:
EmptyDeckException
- there are no objective cards left in the deck
-
drawCard
public PlayableCard drawCard(DrawingCardSource drawingSource, DrawingDeckType deckType, Consumer<PlayableCard> replacedCardCallback) throws EmptyDeckException Draws a card from a player's deck pair.- Parameters:
drawingSource
- Where we are drawing the card romdeckType
- The type of deck to draw from.replacedCardCallback
- A callback that accepts the card that was put in the card pair to replace the drawn card.- Returns:
- The drawn card.
- Throws:
EmptyDeckException
- If the deck being drawn from is empty.
-
drawCard
public PlayableCard drawCard(DrawingCardSource drawingSource, DrawingDeckType deckType) throws EmptyDeckException - Throws:
EmptyDeckException
-
getResourceCards
- Returns:
- the 2 resource cards in the card pair
-
getGoldCards
- Returns:
- the 2 gold cards in the card pair
-
goldCardsLeft
public int goldCardsLeft()- Returns:
- the number of gold cards left in the deck
-
drawStarterCardFromDeck
Draws a starter card from the deck- Returns:
- the starterDeck
- Throws:
EmptyDeckException
- there are no objective cards left in the deck
-
starterCardsLeft
public int starterCardsLeft()- Returns:
- the number of starter cards left in the deck
-
drawObjectiveCardFromDeck
Draws an objective card from the deck- Returns:
- the objectiveDeck
- Throws:
EmptyDeckException
- there are no objective cards left in the deck
-
getObjectiveCards
- Returns:
- the 2 objective cards
-
insertObjectiveCard
Inserts an objective card in the bottom of the deck- Parameters:
card
- the card to insert
-
insertStarterCard
Inserts a starter card in the bottom of the deck- Parameters:
card
- the card to insert
-
objectiveCardsLeft
public int objectiveCardsLeft()- Returns:
- the number of objective cards left in the deck
-
peekResourceCardFromDeck
Returns the first card of the resource deck, without drawing it -
drawResourceCardFromDeck
Draws a resource card from the deck- Returns:
- a resource card drawn from the resource cards deck
- Throws:
EmptyDeckException
- there are no resource cards left in the deck
-
drawResourceCardFromDeck
Draws a resource card from the deck- Parameters:
n
- number of cards to extract- Returns:
- a resource card drawn from the resource cards deck
- Throws:
EmptyDeckException
- there are no resource cards left in the deck
-
drawResourceCardFromPair
Draws the first or the second resource card from the game board and replaces it with a new one from the deck- Parameters:
first
- if true, the first card is drawn, otherwise the second- Returns:
- the resource card drawn
- Throws:
EmptyDeckException
-
resourceCardsLeft
public int resourceCardsLeft()- Returns:
- the number of resource cards left in the deck
-
drawObjectiveCardPair
- Returns:
- a card pair with objective cards from the deck
- Throws:
EmptyDeckException
- if the objective cards deck is empty
-