fix(engine): eliminate panics, fix dismiss hit-test scope, guard home respawn

CR-2: dismiss_modal_on_scrim_click now queries only the target scrim's
      Children rather than all ModalCard entities globally. Prevents
      dismissing the wrong scrim when two overlapping modals are open.

CR-5: handle_home_draw_mode_buttons and handle_home_difficulty_toggle
      now check other_modal_scrims.is_empty() before the despawn+respawn
      cycle, preventing a concurrent second ModalScrim in the same frame.

H-1:  solitaire_core::game_state — replaced all panicking piles[&key]
      index accesses with safe .get().ok_or(MoveError::InvalidSource)?,
      .get().is_some_and(...), or .get().and_then(...) in draw(),
      check_auto_complete(), next_auto_complete_move(), foundation_slot_for().

H-5:  input_plugin end_drag and touch_end_drag — replaced piles[&target]
      with .get(&target).is_some_and(...) so missing pile types reject the
      move rather than panicking.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
funman300
2026-05-17 20:09:01 -07:00
parent d3d8094ebb
commit 3bb3ddb6f8
4 changed files with 43 additions and 25 deletions
+8 -7
View File
@@ -717,13 +717,12 @@ fn end_drag(
let ok = match &target {
PileType::Foundation(_) => {
count == 1
&& can_place_on_foundation(
&bottom_card,
&game.0.piles[&target],
)
&& game.0.piles.get(&target)
.is_some_and(|p| can_place_on_foundation(&bottom_card, p))
}
PileType::Tableau(_) => {
can_place_on_tableau(&bottom_card, &game.0.piles[&target])
game.0.piles.get(&target)
.is_some_and(|p| can_place_on_tableau(&bottom_card, p))
}
_ => false,
};
@@ -972,10 +971,12 @@ fn touch_end_drag(
let ok = match &target {
PileType::Foundation(_) => {
count == 1
&& can_place_on_foundation(&bottom_card, &game.0.piles[&target])
&& game.0.piles.get(&target)
.is_some_and(|p| can_place_on_foundation(&bottom_card, p))
}
PileType::Tableau(_) => {
can_place_on_tableau(&bottom_card, &game.0.piles[&target])
game.0.piles.get(&target)
.is_some_and(|p| can_place_on_tableau(&bottom_card, p))
}
_ => false,
};