feat(engine): add resources, events, and GamePlugin event routing

Introduces the plumbing layer for Phase 3: GameStateResource wraps
solitaire_core::GameState, DragState tracks in-progress drags, and
SyncStatusResource holds runtime sync status. GamePlugin routes
Draw/Move/Undo/NewGame request events into GameState and emits
StateChangedEvent and GameWonEvent for downstream systems.

Also adds the Phase 3 implementation plan under docs/superpowers/plans/.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
funman300
2026-04-23 16:15:38 -07:00
parent 3831fe691c
commit c393eab17d
8 changed files with 530 additions and 3 deletions
+43
View File
@@ -0,0 +1,43 @@
//! Cross-system events used by the engine's plugins.
use bevy::prelude::Event;
use solitaire_core::pile::PileType;
/// Request to move `count` cards from `from` to `to`. Fired by input systems,
/// consumed by `GamePlugin`.
#[derive(Event, Debug, Clone)]
pub struct MoveRequestEvent {
pub from: PileType,
pub to: PileType,
pub count: usize,
}
/// Request to draw from the stock (or recycle waste when stock is empty).
#[derive(Event, Debug, Clone, Copy, Default)]
pub struct DrawRequestEvent;
/// Request to undo the most recent state change.
#[derive(Event, Debug, Clone, Copy, Default)]
pub struct UndoRequestEvent;
/// Request to start a new game. `seed = None` uses a system-time seed.
#[derive(Event, Debug, Clone, Copy, Default)]
pub struct NewGameRequestEvent {
pub seed: Option<u64>,
}
/// Fired by `GamePlugin` after any successful state mutation. Rendering and
/// score-display systems listen for this to refresh.
#[derive(Event, Debug, Clone, Copy, Default)]
pub struct StateChangedEvent;
/// Fired once when the active game transitions to won.
#[derive(Event, Debug, Clone, Copy)]
pub struct GameWonEvent {
pub score: i32,
pub time_seconds: u64,
}
/// Fired when a card's face-up state changes during gameplay.
#[derive(Event, Debug, Clone, Copy)]
pub struct CardFlippedEvent(pub u32);