Class PlayCardAction
- All Implemented Interfaces:
Serializable,Cloneable,Notification
- Direct Known Subclasses:
PlayChooseOneCardAction,PlayHeroCardAction,PlayMinionCardAction,PlaySpellCardAction,PlayWeaponCardAction
When a Card is Card.play()'d, the action that is returned by that method doesn't have a GameAction.getTargetReference() even if it requires a target. ActionLogic.rollout(GameAction, GameContext, Player, Collection) will inspect the PlayCardAction, checking its GameAction.getTargetRequirement() to see if it's supposed to ask a target from the player.
This means that Card.play() action instance isn't yet a valid action that can be played, unless its CardDesc.getTargetSelection() is TargetSelection.NONE. If the target
selection isn't NONE, the action should be rolled out into multiple actions, one corresponding to each valid
target.
-
Field Summary
FieldsFields inherited from class net.demilich.metastone.game.actions.GameAction
chooseOneOptionIndex -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanBeExecutedOn(GameContext context, Player player, Entity entity) clone()voidexecute(GameContext context, int playerId) Plays a card from the hand.getDescription(GameContext context, int playerId) A user-renderable description of what occurred in this notification.getSource(GameContext context) getTargets(GameContext context, int player) For visualization purposes, what are the targets of this notification?abstract voidinnerExecute(GameContext context, int playerId) Represents the consequences of playing a spell card, minion card, hero card, hero power card, etc.Methods inherited from class net.demilich.metastone.game.actions.GameAction
equals, getActionType, getChooseOneOptionIndex, getId, getSource, getSourceReference, getTargetReference, getTargetRequirement, hashCode, isClientInterested, isOverrideChild, isPowerHistory, setActionType, setChooseOneOptionIndex, setId, setOverrideChild, setSourceReference, setTarget, setTargetReference, setTargetRequirement, toString, withTargetReference
-
Field Details
-
logger
public static org.slf4j.Logger logger
-
-
Constructor Details
-
PlayCardAction
protected PlayCardAction() -
PlayCardAction
-
-
Method Details
-
clone
- Overrides:
clonein classGameAction
-
canBeExecutedOn
- Overrides:
canBeExecutedOnin classGameAction
-
execute
Plays a card from the hand. Evaluates whether the card was countered, increments combos, and deducts mana.- Specified by:
executein classGameAction- Parameters:
context- The game contextplayerId- The player who actually plays the card- See Also:
-
innerExecute
Represents the consequences of playing a spell card, minion card, hero card, hero power card, etc.Unlike
execute(GameContext, int), this method will not deduct mana, will not be counterable, and will not increment combos. In other words, this method omits the effects of playing a card from the hand.However, by using the action, a
TargetSelectionwill still occur.The
EntityReference.TARGETwill refer to whatever is theGameAction.getTargetReference().The
GameAction.getTargetRequirement()indicates whether or not these effects require a target to be selected.- Parameters:
context-playerId-
-
getSource
- Specified by:
getSourcein interfaceNotification- Overrides:
getSourcein classGameAction
-
getTargets
Description copied from interface:NotificationFor visualization purposes, what are the targets of this notification?- Specified by:
getTargetsin interfaceNotification- Overrides:
getTargetsin classGameAction- Parameters:
context- game contextplayer- the player- Returns:
- A reference to the entity that is the visualizable target of this notification.
-
getDescription
Description copied from interface:NotificationA user-renderable description of what occurred in this notification.- Specified by:
getDescriptionin interfaceNotification- Overrides:
getDescriptionin classGameAction- Parameters:
context- the game contextplayerId- the player ID- Returns:
- a description string
-