Class PointsPattern

java.lang.Object
it.polimi.ingsw.am13.model.card.points.PointsPattern
All Implemented Interfaces:
PointsObjective, Serializable

public class PointsPattern extends Object implements PointsObjective
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

    Fields
    Modifier and Type
    Field
    Description
    private final Color
    Color of the upper card
    private final Color
    Color of the middle card
    private final Color
    Color of the bottom card
    private final int
    Represetns how many points the card gives for each complete non-intersecting pattern is present in field
    private 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

    Constructors
    Constructor
    Description
    PointsPattern(Color color1, Color color2, Color color3, int pos12, int pos23, int points)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Calculate points of the card, according to how many (at most) non-intersercint patterns with right colors are found.
    boolean
     
     
     
     
    int
     
     
     
    int
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • color1

      private final Color color1
      Color of the upper card
    • color3

      private final Color color3
      Color of the bottom card
    • color2

      private final Color color2
      Color of the middle card
    • vec12

      private final Coordinates 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

      private final Coordinates 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 points
      Represetns 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 card
      color2 - Color of middle card
      color3 - Color of bottom card
      pos12 - 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 values
      InvalidCardCreationException
  • Method Details

    • getColor1

      public Color getColor1()
    • getColor3

      public Color getColor3()
    • getColor2

      public Color getColor2()
    • getVec12

      public Coordinates getVec12()
    • getVec13

      public Coordinates getVec13()
    • calcPoints

      public int calcPoints(FieldIF field)
      Calculate points of the card, according to how many (at most) non-intersercint patterns with right colors are found.
      Specified by:
      calcPoints in interface PointsObjective
      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 interface PointsObjective
      Returns:
      Points multiplier of the objective card (how many points are given for each pattern/set satisfied in the field)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object