Class OpenerAction

java.lang.Object
net.demilich.metastone.game.actions.GameAction
net.demilich.metastone.game.actions.OpenerAction
All Implemented Interfaces:
Serializable, Cloneable, Notification

public final class OpenerAction extends GameAction
Battlecry actions occur when Actor entities are played from cards and have battlecries. A battlecry is a possibly targeted effect.
See Also:
  • Field Details

  • Constructor Details

    • OpenerAction

      protected OpenerAction(SpellDesc spell)
  • Method Details

    • createBattlecry

      public static OpenerAction createBattlecry(SpellDesc spell, TargetSelection targetSelection)
      Creates a battlecry action that performs the specified spell and requests a target.

      To filter the target, make sure to add a SpellArg.FILTER to the spell.

      Parameters:
      spell - The spell to cast for this battlecry action.
      targetSelection - The target selection to make.
      Returns:
      An instance
    • clone

      public OpenerAction clone()
      Overrides:
      clone in class GameAction
    • canBeExecuted

      public boolean canBeExecuted(GameContext context, Player player)
      Computes whether the condition is fulfilled for a battlecry action to be executable. Conditions are not evaluated against targets.
      Parameters:
      context - The game context
      player - The casting player
      Returns:
      true if this battlecry can be executed generally (if it will even prompt the user for targeting).
    • canBeExecutedOn

      public final boolean canBeExecutedOn(GameContext context, Player player, Entity entity)
      Computes whether the given target entity can be targeted by this battlecry.
      Overrides:
      canBeExecutedOn in class GameAction
      Parameters:
      context - The game context
      player - The casting player
      entity - The target entity
      Returns:
      true if the entity is a valid target for the battlecry.
    • execute

      public void execute(GameContext context, int playerId)
      Casts the getSpell() on this action with the specified target.
      Specified by:
      execute in class GameAction
      Parameters:
      context - The game context
      playerId - The casting player.
      See Also:
    • getPredefinedSpellTargetOrUserTarget

      public EntityReference getPredefinedSpellTargetOrUserTarget()
      Returns either the target chosen by the user or the predefined target (possible a group reference / EntityReference.isTargetGroup()) written on the SpellDesc of the spell.
      Returns:
      An entity reference
    • getCondition

      public Condition getCondition()
    • getEntityFilter

      public EntityFilter getEntityFilter()
      Returns the SpellArg.FILTER of the spell.
      Returns:
      The filter.
    • getSpell

      public SpellDesc getSpell()
    • setCondition

      public void setCondition(Condition condition)
    • getSource

      public Entity getSource(GameContext context)
      Specified by:
      getSource in interface Notification
      Overrides:
      getSource in class GameAction
    • getTargets

      public List<Entity> getTargets(GameContext context, int player)
      Description copied from interface: Notification
      For visualization purposes, what are the targets of this notification?
      Specified by:
      getTargets in interface Notification
      Overrides:
      getTargets in class GameAction
      Parameters:
      context - game context
      player - the player
      Returns:
      A reference to the entity that is the visualizable target of this notification.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class GameAction
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class GameAction
    • getDescription

      public String getDescription(GameContext context, int playerId)
      Creates a formatted description for the battlecry given its target.
      Specified by:
      getDescription in interface Notification
      Overrides:
      getDescription in class GameAction
      Parameters:
      context -
      playerId -
      Returns:
    • shouldOverrideTargetSelection

      public boolean shouldOverrideTargetSelection(GameContext context, Player player, Actor actor)
    • getTargetSelectionCondition

      public Condition getTargetSelectionCondition()
    • getTargetSelectionOverride

      public TargetSelection getTargetSelectionOverride()
    • setTargetSelectionCondition

      public void setTargetSelectionCondition(Condition targetSelectionCondition)
    • setTargetSelectionOverride

      public void setTargetSelectionOverride(TargetSelection targetSelectionOverride)