Package it.polimi.ingsw.model
Class CardSlots
java.lang.Object
it.polimi.ingsw.model.CardSlots
- All Implemented Interfaces:
EndGameObservable,CardSlotObservable
public class CardSlots extends java.lang.Object implements EndGameObservable, CardSlotObservable
Represents the set of card slots of a player where they can place their develop cards
-
Constructor Summary
Constructors Constructor Description CardSlots() -
Method Summary
Modifier and Type Method Description java.util.ArrayList<DevelopCard>activatableCards(InterfacePlayerBoard playerBoard)Returns the cards in CardSlots that can be used to producevoidaddDevelopCard(int slot, DevelopCard developCard)Add a DevelopCard in one of the slotsvoidaddToEndGameObserverList(EndGameObserver observerToAdd)add an observer to a list of observersintcalculateDevelopCardScore()Calculate the amount of victory points in CardSlotsintgetNumberOfCardSlots()Getter for the number of slotsvoidnotifyCardSlotUpdate(CardSlotUpdate msg)Notify the model observers that a card has been added to a slot 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 stateintnumberOf(CardFlag cardFlag)Returns the number of cards in the slots with the card flag passed as parametervoidremoveFromEndGameObserverList(EndGameObserver observerToRemove)remove an observer from a list of observersDevelopCardreturnTopCard(int slot)Returns the card which is positioned on top of a slot NOTE: if the slot is empty returns a DevelopCard with level 0voidsetController(ModelObserver controller)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
CardSlots
public CardSlots()
-
-
Method Details
-
calculateDevelopCardScore
public int calculateDevelopCardScore()Calculate the amount of victory points in CardSlots- Returns:
- the score of CardSlots (an int >= 0)
-
returnTopCard
Returns the card which is positioned on top of a slot NOTE: if the slot is empty returns a DevelopCard with level 0- Parameters:
slot- , slot of which the caller wants to know the top card (int between 0 andnumberOfCardSlots)- Returns:
- the top card of a slot (the highest in level)
- Throws:
InvalidCardSlotException- if the card slot doesn't exists
-
addDevelopCard
public void addDevelopCard(int slot, DevelopCard developCard) throws InvalidCardSlotException, java.lang.NullPointerExceptionAdd a DevelopCard in one of the slots- Parameters:
slot- , slot in which the caller wants to put the card (int between 0 and numberOfCardSlots)developCard- , card to add- Throws:
InvalidCardSlotExceptionjava.lang.NullPointerException
-
activatableCards
Returns the cards in CardSlots that can be used to produce- Parameters:
playerBoard- of the player who wants to know which card can active- Returns:
- a list of activatable cards
-
getNumberOfCardSlots
public int getNumberOfCardSlots()Getter for the number of slots- Returns:
- the number of slots
-
numberOf
Returns the number of cards in the slots with the card flag passed as parameter- Parameters:
cardFlag- , the card flag of which the number of instances are to be returned- Returns:
- the number of cards in the slots with the specified card flag
-
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
-
notifyCardSlotUpdate
Description copied from interface:CardSlotObservableNotify the model observers that a card has been added to a slot Along with the notification sends the proper update Object as further explained in project documentation- Specified by:
notifyCardSlotUpdatein interfaceCardSlotObservable- Parameters:
msg- the update object representing a card slot update
-
setController
-