Package it.polimi.ingsw.Server.Model
Class CommonGoalCard
java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
it.polimi.ingsw.Server.Model.CommonGoalCard
- All Implemented Interfaces:
CommonGoalCardInterface
,Serializable
,Remote
This class represents the Common Goal cards, thanks to which players may grant points,
achieving a specific pattern
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate String
This attribute stands for a textual description of the pattern that the player has to achieve, in order to gain points.This attribute stands for the deck of ScoreCards on each Common Goal Card, put there from the lowest to the highest value.static final int
Limit of Common Goal Cards.private final int
This attribute stands for the id of the Common Goal Card, which permits to identify the different Common Goal Cards.Fields inherited from class java.rmi.server.RemoteObject
ref
-
Constructor Summary
ModifierConstructorDescriptionCommonGoalCard
(int type, int playerCount) CommonGoalCard's constructor.private
CommonGoalCard
(int type, String description, Stack<ScoreCard> increments) Related to Game's refresh strategy -
Method Summary
Modifier and TypeMethodDescriptionThis method calculates how many points the player has scored, by achieving the pattern which is displayed in the Common Goal Card.private boolean
findTypesInColumns
(int diffTypesMax, int diffTypesMin, int numOfPattern, Shelf shelf) This method is a support method to attribute() for cards 2 and 5.private boolean
findTypesInRows
(int diffTypesMax, int diffTypesMin, int numOfPattern, Shelf shelf) This method is a support method to attribute() for cards 6 and 7.getCopy()
Refreshed copy, after server reload from fileThis method returns the textual description of the pattern that the player has to achieve, in order to gain points.int
getType()
Common Goal Card's type (ordinal)private boolean
sameTypeGroupFirstCheck
(int dimOfGroup, int numPattern, Shelf shelf) This method is a support method to attribute() for cards 3 and 4.private boolean
sameTypeGroupSecondCheck
(int dimOfGroup, int numPattern, Shelf shelf) This method is a support method to attribute() for cards 3 and 4.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
-
LIMIT
public static final int LIMITLimit of Common Goal Cards.- See Also:
-
type
@Expose private final int typeThis attribute stands for the id of the Common Goal Card, which permits to identify the different Common Goal Cards. -
description
This attribute stands for a textual description of the pattern that the player has to achieve, in order to gain points. -
increments
This attribute stands for the deck of ScoreCards on each Common Goal Card, put there from the lowest to the highest value. The size of the Stack varies according to the number of players.
-
-
Constructor Details
-
CommonGoalCard
CommonGoalCard's constructor. New ScoreCards with a value of 2,4,6 or 8 points are pushed into the Stack increments according to the playerCount, from the lowest to the highest score value.- Parameters:
type
- it indicates the id of the Common Goal Card, in order to identify the patternplayerCount
- (2nd parameter) it represents the number of players, according to which a different number of ScoreCards are pushed into the Stack- Throws:
Exception
- if parameters are invalid
-
CommonGoalCard
private CommonGoalCard(int type, String description, Stack<ScoreCard> increments) throws RemoteException Related to Game's refresh strategy- Throws:
RemoteException
- related to RMI
-
-
Method Details
-
getDescription
This method returns the textual description of the pattern that the player has to achieve, in order to gain points.- Specified by:
getDescription
in interfaceCommonGoalCardInterface
- Returns:
- String: textual description of the pattern
-
getIncrements
- Specified by:
getIncrements
in interfaceCommonGoalCardInterface
- Returns:
- Score Increments stack
-
attribute
This method calculates how many points the player has scored, by achieving the pattern which is displayed in the Common Goal Card.- Parameters:
shelf
- player's shelf- Returns:
- score granted by the player, if the pattern displayed by the card has been achieved
- Throws:
Exception
- if coordinates are invalid
-
findTypesInColumns
private boolean findTypesInColumns(int diffTypesMax, int diffTypesMin, int numOfPattern, Shelf shelf) throws Exception This method is a support method to attribute() for cards 2 and 5.- Parameters:
diffTypesMax
- max number of different types in a columndiffTypesMin
- min number of different types in a columnnumOfPattern
- num of patternshelf
- player's shelf- Returns:
- true if the pattern has been found, false otherwise
- Throws:
Exception
- invalid coordinates
-
findTypesInRows
private boolean findTypesInRows(int diffTypesMax, int diffTypesMin, int numOfPattern, Shelf shelf) throws Exception This method is a support method to attribute() for cards 6 and 7.- Parameters:
diffTypesMax
- max number of different types in a linediffTypesMin
- min number of different types in a columnnumOfPattern
- num of patternshelf
- player's shelf- Returns:
- true if the pattern has been found, false otherwise
- Throws:
Exception
- invalid coordinates
-
sameTypeGroupFirstCheck
private boolean sameTypeGroupFirstCheck(int dimOfGroup, int numPattern, Shelf shelf) throws Exception This method is a support method to attribute() for cards 3 and 4. It checks the presence of groups in lines and then in columns.- Parameters:
dimOfGroup
- dimension of each groupnumPattern
- number of patternshelf
- player's shelf- Returns:
- true if the pattern has been found, false otherwise
- Throws:
Exception
- invalid coordinates
-
sameTypeGroupSecondCheck
private boolean sameTypeGroupSecondCheck(int dimOfGroup, int numPattern, Shelf shelf) throws Exception This method is a support method to attribute() for cards 3 and 4. It checks the presence of groups in columns and then in lines.- Parameters:
dimOfGroup
- dimension of each groupnumPattern
- number of patternsshelf
- player's shelf- Returns:
- true if the pattern has been found, false otherwise
- Throws:
Exception
- invalid coordinates
-
getCopy
Refreshed copy, after server reload from file- Returns:
- new copy of the object
- Throws:
RemoteException
- related to RMI
-
getType
Common Goal Card's type (ordinal)- Specified by:
getType
in interfaceCommonGoalCardInterface
- Returns:
- type
- Throws:
RemoteException
- related to RMI
-