babylon.models.entities.trigger
Trigger model for event conditions.
A Trigger defines conditions that can cause events to occur. Triggers are the connection between game state and event generation.
This replaces the old dataclass in data/models/trigger.py.
Design note: The old Trigger used a Callable for the condition, which cannot be serialized. This version uses a declarative condition specification that can be evaluated and serialized.
Classes
|
A condition that can trigger game events. |
|
A single condition that can be evaluated against game state. |
- class babylon.models.entities.trigger.TriggerCondition(**data)[source]
Bases:
BaseModelA single condition that can be evaluated against game state.
Conditions specify what to check, how to compare, and what threshold to use. Multiple conditions can be combined in a Trigger.
- Parameters:
- path
Dot-notation path to the value in game state (e.g., “economy.gini_coefficient”)
- operator
Comparison operator
- threshold
Value to compare against
- description
Human-readable explanation
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class babylon.models.entities.trigger.Trigger(**data)[source]
Bases:
BaseModelA condition that can trigger game events.
Triggers define when events should occur based on game state. They can have multiple conditions that must all be met (AND logic) or any one met (OR logic).
- Parameters:
- id
Unique identifier
- description
Human-readable description
- trigger_type
Category of trigger (economic, political, social, etc.)
- conditions
List of conditions to evaluate
- logic
How to combine conditions (all must pass or any must pass)
- parameters
Optional parameters for condition evaluation
- cooldown_turns
Minimum turns between activations (0 = no cooldown)
- last_triggered_turn
Turn when this was last triggered
-
conditions:
list[TriggerCondition]
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].