fix(engine): Draw-Three waste fan hit-testing; add HUD and input coverage
fix(input_plugin): card_position() now applies the same X-fan offset for Draw-Three waste cards as card_plugin uses for rendering. Previously the top waste card appeared at base_x + 0.56 * card_width but was only hittable at base_x, making it impossible to drag from its visual position. test(hud_plugin): add five behaviour tests — score/moves/time display format, Zen mode score suppression, Draw-Three mode badge. test(input_plugin): add find_draggable test that clicks the top fanned waste card at its visual X position and confirms it hits in Draw-Three. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -164,4 +164,60 @@ mod tests {
|
||||
GameState::new(42, DrawMode::DrawOne);
|
||||
app.update();
|
||||
}
|
||||
|
||||
fn read_hud_text<M: Component>(app: &mut App) -> String {
|
||||
app.world_mut()
|
||||
.query_filtered::<&Text, With<M>>()
|
||||
.iter(app.world())
|
||||
.next()
|
||||
.map(|t| t.0.clone())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn score_reflects_game_state() {
|
||||
let mut app = headless_app();
|
||||
app.world_mut().resource_mut::<GameStateResource>().0.score = 750;
|
||||
app.update();
|
||||
assert_eq!(read_hud_text::<HudScore>(&mut app), "Score: 750");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn moves_reflects_game_state() {
|
||||
let mut app = headless_app();
|
||||
app.world_mut().resource_mut::<GameStateResource>().0.move_count = 42;
|
||||
app.update();
|
||||
assert_eq!(read_hud_text::<HudMoves>(&mut app), "Moves: 42");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn draw_three_mode_shows_draw_3_badge() {
|
||||
use solitaire_core::game_state::GameMode;
|
||||
let mut app = headless_app();
|
||||
app.world_mut().resource_mut::<GameStateResource>().0 =
|
||||
GameState::new_with_mode(42, DrawMode::DrawThree, GameMode::Classic);
|
||||
app.update();
|
||||
assert_eq!(read_hud_text::<HudMode>(&mut app), "Draw 3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zen_mode_hides_score() {
|
||||
use solitaire_core::game_state::GameMode;
|
||||
let mut app = headless_app();
|
||||
app.world_mut().resource_mut::<GameStateResource>().0 =
|
||||
GameState::new_with_mode(42, DrawMode::DrawOne, GameMode::Zen);
|
||||
app.world_mut().resource_mut::<GameStateResource>().0.score = 999;
|
||||
app.update();
|
||||
// Zen mode spec: "No score display" → text must be empty.
|
||||
assert_eq!(read_hud_text::<HudScore>(&mut app), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn time_display_uses_mm_ss_format() {
|
||||
let mut app = headless_app();
|
||||
app.world_mut().resource_mut::<GameStateResource>().0.elapsed_seconds = 125;
|
||||
app.update();
|
||||
// 125 seconds = 2 minutes 5 seconds → "2:05"
|
||||
assert_eq!(read_hud_text::<HudTime>(&mut app), "2:05");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user