Class CardObjective

java.lang.Object
it.polimi.ingsw.am13.model.card.Card
it.polimi.ingsw.am13.model.card.CardObjective
All Implemented Interfaces:
CardIF, CardObjectiveIF, Serializable

public class CardObjective extends Card implements CardObjectiveIF
Represents an objective card. It stores only the active/front side (the back side has no information). It's then the side that store information about the points guaranted by the card itself.
See Also:
  • Field Details

    • front

      private final CardSideObjectiveActive front
      Active/front side of the card, where information about the points is stored.
  • Constructor Details

    • CardObjective

      public CardObjective(String id, int points, Map<Resource,Integer> set)
      Creates a new immutable objective card, with points of type "x points for each set of resources/objects"
      Parameters:
      id - Id of the card. Look at class Card for more information
      points - How many points the card gives for each complete set present in field
      set - The set of resources/objects that must be present to obtain the points
    • CardObjective

      public CardObjective(String id, int points, Color color1, Color color2, Color color3, int pos12, int pos23) throws InvalidCardCreationException
      Creates a new immutable card side for an objective card of type "x points for each pattern with 3 card in a certain position and with certain colors"
      Parameters:
      id - Id of the card. Look at class Card for more information
      points - How many points the card gives for each complete non-intersecting pattern is present in field
      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)
      Throws:
      InvalidCardCreationException - If pos12 or pos23 are not among their possible values
  • Method Details

    • calcPoints

      public int calcPoints(Field field)
      Calculates the points guaranteed by the card for the field passed as parameter
      Parameters:
      field - Field of the player for whom you want to calculate the points given by the card.
      Returns:
      Number of points guaranteed by the card objective
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Card
    • getPoints

      public PointsObjective getPoints()
      Specified by:
      getPoints in interface CardObjectiveIF