Skip to main content

Module log

Module log 

Source
Expand description

P6a — a generic, additive per-turn event log for stack-driven battles.

StackDriver::execute_turn returns only StackTurnResult { first, second_cancelled } — enough to sequence a turn, but NOT enough for a frontend to narrate it (“X used Y!”, “Critical hit!”, “X fainted!”). A game that renders a turn needs a structured record of WHAT HAPPENED.

This module adds that record as a generic, game-agnostic TurnLog of TurnEvents, populated by StackDriver::execute_turn_logged. It is ADDITIVE + DEFAULTED: the plain execute_turn is unchanged and draws no log; the logging path runs the SAME turn (identical rng draw order, identical final BattleState) and merely records a structural before/after diff at the driver’s existing event sites. Every existing battle / test that calls execute_turn is byte-identical.

The vocabulary is the universal JRPG turn surface — move used, miss, crit, damage, heal, status inflicted/cured, stat-stage change, faint — keyed by the engine’s existing generic associated types (P::Move / P::Status / P::Stat) and BattlerRef. Game-specific PRESENTATION (effectiveness wording, exact phrasing, animation choice) is the frontend’s job: the engine reports the structural truth in order, the game translates it to text/animation.

Structs§

TurnLog
An ordered log of TurnEvents for one stack-driven turn.

Enums§

HpChangeCause
Why a battler’s HP changed — carried on TurnEvent::Damaged / TurnEvent::Healed so a game can narrate residual ticks distinctly (“hurt by POISON!”, “sapped by LEECH SEED!”). None (the default) means ordinary move damage/heal — today’s behaviour, unchanged. The engine records only what it holds at the residual fire site: the non-volatile Status, or the volatile’s opaque EffectStateKind for a volatile-hosted residual — the game maps that token back to the concrete volatile (Toxic / Leech Seed / …). Engine-agnostic: the engine stores the token but never interprets it (symmetric with the Status variant).
TurnEvent
One structural event observed during a stack-driven turn (see module docs).