Consolidate shared trail-game pieces into retro-kit

Consolidate shared trail-game pieces into retro-kit

#29 in Riparion/riparion-retro — merged 2026-06-11

What

Lift the genuinely game-agnostic pieces that were copy-pasted across Oregon Trail, Fort Nash, and Kaintuck into retro-kit:

  • rations::EatLevel — the ration enum (food_cost = 8 + 5·E), re-exported by each trail game's engine::state. Serde wire-format is unchanged, so existing localStorage saves still load.
  • scoring::{calendar_date, arrival_date, leftover_value} — the arrival-date calendar walk, parameterized by epoch/period/year, plus the leftover-supplies valuation. Each game keeps its own score/rank/HighScore (constants and fields diverge; Kaintuck's has no miles).
  • game_flow::{Persisted, use_persistence} — the identical save-on-transition / clear-and-record-on-game-over use_effect, captured as a trait + helper generic over G so the per-game Signal stays concrete. Each game impls Persisted (Kaintuck scores on state.trader, the trail games on state.party); each app.rs collapses its hand-rolled effect to use_persistence(game).

retro-kit 0.1.2 → 0.1.5; game patch versions bumped accordingly.

What deliberately did not change

  • UI components stay per-game (GameRoot dispatch, StatusBar, Cover, InteractionHost, GameOver). Dioxus 0.7 keys context by concrete type, so a generic version would fight the framework for little gain.
  • The oregon-trail/fort-nash engines stay separate. They look ~99% identical by line count, but a close diff shows the overlap is the probability/formula skeleton while the divergence is dominated by ~200 inline narrative strings + real behavioral forks (SteadyTask::Ice death path, the third Cumberland-River crossing, the Ford-minigame-vs-plain-toll event slot, fortnights vs weeks). Merging would replace readable inline voice with a string table — a maintainability regression. NOTES.md records the rationale so it isn't re-litigated.

Verification

  • cargo test --workspace — all green (24 test binaries, 0 failures); retro-kit gained 7 host-side tests for the moved math.
  • All 9 games + examples still compile; Cargo.lock refreshed.
  • wasm smoke (oregon-trail): just build oregon-trail succeeds; driven headless — boots with no page errors, use_persistence writes the save ({version:2, data}), eat_level still serializes as the bare string "Moderately" (save compat intact), and reload offers RESUME JOURNEY.

🤖 Generated with Claude Code

Last updated 2026-06-12