Class Board

java.lang.Object
it.polimi.ingsw.gc14.Model.GamePackage.Board
All Implemented Interfaces:
Serializable

public class Board extends Object implements Serializable
Board manages all the elements during the game such as decks, upper and lower rows, totems, tiles...
See Also:
  • Field Details

    • slotList

      private final List<Slot> slotList
      slotList contains the ordered list of slots (tiles). The slots changes based on the number of players. Each slot (tile) has special action as drawing from the upper/lower row or taking food.
    • tribeDeck

      private final Queue<TribeCard> tribeDeck
      tribeDeck is the deck from where you draw tribe cards as characters and events.
    • upperListTribe

      private final List<TribeCard> upperListTribe
      The upper row of tribe cards. It contains a total of nTotem + 4 tribe cards, which may include both character and event cards.
    • lowerListTribe

      private final List<TribeCard> lowerListTribe
      The lower row of the tribe card. During the first round, there will be (num. of players + 1) character cards. During the following rounds, lower row will be emptied and populated with upper row's cards. When an Event card gets in the lower row, the event effect will be activated at the end of the round.
    • upperListBuilding

      private final List<BuildingCard> upperListBuilding
      Contains all the building cards of the upper list. When a new era starts, all its building cards are placed here.
    • lowerListBuilding

      private final List<BuildingCard> lowerListBuilding
      Contains all the building cards of the lower list. When a new era starts, the old era's buildings are moved from the upper to the lower list.
    • buildingCardsAllEras

      private final ArrayList<List<BuildingCard>> buildingCardsAllEras
      All building card lists grouped by era; index 0 = era 1, index 1 = era 2, etc.
    • nTotem

      private final int nTotem
      Number of players
    • era

      private int era
      Current era of the game
  • Constructor Details

    • Board

      public Board(int nTotem)
      Creates and initializes a new board: - Generate the slotList using a method of DecksCreator. - Generate the tribeDeck. - Populate the lower list (if there is an event card, it's added to the upper list). - Populate the upper list. - Generate the buildingDeck using a method of DecksCreator.
      Parameters:
      nTotem - the number of players.
  • Method Details

    • getUpperListTribe

      public List<TribeCard> getUpperListTribe()
      Returns the upper row of tribe cards.
      Returns:
      the live upper tribe card list.
    • getLowerListTribe

      public List<TribeCard> getLowerListTribe()
      Returns the lower row of tribe cards.
      Returns:
      the live lower tribe card list.
    • getUpperListBuilding

      public List<BuildingCard> getUpperListBuilding()
      Returns the upper row of building cards.
      Returns:
      the live upper building card list.
    • getLowerListBuilding

      public List<BuildingCard> getLowerListBuilding()
      Returns the lower row of building cards.
      Returns:
      the live lower building card list.
    • getSlotList

      public List<Slot> getSlotList()
      Creates and returns a new list containing the slots (tiles) of the game.
      Returns:
      a copy of the slot list.
    • getTribeDeckSize

      public int getTribeDeckSize()
      Returns:
      the size of the TribeDeck
    • getEra

      public int getEra()
      Returns:
      the game era
    • generateTribeDeck

      private Queue<TribeCard> generateTribeDeck(int nPlayers)
      Creates the tribeDeck. Loads the cards from each era, shuffle them, and then combine them in the final deck. In the end, two special events (Sustenance and ShamanicRitual) are added.
      Parameters:
      nPlayers - the number of players.
      Returns:
      a queue containing the cards in this order: - Era 1. - Era 2. - Era 3. - Special events.
    • getPendingEvents

      public Queue<EventCard> getPendingEvents()
      Returns:
      the queue of events cards from the lower list that need to be activated
    • removeUpperTribeCard

      public boolean removeUpperTribeCard(TribeCard tribeCard)
      Take the selected card from the upper tribe list of the board.
      Parameters:
      tribeCard - is the card to remove.
      Returns:
      true if the card is successfully removed.
    • removeLowerTribeCard

      public boolean removeLowerTribeCard(TribeCard tribeCard)
      Take the selected card from the lower tribe list of the board.
      Parameters:
      tribeCard - is the card to remove.
      Returns:
      true if succeed in removing the card.
    • removeUpperBuildingCard

      public boolean removeUpperBuildingCard(BuildingCard buildingCard)
      Take the selected card from the upper building list of the board.
      Parameters:
      buildingCard - is the card to remove.
      Returns:
      true if succeed in removing the card.
    • removeLowerBuildingCard

      public boolean removeLowerBuildingCard(BuildingCard buildingCard)
      Take the selected card from the lower building list of the board.
      Parameters:
      buildingCard - is the card to remove.
      Returns:
      true if succeed in removing the card.
    • nextRound

      public int nextRound()
      Goes to the next round. - Clear the lower tribe row. - Moves the upper tribe row to the lower one. - Populate the upper tribe row.
      Returns:
      the current era after moving to the next round.
    • nextEra

      private void nextEra()
      Changes the era of the game: - Increase the era attribute. - Clear the lower building list and replace it with the upper building list. - Repopulate the upper building list.