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 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

      public DevelopCard returnTopCard​(int slot) throws InvalidCardSlotException
      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 and numberOfCardSlots)
      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.NullPointerException
      Add 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:
      InvalidCardSlotException
      java.lang.NullPointerException
    • activatableCards

      public java.util.ArrayList<DevelopCard> activatableCards​(InterfacePlayerBoard playerBoard)
      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

      public int numberOf​(CardFlag cardFlag)
      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

      public void addToEndGameObserverList​(EndGameObserver observerToAdd)
      Description copied from interface: EndGameObservable
      add an observer to a list of observers
      Specified by:
      addToEndGameObserverList in interface EndGameObservable
      Parameters:
      observerToAdd - the observer to add
    • removeFromEndGameObserverList

      public void removeFromEndGameObserverList​(EndGameObserver observerToRemove)
      Description copied from interface: EndGameObservable
      remove an observer from a list of observers
      Specified by:
      removeFromEndGameObserverList in interface EndGameObservable
      Parameters:
      observerToRemove - the observer to remove
    • notifyForEndGame

      public void notifyForEndGame​(boolean onySinglePlayer)
      Description copied from interface: EndGameObservable
      notify the endgame observers that the game is in the endgame state
      Specified by:
      notifyForEndGame in interface EndGameObservable
      Parameters:
      onySinglePlayer - true the game must end only if it is in single player
    • notifyCardSlotUpdate

      public void notifyCardSlotUpdate​(CardSlotUpdate msg)
      Description copied from interface: CardSlotObservable
      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 documentation
      Specified by:
      notifyCardSlotUpdate in interface CardSlotObservable
      Parameters:
      msg - the update object representing a card slot update
    • setController

      public void setController​(ModelObserver controller)