Package it.polimi.ingsw.model
Class DevelopCardDeck
java.lang.Object
it.polimi.ingsw.model.DevelopCardDeck
- All Implemented Interfaces:
EndGameObservable,DeckSetupObservable,DevDeckUpdateObservable,LorenzoDevDeckObservable
public class DevelopCardDeck extends java.lang.Object implements EndGameObservable, DeckSetupObservable, LorenzoDevDeckObservable, DevDeckUpdateObservable
Represent the develop cards' deck where players can buy
-
Constructor Summary
Constructors Constructor Description DevelopCardDeck()Default constructor because construction is handled by the cardParser method -
Method Summary
Modifier and Type Method Description voidaddToEndGameObserverList(EndGameObserver observerToAdd)add an observer to a list of observersjava.util.List<DevelopCard>buyableCards(InterfacePlayerBoard playerBoard)Returns a list of the cards that the specified player can buy in a specific momentvoidfinalizeDeckSetup(ModelObserver controller)Shuffles the deck, assigns the ModelObserver and notifies the client about the deck setupDevelopCardgetCard(int row, int column)returns the reference to a card contained in the Deck given the position row/column NOTE: this method doesn't remove the cardDevelopCardgetCardFromId(int id)get the developCard corresponding to the specified IdvoidnotifyDeckSetup(DevelopCardDeckSetup msg)notify the model observers that deck has been set up Along with the notification sends the proper update Object as further explained in project documentationvoidnotifyDeckUpdate(DevelopCardDeckUpdate msg)Notify the model observers that a card has been drawn from the deck Along with the notification sends the proper update Object as further explained in project documentationvoidnotifyForEndGame(boolean onySinglePlayer)notify the endgame observers that the game is in the endgame statevoidnotifyLorenzoDeckUpdate(DevelopCardDeckUpdate msg)Notify the model observers that lorenzo drew cards from the deck Along with the notification sends the proper update Object as further explained in project documentationvoidremoveCard(DevelopCard card)removes the specified card from the deck.voidremoveFromEndGameObserverList(EndGameObserver observerToRemove)remove an observer from a list of observersvoidRemoveTwoCards(DevelopCardColor color)method needed for the single player mode Removes two cards of the lowes possible level and of the specified color from the topvoidsetupClass()this method is called by the cardParser method in GSON class to complete the setup process of this class it creates the card matrix from the card listvoidshuffleDeck()Shuffles the Deckjava.util.ArrayList<DevelopCard>visibleCards()returns the visible cards (the ones on top of the card square)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
DevelopCardDeck
public DevelopCardDeck()Default constructor because construction is handled by the cardParser method
-
-
Method Details
-
setupClass
public void setupClass()this method is called by the cardParser method in GSON class to complete the setup process of this class it creates the card matrix from the card list -
finalizeDeckSetup
Shuffles the deck, assigns the ModelObserver and notifies the client about the deck setup- Parameters:
controller- the modelObserver to be assigned to this class
-
shuffleDeck
public void shuffleDeck()Shuffles the Deck -
visibleCards
returns the visible cards (the ones on top of the card square)- Returns:
- matrix of DevelopCard
-
buyableCards
Returns a list of the cards that the specified player can buy in a specific moment- Parameters:
playerBoard- the player- Returns:
- the list of buyable cards
-
RemoveTwoCards
method needed for the single player mode Removes two cards of the lowes possible level and of the specified color from the top- Parameters:
color- indicates the color of the cards to remove
-
getCard
returns the reference to a card contained in the Deck given the position row/column NOTE: this method doesn't remove the card- Parameters:
row- the row of the card to return (start at 0). Row is related to the card levelcolumn- the column of the card to return (start at 0). Column is related to card the color- Returns:
- the card present at the given position
- Throws:
InvalidDevelopCardException- if the card position is invalid
-
removeCard
removes the specified card from the deck. Does nothing if the card is null- Parameters:
card- the reference of the card to remove- Throws:
InvalidCardException- if the given card is not a visible card
-
getCardFromId
get the developCard corresponding to the specified Id- Parameters:
id- Id of the card to get- Returns:
- the the developCard corresponding to the specified Id
- Throws:
InvalidCardException- if there isn't a card with the specified id in the deck
-
addToEndGameObserverList
Description copied from interface:EndGameObservableadd an observer to a list of observers- Specified by:
addToEndGameObserverListin interfaceEndGameObservable- Parameters:
observerToAdd- the observer to add
-
removeFromEndGameObserverList
Description copied from interface:EndGameObservableremove an observer from a list of observers- Specified by:
removeFromEndGameObserverListin interfaceEndGameObservable- Parameters:
observerToRemove- the observer to remove
-
notifyForEndGame
public void notifyForEndGame(boolean onySinglePlayer)Description copied from interface:EndGameObservablenotify the endgame observers that the game is in the endgame state- Specified by:
notifyForEndGamein interfaceEndGameObservable- Parameters:
onySinglePlayer- true the game must end only if it is in single player
-
notifyDeckUpdate
Description copied from interface:DevDeckUpdateObservableNotify the model observers that a card has been drawn from the deck Along with the notification sends the proper update Object as further explained in project documentation- Specified by:
notifyDeckUpdatein interfaceDevDeckUpdateObservable- Parameters:
msg- the update object representing a develop card deck update
-
notifyDeckSetup
Description copied from interface:DeckSetupObservablenotify the model observers that deck has been set up Along with the notification sends the proper update Object as further explained in project documentation- Specified by:
notifyDeckSetupin interfaceDeckSetupObservable- Parameters:
msg- the update object representing a develop card deck setup containing the whole develop card deck
-
notifyLorenzoDeckUpdate
Description copied from interface:LorenzoDevDeckObservableNotify the model observers that lorenzo drew cards from the deck Along with the notification sends the proper update Object as further explained in project documentation- Specified by:
notifyLorenzoDeckUpdatein interfaceLorenzoDevDeckObservable- Parameters:
msg- the update object representing a develop card deck update
-