Class CardBehaviour

java.lang.Object
it.polimi.ingsw.model.leadercard.CardBehaviour
Direct Known Subclasses:
DiscountBehaviour, LeaderProduceBehaviour, MarbleModifierBehaviour, StorageBehaviour

public abstract class CardBehaviour
extends java.lang.Object
Class that contains all possibile leaderCards behaviours. When a leadercard ability gets activated these methods get called to perform the card ability. These methods are Overridden by the specific subclasses that represent the various possible card Types; so in order to create the specific cards it is possible to compose at will this methods in a new implementation of the CardBehaviour interface
  • Constructor Details

    • CardBehaviour

      public CardBehaviour()
  • Method Details

    • getOnWhite

      public ResourceType getOnWhite()
      returns the resource white marble ResourceType produced by the LeaderCard ability. Returns null if the card doesn't have this ability
      Returns:
      can be null if this leadercard doesn't convert white marbles
    • createStorage

      public void createStorage​(InterfacePlayerBoard playerBoard) throws MaxLeaderCardLevelsException
      adds level to the warehouse of the specified playerBoard so that the leaderCard level becomes usable. Does nothing if the card doesn't have this ability
      Parameters:
      playerBoard - playerBoard in which to add the warehouse level
      Throws:
      MaxLeaderCardLevelsException - if more than the maximum allowed number of additional levels are added
    • produce

      activates the leader ability to produce resources. Does nothing if the card doesn't have this ability
      Parameters:
      resourceToAdd - the resource to add to the Chest
      playerboard - the playerBoard in which to add the resources
      Throws:
      AbuseOfFaithException - if resourceToAdd is the faith resource
      NotEnoughResourcesException - if the specified playerBoard doesn't have enough resources to consume for the production
      NeedAResourceToAddException - if the resourceToAdd parameter is not specified
    • discount

      public void discount​(java.util.HashMap<ResourceType,​java.lang.Integer> resources)
      applies discount to the map passed as a parameter NOTE: the method modifies the map passed as a parameter in order to apply the discount does nothing if the card doesn't have this ability
      Parameters:
      resources - the resource map to be discounted
    • getResourceToDiscount

      public ResourceType getResourceToDiscount()
    • getProductionRequirement

      public ResourceType getProductionRequirement()
    • getResToStore

      public ResourceType getResToStore()