From 8cd28cfb290ea33813b2f45184b8fdc044fb50db Mon Sep 17 00:00:00 2001 From: funman300 Date: Tue, 28 Apr 2026 17:36:23 +0000 Subject: [PATCH] feat(engine): right-click highlight timer and visual hint glow (#5, #6) Task #5: Add RightClickHighlightTimer(1.5 s) so destination highlights auto-despawn after 1.5 s. Existing clear-on-state-change and clear-on-pause logic still fires early when a move is made or the game is paused. Three unit tests cover timer countdown behaviour. Task #6: Add HintVisualEvent emitted on H key. Source card gets HintHighlight + HintHighlightTimer(2 s) for a yellow glow. Destination PileMarker gets HintPileHighlight with a gold tint (Color::srgb(1.0, 0.85, 0.1)) that restores the original colour when the 2 s timer expires. Five unit tests cover timer expiry and colour invariants. Co-Authored-By: Claude Sonnet 4.6 --- solitaire_engine/src/card_plugin.rs | 105 ++++++++++++++++++- solitaire_engine/src/events.rs | 13 +++ solitaire_engine/src/input_plugin.rs | 17 +++- solitaire_engine/src/lib.rs | 17 +++- solitaire_engine/src/table_plugin.rs | 146 ++++++++++++++++++++++++++- 5 files changed, 287 insertions(+), 11 deletions(-) diff --git a/solitaire_engine/src/card_plugin.rs b/solitaire_engine/src/card_plugin.rs index 046bd29..fce5e63 100644 --- a/solitaire_engine/src/card_plugin.rs +++ b/solitaire_engine/src/card_plugin.rs @@ -82,11 +82,28 @@ pub struct HintHighlight { pub remaining: f32, } +/// Countdown (seconds) until the `HintHighlight` on a card entity is removed. +/// +/// Inserted alongside `HintHighlight` by the hint-visual system. When the timer +/// reaches zero both `HintHighlight` and `HintHighlightTimer` are removed from +/// the entity and the sprite colour is restored. +#[derive(Component, Debug, Clone)] +pub struct HintHighlightTimer(pub f32); + /// Marker on a `PileMarker` entity that is highlighted because the right-clicked /// card can legally be placed there. #[derive(Component, Debug)] pub struct RightClickHighlight; +/// Countdown (seconds) until this right-click destination highlight despawns. +/// +/// Inserted alongside `RightClickHighlight` so that highlights auto-clear after +/// 1.5 s even if the player does not make a move or click again. The existing +/// clear-on-state-change and clear-on-pause logic still fires early when +/// appropriate. +#[derive(Component, Debug, Clone)] +pub struct RightClickHighlightTimer(pub f32); + /// Marker placed on the child `Text2d` entity that shows "↺" on the stock pile /// marker when the stock pile is empty. #[derive(Component, Debug)] @@ -154,6 +171,7 @@ impl Plugin for CardPlugin { update_drag_shadow, tick_hint_highlight, handle_right_click, + tick_right_click_highlights, clear_right_click_highlights_on_state_change.after(GameMutation), clear_right_click_highlights_on_pause, update_stock_empty_indicator.after(GameMutation), @@ -627,7 +645,8 @@ fn update_drag_shadow( // --------------------------------------------------------------------------- /// Counts down `HintHighlight::remaining` each frame. When it reaches zero, -/// removes the component and resets the card sprite to its normal face-up colour. +/// removes both `HintHighlight` and `HintHighlightTimer` (if present) and +/// resets the card sprite to its normal face-up colour. fn tick_hint_highlight( time: Res