java.lang.Object
it.polimi.ingsw.am13.model.card.points.PointsPattern
- All Implemented Interfaces:
PointsObjective
,Serializable
Representation of an objective card of type "x points for each pattern with 3 card in a certain position and with certain colors"
(fourth type of objective card presented in rulebook).
Note that, according to rules, the patterns cannot intersect, and the points are calculating with the maximum number of disjunctive patterns found.
The pattern is represented starting from the upper card by using two vectors that can be (-1,-1), (0,-1), (1,-1).
The vectors represent where the card right below the previous one is: in order, the next card is to the left / below / to the right of the previous card.
An object instantiated from this class is immutable.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Color
Color of the upper cardprivate final Color
Color of the middle cardprivate final Color
Color of the bottom cardprivate final int
Represetns how many points the card gives for each complete non-intersecting pattern is present in fieldprivate final Coordinates
Vector representing position of middle card with respect to upper card Mathmatically vec12 = (coordinates of middle card) - (coordinates of upper card) It can be only one among (-1,-1), (0,-1), (1,-1)private final Coordinates
Vector representing position of bottom card with respect to upper card Mathematically vec13 = (coordinates of bottom card) - (coordinates of upper card) It can be only one among (-2,-2), (-1,-2), (1,-2), (2,-2) -
Constructor Summary
ConstructorsConstructorDescriptionPointsPattern
(Color color1, Color color2, Color color3, int pos12, int pos23, int points) -
Method Summary
Modifier and TypeMethodDescriptionint
calcPoints
(FieldIF field) Calculate points of the card, according to how many (at most) non-intersercint patterns with right colors are found.boolean
int
getVec12()
getVec13()
int
hashCode()
-
Field Details
-
color1
Color of the upper card -
color3
Color of the bottom card -
color2
Color of the middle card -
vec12
Vector representing position of middle card with respect to upper card Mathmatically vec12 = (coordinates of middle card) - (coordinates of upper card) It can be only one among (-1,-1), (0,-1), (1,-1) -
vec13
Vector representing position of bottom card with respect to upper card Mathematically vec13 = (coordinates of bottom card) - (coordinates of upper card) It can be only one among (-2,-2), (-1,-2), (1,-2), (2,-2) -
points
private final int pointsRepresetns how many points the card gives for each complete non-intersecting pattern is present in field
-
-
Constructor Details
-
PointsPattern
public PointsPattern(Color color1, Color color2, Color color3, int pos12, int pos23, int points) throws InvalidCardCreationException - Parameters:
color1
- Color of upper cardcolor2
- Color of middle cardcolor3
- Color of bottom cardpos12
- Position of middle card with respect to upper card. It can only be -1 (to the left), 0 (right under), 1 (to the right)pos23
- Position of bottom card with respect to middle card. It can only be -1 (to the left), 0 (right under), 1 (to the right)points
- How many points the card gives for each complete non-intersecting pattern is present in field- Throws:
InvalidParameterException
- If pos12 or pos23 are not among their possible valuesInvalidCardCreationException
-
-
Method Details
-
getColor1
-
getColor3
-
getColor2
-
getVec12
-
getVec13
-
calcPoints
Calculate points of the card, according to how many (at most) non-intersercint patterns with right colors are found.- Specified by:
calcPoints
in interfacePointsObjective
- Parameters:
field
- Field of the player for whom you want to calculate the points given by the card objective.- Returns:
- Number of points guaranteed by the card objective
-
getPointsMultiplier
public int getPointsMultiplier()- Specified by:
getPointsMultiplier
in interfacePointsObjective
- Returns:
- Points multiplier of the objective card (how many points are given for each pattern/set satisfied in the field)
-
equals
-
hashCode
public int hashCode()
-