Package it.polimi.ingsw.model.leadercard
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 Summary
Constructors Constructor Description CardBehaviour() -
Method Summary
Modifier and Type Method Description voidcreateStorage(InterfacePlayerBoard playerBoard)adds level to the warehouse of the specified playerBoard so that the leaderCard level becomes usable.voiddiscount(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 abilityResourceTypegetOnWhite()returns the resource white marble ResourceType produced by the LeaderCard ability.ResourceTypegetProductionRequirement()ResourceTypegetResourceToDiscount()ResourceTypegetResToStore()voidproduce(ResourceType resourceToAdd, InterfacePlayerBoard playerboard)activates the leader ability to produce resources.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
CardBehaviour
public CardBehaviour()
-
-
Method Details
-
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
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
public void produce(ResourceType resourceToAdd, InterfacePlayerBoard playerboard) throws AbuseOfFaithException, NotEnoughResourcesException, NeedAResourceToAddExceptionactivates the leader ability to produce resources. Does nothing if the card doesn't have this ability- Parameters:
resourceToAdd- the resource to add to the Chestplayerboard- the playerBoard in which to add the resources- Throws:
AbuseOfFaithException- if resourceToAdd is the faith resourceNotEnoughResourcesException- if the specified playerBoard doesn't have enough resources to consume for the productionNeedAResourceToAddException- if the resourceToAdd parameter is not specified
-
discount
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
-
getProductionRequirement
-
getResToStore
-