Package it.polimi.ingsw.Server.Model
Class Shelf
java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
it.polimi.ingsw.Server.Model.Shelf
- All Implemented Interfaces:
ShelfInterface
,Serializable
,Remote
Player's Shelf
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate Optional<ObjectCard>[][]
Shelf implementation of Object Cardsstatic final int
Maximum X dimension of the shelfstatic final int
Maximum Y dimension of the shelfFields inherited from class java.rmi.server.RemoteObject
ref
-
Constructor Summary
ModifierConstructorDescriptionShelf()
Manages creation of the shelf (filling with empty values)private
Shelf
(Optional<ObjectCard>[][] cards) Related to Game's refresh strategy -
Method Summary
Modifier and TypeMethodDescriptionint
emptySpacesInColumn
(int column) Calculates the number of empty spaces in the selected columnint
evaluatePattern
(PersonalGoalCard pgCard) Evaluates score for a PersonalGoalCardint
Implements final evaluation of groups of Object Cards used at the end of the gamegetCard
(int x, int y) gets Object Card in position (x, y) if valid (else empty)getCardImage
(int x, int y) Returns Object Card's image path in position (x, y) if valid (else null)int
getCardOrdinal
(int x, int y) Returns Object Card's type ordinal in position (x, y) if valid (else -1)int
getCoordinate
(ObjectCard oc, boolean X) Looks for coordinates of a given card (x, y)getCopy()
Refreshed copy, after server reload from filegetPlainCard
(int x, int y) gets Object Card in position (x, y) if valid (else null)boolean
isFull()
void
placeCard
(ObjectCard oc, int y) Inserts a card into the shelf at the selected column (y)Returns a list of effectively present cards on the board, based on a functional approach using Optionals.Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, exportObject, exportObject, unexportObject
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
-
Field Details
-
SHELF_DIM_X
public static final int SHELF_DIM_XMaximum X dimension of the shelf- See Also:
-
SHELF_DIM_Y
public static final int SHELF_DIM_YMaximum Y dimension of the shelf- See Also:
-
cards
Shelf implementation of Object Cards
-
-
Constructor Details
-
Shelf
Manages creation of the shelf (filling with empty values)- Throws:
RemoteException
- related to RMI
-
Shelf
Related to Game's refresh strategy- Throws:
RemoteException
-
-
Method Details
-
shelfCards
Returns a list of effectively present cards on the board, based on a functional approach using Optionals.- Returns:
- list of cards in the shelf
-
getCard
gets Object Card in position (x, y) if valid (else empty)- Parameters:
x
- coordinatey
- coordinate- Returns:
- requested ObjectCard
- Throws:
Exception
- if coordinates are invalid
-
getPlainCard
gets Object Card in position (x, y) if valid (else null)- Parameters:
x
- coordinatey
- coordinate- Returns:
- requested ObjectCard
- Throws:
Exception
- if coordinates are invalid
-
getCardOrdinal
Returns Object Card's type ordinal in position (x, y) if valid (else -1)- Specified by:
getCardOrdinal
in interfaceShelfInterface
- Parameters:
x
- coordinatey
- coordinate- Returns:
- requested Object Card's type ordinal
- Throws:
Exception
- if coordinates are invalid
-
getCardImage
Returns Object Card's image path in position (x, y) if valid (else null)- Specified by:
getCardImage
in interfaceShelfInterface
- Parameters:
x
- coordinatey
- coordinate- Returns:
- the card's image path
- Throws:
Exception
- if parameters are trying to go out of the board
-
getCoordinate
Looks for coordinates of a given card (x, y)- Parameters:
oc
- the Object Card to be foundX
- kind of coordinate: X = true means x coordinate, false y- Returns:
- coordinate of the given card
- Throws:
Exception
- related to invalid coordinates in getCard method
-
placeCard
Inserts a card into the shelf at the selected column (y)- Parameters:
oc
- ObjectCard to inserty
- number of column to use- Throws:
Exception
- newly defined exception to manage error related to Shelf Insertion
-
evaluatePattern
Evaluates score for a PersonalGoalCard- Parameters:
pgCard
- Personal Goal Card- Returns:
- corresponding score
-
finalEvaluation
Implements final evaluation of groups of Object Cards used at the end of the game- Returns:
- score obtained for current shelf
- Throws:
Exception
- related to invalid coordinates in getCard method
-
isFull
public boolean isFull()- Specified by:
isFull
in interfaceShelfInterface
- Returns:
- true if the Shelf is full
-
emptySpacesInColumn
Calculates the number of empty spaces in the selected column- Parameters:
column
- in the Shelf- Returns:
- number of empty spaces in the column
- Throws:
Exception
- if given column is invalid
-
getCopy
Refreshed copy, after server reload from file- Returns:
- new copy of the object
- Throws:
RemoteException
- related to RMI
-