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
Fields inherited from class net.demilich.metastone.game.actions.GameAction
chooseOneOptionIndex
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canBeExecutedOn
(GameContext context, Player player, Entity entity) clone()
void
execute
(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 void
innerExecute
(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:
clone
in classGameAction
-
canBeExecutedOn
- Overrides:
canBeExecutedOn
in classGameAction
-
execute
Plays a card from the hand. Evaluates whether the card was countered, increments combos, and deducts mana.- Specified by:
execute
in 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
TargetSelection
will still occur.The
EntityReference.TARGET
will 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:
getSource
in interfaceNotification
- Overrides:
getSource
in classGameAction
-
getTargets
Description copied from interface:Notification
For visualization purposes, what are the targets of this notification?- Specified by:
getTargets
in interfaceNotification
- Overrides:
getTargets
in 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:Notification
A user-renderable description of what occurred in this notification.- Specified by:
getDescription
in interfaceNotification
- Overrides:
getDescription
in classGameAction
- Parameters:
context
- the game contextplayerId
- the player ID- Returns:
- a description string
-