Class AbstractBehaviour

java.lang.Object
net.demilich.metastone.game.behaviour.AbstractBehaviour
All Implemented Interfaces:
Serializable, Cloneable, Behaviour
Direct Known Subclasses:
IntelligentBehaviour, UtilityBehaviour

public abstract class AbstractBehaviour extends Object implements Behaviour, Serializable
A base class for behaviours that implement no action or a default action when its methods are called.
See Also:
  • Constructor Details

    • AbstractBehaviour

      public AbstractBehaviour()
  • Method Details

    • clone

      public AbstractBehaviour clone()
      Description copied from interface: Behaviour
      Clones the behaviour, typically with its internal state.
      Specified by:
      clone in interface Behaviour
      Overrides:
      clone in class Object
      Returns:
      A clone of the Behaviour instance.
    • onGameOver

      public void onGameOver(GameContext context, int playerId, int winningPlayerId)
      Description copied from interface: Behaviour
      Notify the behaviour that the game is over, allowing it to clean up any state.
      Specified by:
      onGameOver in interface Behaviour
      Parameters:
      context - The context of the game that has ended.
      playerId - The player that corresponds to this behaviour.
      winningPlayerId - The winning player.
    • mulliganAsync

      public void mulliganAsync(GameContext context, Player player, List<Card> cards, Consumer<List<Card>> handler)
      Description copied from interface: Behaviour
      Asynchronously request a mulligan.
      Specified by:
      mulliganAsync in interface Behaviour
      Parameters:
      context - The game context.
      player - The player who is mulliganing.
      cards - The cards in the player's first hand.
      handler - The callback when the player chose which cards to discard.
      See Also:
    • requestActionAsync

      public void requestActionAsync(GameContext context, Player player, List<GameAction> validActions, Consumer<GameAction> callback)
      Description copied from interface: Behaviour
      Requests an action from a player asynchronously.
      Specified by:
      requestActionAsync in interface Behaviour
      Parameters:
      context - The game context where the choice is being made.
      player - The player who is making the choice.
      validActions - The valid actions the player has to choose from.
      callback - The callback whose argument is one of the validActions that correspond to the player's
    • isHuman

      public boolean isHuman()
      Description copied from interface: Behaviour
      Determines whether this behaviour's actions were determined by a human.
      Specified by:
      isHuman in interface Behaviour
      Returns:
      true if the actions are determined by a human, false otherwise.