feat(engine): require N-key confirmation when abandoning an active game

Pressing N during an active game (move_count > 0, not won) now shows a
"Press N again to start a new game" toast and only starts a new game if
N is pressed a second time within 3 seconds. Starting a fresh game or
pressing N after a win still acts immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-04-27 02:53:28 +00:00
parent dfeaed6de2
commit 4a33cbdc22
5 changed files with 66 additions and 16 deletions
+12
View File
@@ -11,6 +11,7 @@ use crate::auto_complete_plugin::AutoCompleteState;
use crate::card_plugin::CardEntity;
use crate::challenge_plugin::ChallengeAdvancedEvent;
use crate::daily_challenge_plugin::{DailyChallengeCompletedEvent, DailyGoalAnnouncementEvent};
use crate::events::NewGameConfirmEvent;
use crate::events::{AchievementUnlockedEvent, GameWonEvent};
use crate::game_plugin::GameMutation;
use crate::layout::LayoutResource;
@@ -91,6 +92,7 @@ impl Plugin for AnimationPlugin {
.add_event::<TimeAttackEndedEvent>()
.add_event::<ChallengeAdvancedEvent>()
.add_event::<SettingsChangedEvent>()
.add_event::<NewGameConfirmEvent>()
.init_resource::<EffectiveSlideDuration>()
.add_systems(Startup, init_slide_duration)
.add_systems(
@@ -108,6 +110,7 @@ impl Plugin for AnimationPlugin {
handle_challenge_toast,
handle_settings_toast,
handle_auto_complete_toast,
handle_new_game_confirm_toast,
tick_toasts,
)
.after(GameMutation),
@@ -310,6 +313,15 @@ fn handle_auto_complete_toast(
}
}
fn handle_new_game_confirm_toast(
mut commands: Commands,
mut events: EventReader<NewGameConfirmEvent>,
) {
for _ in events.read() {
spawn_toast(&mut commands, "Press N again to start a new game".to_string(), 3.0);
}
}
fn tick_toasts(
mut commands: Commands,
time: Res<Time>,