Package it.polimi.ingsw.model
Class Library
java.lang.Object
it.polimi.ingsw.model.Library
- All Implemented Interfaces:
Serializable
class representing each player's private library. Mutable
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckCol(int col, int numCards) check if the chosen column have enough space for the cardsintcount the points gained thanks to adjacent cardsvoiddraw()method that draws the library of the ownervoidmethod that draws the library of a player, not the ownervoidinsertCards(int col, ArrayList<Card> cards) insert the cards in the library of the current playerbooleanisFull()check if the library is fullintfind the maximum number of cards insertable in the current librarybooleansameLibraryColor(Library lib) check that the 2 library have the cards with the same color
-
Field Details
-
ROWS
public final int ROWSthe rows of the game library- See Also:
-
COLS
public final int COLSthe columns of the game library- See Also:
-
gameLibrary
the matrix which contains the cards placed by the user -
name
the name of the player using this library
-
-
Constructor Details
-
Library
normal constructor for this type of objects- Parameters:
n- the name of the player using this library
-
Library
copy constructor for the Library Objects, useful for deep copy- Parameters:
l- the library which you need to copy
-
-
Method Details
-
isFull
public boolean isFull()check if the library is full- Returns:
- true or false, depending on if library is full or not
-
checkCol
public boolean checkCol(int col, int numCards) check if the chosen column have enough space for the cards- Parameters:
col- index of columnnumCards- number of cards- Returns:
- true iff the cards can stay inside the library column
-
maxCardsInsertable
public int maxCardsInsertable()find the maximum number of cards insertable in the current library- Returns:
- the maximum number of cards insertable in the current library (int)
-
insertCards
insert the cards in the library of the current player- Parameters:
col- index of the column in which insert the cardscards- the cards that needs to be physically inserted in the library
-
countGroupedPoints
public int countGroupedPoints()count the points gained thanks to adjacent cards- Returns:
- the number of points made by this player
-
draw
public void draw()method that draws the library of the owner -
draw
method that draws the library of a player, not the owner -
sameLibraryColor
check that the 2 library have the cards with the same color- Parameters:
lib- library that need to be checked- Returns:
- true iff the library are equals
-