fix(engine): start new game when player confirms abandon-current-game modal
CI / Test & Lint (push) Failing after 19s
CI / Release Build (push) Has been skipped

Reported during 2026-04-29 smoke test: pressing Y on the
ConfirmNewGameScreen modal closed nothing and didn't start a new game.

Trace:
  Frame N: handle_confirm_input despawns the modal entity (deferred),
           writes NewGameRequestEvent.
  End of N: command flush — modal gone.
  Frame N+1: handle_new_game reads the event. needs_confirm is still
             true (game state unchanged). confirm_already_open is now
             false (modal flushed). Condition matches → spawn_confirm_
             dialog runs again, the modal reappears, and the new game
             never starts.

Add a `confirmed: bool` field to NewGameRequestEvent. handle_confirm_
input writes it as true on Y/Enter so handle_new_game's dialog-spawn
guard short-circuits and the existing despawn-and-start branch runs.
All other writers (button click, N hotkey, mode hotkeys, daily/
challenge/time-attack auto-deal, tests) stay at `confirmed: false`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
funman300
2026-04-29 23:28:48 +00:00
parent b10e1a5a87
commit 62cd1cf924
8 changed files with 31 additions and 11 deletions
+2 -2
View File
@@ -554,7 +554,7 @@ mod tests {
.move_count = 3;
app.world_mut()
.write_message(NewGameRequestEvent { seed: Some(999), mode: None });
.write_message(NewGameRequestEvent { seed: Some(999), mode: None, confirmed: false });
app.update();
let stats = &app.world().resource::<StatsResource>().0;
@@ -567,7 +567,7 @@ mod tests {
fn new_game_without_moves_does_not_record_abandoned() {
let mut app = headless_app();
app.world_mut()
.write_message(NewGameRequestEvent { seed: Some(42), mode: None });
.write_message(NewGameRequestEvent { seed: Some(42), mode: None, confirmed: false });
app.update();
let stats = &app.world().resource::<StatsResource>().0;