java.lang.Object
it.polimi.ingsw.am13.model.card.Corner
All Implemented Interfaces:
Serializable

public class Corner extends Object implements Serializable
This is a class that represents one of the four corners of the side of a card
See Also:
  • Field Details

    • visibility

      private final boolean visibility
      This attribute represents whether the corner is visible or not
    • covered

      private boolean covered
      This attribute represents whether the corner has been covered by another corner or not
    • resource

      private final Resource resource
      This attribute represents the resource contained in this corner
  • Constructor Details

    • Corner

      public Corner(Resource resource)
      This is a constructor of a visible corner
      Parameters:
      resource - Resource present on the corner. If the corner is visible but has no resource, use Resource.NO_RESOURCE
    • Corner

      public Corner()
      This is a constructor of a corner that isn't visible. A non-visible corner can only contain NO_RESOURCE as a resource
  • Method Details

    • getResource

      public Resource getResource()
      Returns:
      the resource contained in this corner
    • getLink

      public CardSidePlayable getLink()
      Returns:
      the link contained in this corner
    • isCovered

      public boolean isCovered()
      Returns:
      whether the corner has been covered by another corner or not
    • coverCorner

      public void coverCorner()
      This method covers the Corner by setting the covered variable to true
    • isPlaceable

      public boolean isPlaceable()
      Returns:
      whether another corner can be played on top of this corner
    • addLinkToCard

      public void addLinkToCard(CardSidePlayable cardSidePlayable) throws VariableAlreadySetException
      This method creates a link from this corner to a cardSidePlayable
      Parameters:
      cardSidePlayable - the cardSidePlayable to which the link will be created
      Throws:
      VariableAlreadySetException - when the link isn't null, ie it was already set outside the constructor before
    • generateEmptyCorners

      public static List<Corner> generateEmptyCorners()
      Utility method useful for tests. Generates a list of four visible empty corners (as in back side of resource cards)
      Returns:
      New list of four visible empty corners (as in back side of resource cards)
    • clone

      public Corner clone()
      Overrides:
      clone in class Object
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object