Class Board

java.lang.Object
it.polimi.ingsw.model.Board
All Implemented Interfaces:
Serializable

public class Board extends Object implements Serializable
class which represent the common board where the players choose the cards. Mutable
See Also:
  • Field Details

    • commonObjective_1

      public CommonObjective commonObjective_1
      the first common objective
    • commonObjective_2

      public CommonObjective commonObjective_2
      the second common objective
    • pointsCO_1

      public LinkedList<Integer> pointsCO_1
      the points available for the first common objective
    • pointsCO_2

      public LinkedList<Integer> pointsCO_2
      the points available for the second common objective
    • name

      public String name
      the name of the player owning this board
  • Constructor Details

    • Board

      public Board(int numPlayers, CommonObjective CO_1, CommonObjective CO_2)
      normal constructor for this type of object
      Parameters:
      numPlayers - the number of players in this game
      CO_1 - the first common objective chosen
      CO_2 - the second common objective chosen
    • Board

      public Board(Board b)
      copy constructor for this class, used for deep copying objects
      Parameters:
      b - the object to copy (game board)
  • Method Details

    • getGameBoard

      public Card[][] getGameBoard()
      getter for the game board
    • getCO_1

      public CommonObjective getCO_1()
      getter for the CO 1
    • getCO_2

      public CommonObjective getCO_2()
      getter for the CO 2
    • isBoardUnplayable

      public boolean isBoardUnplayable()
      check if the current board is unplayable
      Returns:
      true iff it is unplayable
    • hasOneFreeSide

      public boolean hasOneFreeSide(int x, int y)
      check if the card has at least one free side
      Parameters:
      x - pos x
      y - pos y
      Returns:
      true iff it has at least one free side
    • areCardsPickable

      public boolean areCardsPickable(ArrayList<Integer> cardPositions)
      check if the cards picked are in a valid position
      Parameters:
      cardPositions - list of paired coordinates
      Returns:
      true iff they are in a valid position
    • areCardsAligned

      public boolean areCardsAligned(ArrayList<Integer> cardPosition)
      check if the cards are on a straight line
      Parameters:
      cardPosition - list of paired coordinates
      Returns:
      true iff they are on a straight line
    • initBoard

      public void initBoard(int numPlayers)
      initialize a new board
      Parameters:
      numPlayers - number of players
    • fillBoard

      public void fillBoard(int numPlayers)
      fill the board (start of the game or when it is unplayable)
      Parameters:
      numPlayers - number of players
    • shuffleCardsBucket

      public void shuffleCardsBucket()
      randomize the card array so that we get a random board
    • setGameBoard

      public void setGameBoard(Card[][] g)
      setter for the gameBoard (only used by testing)
      Parameters:
      g - the matrix to copy in the board
    • draw

      public void draw()
      method that print the game board