Class AbstractBehaviour
java.lang.Object
net.demilich.metastone.game.behaviour.AbstractBehaviour
- All Implemented Interfaces:
Serializable
,Cloneable
,Behaviour
- Direct Known Subclasses:
IntelligentBehaviour
,UtilityBehaviour
A base class for behaviours that implement no action or a default action when its methods are called.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
Clones the behaviour, typically with its internal state.boolean
isHuman()
Determines whether this behaviour's actions were determined by a human.void
mulliganAsync
(GameContext context, Player player, List<Card> cards, Consumer<List<Card>> handler) Asynchronously request a mulligan.void
onGameOver
(GameContext context, int playerId, int winningPlayerId) Notify the behaviour that the game is over, allowing it to clean up any state.void
requestActionAsync
(GameContext context, Player player, List<GameAction> validActions, Consumer<GameAction> callback) Requests an action from a player asynchronously.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.demilich.metastone.game.behaviour.Behaviour
getName, mulligan, requestAction
-
Constructor Details
-
AbstractBehaviour
public AbstractBehaviour()
-
-
Method Details
-
clone
Description copied from interface:Behaviour
Clones the behaviour, typically with its internal state. -
onGameOver
Description copied from interface:Behaviour
Notify the behaviour that the game is over, allowing it to clean up any state.- Specified by:
onGameOver
in interfaceBehaviour
- 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 interfaceBehaviour
- 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 interfaceBehaviour
- 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 thevalidActions
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.
-