Package it.polimi.ingsw.model
Class Board
java.lang.Object
it.polimi.ingsw.model.Board
- All Implemented Interfaces:
Serializable
class which represent the common board where the players choose the cards. Mutable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionthe first common objectivethe second common objectivethe name of the player owning this boardthe points available for the first common objectivethe points available for the second common objective -
Constructor Summary
ConstructorsConstructorDescriptionBoard
(int numPlayers, CommonObjective CO_1, CommonObjective CO_2) normal constructor for this type of objectcopy constructor for this class, used for deep copying objects -
Method Summary
Modifier and TypeMethodDescriptionboolean
areCardsAligned
(ArrayList<Integer> cardPosition) check if the cards are on a straight lineboolean
areCardsPickable
(ArrayList<Integer> cardPositions) check if the cards picked are in a valid positionvoid
draw()
method that print the game boardvoid
fillBoard
(int numPlayers) fill the board (start of the game or when it is unplayable)getCO_1()
getter for the CO 1getCO_2()
getter for the CO 2Card[][]
getter for the game boardboolean
hasOneFreeSide
(int x, int y) check if the card has at least one free sidevoid
initBoard
(int numPlayers) initialize a new boardboolean
check if the current board is unplayablevoid
setGameBoard
(Card[][] g) setter for the gameBoard (only used by testing)void
randomize the card array so that we get a random board
-
Field Details
-
commonObjective_1
the first common objective -
commonObjective_2
the second common objective -
pointsCO_1
the points available for the first common objective -
pointsCO_2
the points available for the second common objective -
name
the name of the player owning this board
-
-
Constructor Details
-
Board
normal constructor for this type of object- Parameters:
numPlayers
- the number of players in this gameCO_1
- the first common objective chosenCO_2
- the second common objective chosen
-
Board
copy constructor for this class, used for deep copying objects- Parameters:
b
- the object to copy (game board)
-
-
Method Details
-
getGameBoard
getter for the game board -
getCO_1
getter for the CO 1 -
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 xy
- pos y- Returns:
- true iff it has at least one free side
-
areCardsPickable
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
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
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
-