action package
Submodules
models.flow.action.action module
- class models.flow.action.action.Action(actor)
Bases:
ABC
Abstract base class for actions performed by game entities.
Defines the structure for validating and executing actions.
- static apply_effect(target, effect)
Apply an effect to a target.
- Parameters:
target (object) – GameEntity receiving the effect.
effect (dict) – Dictionary describing the effect.
- Example effect:
{ “type”: “buff”, “details”: “advantage on attack rolls”, “duration”: 3
}
- blocked
Whether the action has been blocked.
- abstractmethod execute(game_state)
Execute the action’s effects on the game state.
Must be implemented by subclasses.
- Parameters:
game_state (object) – The current state of the game.
- Raises:
NotImplementedError – If not implemented in subclass.
- execution_log
Log of events during the action’s execution.
- interrupt(reason)
Interrupt the action, marking it as blocked and logging the reason.
- Parameters:
reason (str) – The reason for the interruption.
- static roll(expression)
Parse and roll a dice expression (e.g., ‘2d6+3’) and return the result.
- Parameters:
expression (str) – A string representing the dice roll (e.g., ‘2d6+3’).
- Returns:
The total result of the dice roll.
- Return type:
int
- Raises:
ValueError – If the dice expression is invalid.
- abstractmethod validate(game_state)
Validate whether the action can be performed under the current game state.
Must be implemented by subclasses.
- Parameters:
game_state (object) – The current state of the game.
- Raises:
NotImplementedError – If not implemented in subclass.
- validated
Whether the action has been validated.
- models.flow.action.action.apply_effect(target, effect)
Apply an effect to a target.
- Parameters:
target (object) – GameEntity receiving the effect.
effect (dict) – Dictionary describing the effect.
- Example effect:
{ “type”: “buff”, “details”: “advantage on attack rolls”, “duration”: 3
}
- models.flow.action.action.roll(expression)
Parse and roll a dice expression (e.g., ‘2d6+3’) and return the result.
- Parameters:
expression (str) – A string representing the dice roll (e.g., ‘2d6+3’).
- Returns:
The total result of the dice roll.
- Return type:
int
- Raises:
ValueError – If the dice expression is invalid.
models.flow.action.action_validator module
- class models.flow.action.action_validator.ActionValidator
Bases:
object
- static validate(action, game_state=None)
Validate if the action can be performed. You could expand this with rulebooks, conditions, or custom logic.
- Parameters:
action – Action instance
game_state – Optional context, like current battlefield state
- Returns:
Boolean
models.flow.action.spell_action module
- class models.flow.action.spell_action.SpellAction(caster, spell, targets)
Bases:
Action
Represents a spell action performed by a caster on one or more targets.
- Parameters:
caster – The entity casting the spell.
spell – The spell object containing spell details.
targets – A list of target entities affected by the spell.
- execute(game_state)
Execute the spell action, applying its effects to the targets.
- Parameters:
game_state (object) – The current state of the game.
- Returns:
None
- validate(game_state)
Validate whether the spell can be cast in the current game state.
Checks range, line of sight, components, etc.
- Parameters:
game_state (object) – The current state of the game.
- Returns:
None