Expand description
Battle system trait definitions for a JRPG engine framework.
This module defines the core abstractions for turn-based battle systems:
battle state, battler state, type charts, AI decision-making, and
move effect handling. All types are generic over a BattleProvider
implementation — the engine is game-agnostic.
§Architecture
BattleProvider— Central trait supplying battle data, damage formula, and factory methods. All methods take&self(read-only provider).TypeChart— N×N type effectiveness matrix, parameterized by game types.BattleAI— Move selection, switching, and item-use decisions.EffectHandler— Dispatches move effects (damage, healing, status, stat changes) on battler state.
§Design Principles
- Generic over game data — No concrete game-specific, monster, or move types.
All identifiers are associated types on
BattleProvider. - Provider pattern — Battle systems query the provider, which delegates to type charts, AI, and effect handlers internally.
- No I/O, no platform — Pure data and trait definitions only.
Re-exports§
pub use ai::BattleAi;pub use ai::BattleAiProvider;pub use driver::BattleDriver;pub use driver::BattleEnd;pub use driver::TurnEvent;pub use driver::TurnOutcome;pub use rng::BattleRng;
Modules§
- ai
- Generic, game-agnostic battle AI driver (P0c).
- driver
- Generic, game-agnostic battle turn-execution driver (P0b).
- rng
- Injected randomness for the battle turn-execution driver (P0b).
- stack
- Showdown-style effect-stack battle engine (Pattern C) — vertical-slice
POC (design doc
06-battle-engine-effect-stack-design.md, §8).
Structs§
- Battle
State - The complete state of an ongoing battle.
- Battler
Ref - A reference to one battler position on the battlefield.
- Battler
State - The battle state of a single monster/character.
- Damage
Result - Result of a damage calculation.
- EnumMap
- A map from enum-like keys to values, backed by a
Vecof(K, V)pairs. - Order
Key - A turn-ordering sort key produced by
BattleProvider::turn_order_key. - Resource
Pool - A per-battler pool of generic, game-defined consumable resources (MP / SP / TP / mana / charge — the engine assigns the concept no name; doc 13 §4, the highest-value STATE-SEAM).
Enums§
- Battle
Action - The action a battler has chosen to take this turn.
- Effect
Result - Outcome of applying a move effect.
- Move
Effect - Categories of additional effects a move can have.
- Move
Gate - Result of
BattleProvider::before_move: the pre-move status gate. - Terrain
- Field terrain condition.
- Weather
- Field weather condition.
Traits§
- BattleAI
- AI decision-making for battle actions.
- Battle
Provider - Central trait for battle system data and formula implementations.
- Effect
Handler - Handles move effects on battler state.
- Type
Chart - N×N type effectiveness matrix.