Class LeaderCard

java.lang.Object
it.polimi.ingsw.model.leadercard.LeaderCard

public class LeaderCard
extends java.lang.Object
Represents a leader card
  • Constructor Details

    • LeaderCard

      public LeaderCard​(int ID, ResourceType requiredResources, java.util.Map<CardFlag,​java.lang.Integer> requiredCardFlags, int victoryPoints, CardBehaviour cardBehaviour)
      class constructor
      Parameters:
      requiredResources - resource type required to buy the card. Can be null
      requiredCardFlags - DevelopCard's cardFlags required to buy the card. Can be null
      victoryPoints - card's points
      cardBehaviour - object containing the card's behaviour (abilities)
    • LeaderCard

      public LeaderCard​(ResourceType requiredResources, java.util.Map<CardFlag,​java.lang.Integer> requiredCardFlags, int victoryPoints, CardBehaviour cardBehaviour)
  • Method Details

    • setActive

      public void setActive​(InterfacePlayerBoard playerBoard) throws NotEnoughResourcesException, InvalidLeaderCardException
      if it's allowed sets the LeaderCard state to active
      Parameters:
      playerBoard - the player that wants to activate the card
      Throws:
      NotEnoughResourcesException - if the player doesn't have the resources (CardFlags or ResourceType) to activate the card
      InvalidLeaderCardException - if the player doesn't own this card
    • isActive

      public boolean isActive()
      returns true if this is an active card in the player's playerboard
      Returns:
      true if this card is active
    • getLeaderId

      public int getLeaderId()
    • getImage

      public java.lang.String getImage()
    • getVictoryPoints

      public int getVictoryPoints()
      get the number of victory points
      Returns:
      the number of this card's victory points
    • applyDiscount

      public void applyDiscount​(java.util.HashMap<ResourceType,​java.lang.Integer> mapToDiscount)
      applies discount to the map passed as a parameter the method modifies the map passed as a parameter in order to apply the discount does nothing if the card is not active or doesn't have this ability
    • resourceOnWhite

      public ResourceType resourceOnWhite()
      the ResourceType in which to convert the white marble that comes from a market
      Returns:
      the ResourceType in which to convert the white marble or null if the card is not active or doesn't have this ability
    • leaderProduce

      public void leaderProduce​(ResourceType resourceToAdd, InterfacePlayerBoard playerBoard) throws AbuseOfFaithException, NotEnoughResourcesException, NeedAResourceToAddException
      activates the production ability does nothing if the card is not active or doesn't have this ability
      Parameters:
      resourceToAdd - the resource that will be produced (FAITH not allowed)
      playerBoard - that wants to activate this ability (needed to add and remove resources directly from his storages)
      Throws:
      AbuseOfFaithException - if you pass ResourceType.FAITH as the resource you want to add
      NotEnoughResourcesException - if the player doesn't have the resources to activate the production
      NeedAResourceToAddException
    • addStorageSpace

      public void addStorageSpace​(InterfacePlayerBoard playerBoard) throws MaxLeaderCardLevelsException
      activates the additional storage space ability does nothing if the card is not active or doesn't have this ability
      Parameters:
      playerBoard - that wants to activate a Storage type LeaderCard
      Throws:
      MaxLeaderCardLevelsException - if the maximum number of additional storages is surpassed
    • getResToDiscount

      public ResourceType getResToDiscount()
    • getProductionRequirement

      public ResourceType getProductionRequirement()
    • getWhite

      public ResourceType getWhite()
    • getResToStore

      public ResourceType getResToStore()
    • getRequiredResources

      public ResourceType getRequiredResources()
    • getRequiredCardFlags

      public java.util.Map<CardFlag,​java.lang.Integer> getRequiredCardFlags()