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
    void addToEndGameObserverList​(EndGameObserver observerToAdd)
    add an observer to a list of observers
    java.util.List<DevelopCard> buyableCards​(InterfacePlayerBoard playerBoard)
    Returns a list of the cards that the specified player can buy in a specific moment
    void finalizeDeckSetup​(ModelObserver controller)
    Shuffles the deck, assigns the ModelObserver and notifies the client about the deck setup
    DevelopCard getCard​(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 card
    DevelopCard getCardFromId​(int id)
    get the developCard corresponding to the specified Id
    void notifyDeckSetup​(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 documentation
    void notifyDeckUpdate​(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 documentation
    void notifyForEndGame​(boolean onySinglePlayer)
    notify the endgame observers that the game is in the endgame state
    void notifyLorenzoDeckUpdate​(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 documentation
    void removeCard​(DevelopCard card)
    removes the specified card from the deck.
    void removeFromEndGameObserverList​(EndGameObserver observerToRemove)
    remove an observer from a list of observers
    void RemoveTwoCards​(DevelopCardColor color)
    method needed for the single player mode Removes two cards of the lowes possible level and of the specified color from the top
    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
    void shuffleDeck()
    Shuffles the Deck
    java.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

      public void finalizeDeckSetup​(ModelObserver controller)
      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

      public java.util.ArrayList<DevelopCard> visibleCards()
      returns the visible cards (the ones on top of the card square)
      Returns:
      matrix of DevelopCard
    • buyableCards

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

      public void RemoveTwoCards​(DevelopCardColor color)
      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

      public DevelopCard getCard​(int row, int column) throws InvalidDevelopCardException
      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 level
      column - 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

      public void removeCard​(DevelopCard card) throws InvalidCardException
      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

      public DevelopCard getCardFromId​(int id) throws InvalidCardException
      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

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

      public void notifyDeckUpdate​(DevelopCardDeckUpdate msg)
      Description copied from interface: DevDeckUpdateObservable
      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 documentation
      Specified by:
      notifyDeckUpdate in interface DevDeckUpdateObservable
      Parameters:
      msg - the update object representing a develop card deck update
    • notifyDeckSetup

      public void notifyDeckSetup​(DevelopCardDeckSetup msg)
      Description copied from interface: DeckSetupObservable
      notify 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:
      notifyDeckSetup in interface DeckSetupObservable
      Parameters:
      msg - the update object representing a develop card deck setup containing the whole develop card deck
    • notifyLorenzoDeckUpdate

      public void notifyLorenzoDeckUpdate​(DevelopCardDeckUpdate msg)
      Description copied from interface: LorenzoDevDeckObservable
      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 documentation
      Specified by:
      notifyLorenzoDeckUpdate in interface LorenzoDevDeckObservable
      Parameters:
      msg - the update object representing a develop card deck update