feat(engine): record + persist winning replays on disk
- New `RecordingReplay` resource (in `game_plugin`): in-memory move buffer that accumulates atomic player inputs as they're applied to `GameState`. Cleared on every `NewGameRequestEvent` so a fresh deal starts from an empty list. - `handle_move` and `handle_draw` push the corresponding `ReplayMove` on success only — invalid / rejected events never enter the buffer. `Undo` is intentionally not recorded; the replay represents the canonical path to victory, not the missteps that were rolled back. - `record_replay_on_win` listens for `GameWonEvent`, freezes the buffer into a `Replay` (seed + draw_mode + mode + score + duration + today's date + the move list), and persists atomically to `<data_dir>/solitaire_quest/latest_replay.json` via the new `ReplayPath` resource. - Empty-recording guard: synthesised win events from XP / streak / weekly-goal tests must not clobber the developer's real replay file. A real win always has at least one recorded move. - 5 dedicated tests cover ordering, rejected-move skipping, undo skipping, new-game clearing, and the freeze→save round-trip. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -92,7 +92,10 @@ pub use events::{
|
||||
ToggleLeaderboardRequestEvent, ToggleProfileRequestEvent, ToggleSettingsRequestEvent,
|
||||
ToggleStatsRequestEvent, UndoRequestEvent, WinStreakMilestoneEvent, XpAwardedEvent,
|
||||
};
|
||||
pub use game_plugin::{ConfirmNewGameScreen, GameMutation, GameOverScreen, GamePlugin, GameStatePath};
|
||||
pub use game_plugin::{
|
||||
ConfirmNewGameScreen, GameMutation, GameOverScreen, GamePlugin, GameStatePath, RecordingReplay,
|
||||
ReplayPath,
|
||||
};
|
||||
pub use help_plugin::{HelpPlugin, HelpScreen};
|
||||
pub use home_plugin::{HomePlugin, HomeScreen};
|
||||
pub use hud_plugin::{
|
||||
|
||||
Reference in New Issue
Block a user