Class GameAction

java.lang.Object
net.demilich.metastone.game.actions.GameAction
All Implemented Interfaces:
Serializable, Cloneable, Notification
Direct Known Subclasses:
DiscoverAction, EndTurnAction, OpenerAction, PhysicalAttackAction, PlayCardAction

public abstract class GameAction extends Object implements Cloneable, Serializable, Notification
An action a player can take in the game.

This class both represents the piece of data that a player should consider from a list from GameLogic.getValidActions(int). It also has the code that executes the action in the GameLogic.

See Also:
  • Field Details

    • chooseOneOptionIndex

      protected Integer chooseOneOptionIndex
  • Constructor Details

    • GameAction

      public GameAction()
  • Method Details

    • canBeExecutedOn

      public boolean canBeExecutedOn(GameContext gameContext, Player player, Entity entity)
    • clone

      public GameAction clone()
      Overrides:
      clone in class Object
    • execute

      public abstract void execute(GameContext context, int playerId)
      The implementation of this method actually represents the game effects of this action.

      For example, the PlayMinionCardAction eventually calls GameLogic.summon(int, Minion, Entity, int, boolean).

      Parameters:
      context - The game context
      playerId - The invoking player
      See Also:
    • getActionType

      public com.hiddenswitch.spellsource.rpc.Spellsource.ActionTypeMessage.ActionType getActionType()
    • getSourceReference

      public EntityReference getSourceReference()
    • getTargetReference

      public EntityReference getTargetReference()
    • getTargetRequirement

      public TargetSelection getTargetRequirement()
    • setActionType

      protected void setActionType(com.hiddenswitch.spellsource.rpc.Spellsource.ActionTypeMessage.ActionType actionType)
    • setSourceReference

      public void setSourceReference(EntityReference sourceReference)
    • setTarget

      public void setTarget(Entity target)
    • setTargetReference

      public void setTargetReference(EntityReference targetKey)
    • setTargetRequirement

      public void setTargetRequirement(TargetSelection targetRequirement)
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getId

      public int getId()
    • setId

      public void setId(int id)
    • isPowerHistory

      public boolean isPowerHistory()
      Description copied from interface: Notification
      When true, indicates to processors of this notification that it belongs in the power history.
      Specified by:
      isPowerHistory in interface Notification
      Returns:
      true if this notification should be stored in the power history of the game where it occurred.
    • getDescription

      public String getDescription(GameContext context, int playerId)
      Description copied from interface: Notification
      A user-renderable description of what occurred in this notification.
      Specified by:
      getDescription in interface Notification
      Parameters:
      context - the game context
      playerId - the player ID
      Returns:
      a description string
    • getSource

      public Entity getSource()
      Description copied from interface: Notification
      For visualization purposes, what is the source of this notification?
      Specified by:
      getSource in interface Notification
      Returns:
      A reference to the entity that is the visualizable source of this notification.
    • getSource

      public Entity getSource(GameContext context)
      Specified by:
      getSource in interface Notification
    • 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
      Parameters:
      context - game context
      player - the player
      Returns:
      A reference to the entity that is the visualizable target of this notification.
    • withTargetReference

      public GameAction withTargetReference(EntityReference reference)
    • isClientInterested

      public boolean isClientInterested()
      Description copied from interface: Notification
      Should this notification be sent to the client?
      Specified by:
      isClientInterested in interface Notification
      Returns:
      false by default.
    • getChooseOneOptionIndex

      public Integer getChooseOneOptionIndex()
    • setChooseOneOptionIndex

      public void setChooseOneOptionIndex(Integer chooseOneOptionIndex)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isOverrideChild

      public boolean isOverrideChild()
    • setOverrideChild

      public GameAction setOverrideChild(boolean overrideChild)