diff --git a/Cargo.lock b/Cargo.lock index 40df819..4e59e6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2083,11 +2083,12 @@ dependencies = [ [[package]] name = "card_game" -version = "0.4.0" -source = "git+https://git.aleshym.co/Quaternions/card_game?rev=99b49e62#99b49e629e2372962b082325503c33e20a458818" +version = "0.4.1" +source = "git+https://git.aleshym.co/Quaternions/card_game?rev=fb01881f#fb01881f629647eb649d044a63a145cc1da54599" dependencies = [ "arrayvec 0.7.6 (sparse+https://git.aleshym.co/api/packages/Quaternions/cargo/)", "serde", + "serde_derive", ] [[package]] @@ -4599,12 +4600,13 @@ dependencies = [ [[package]] name = "klondike" -version = "0.3.0" -source = "git+https://git.aleshym.co/Quaternions/card_game?rev=99b49e62#99b49e629e2372962b082325503c33e20a458818" +version = "0.4.0" +source = "git+https://git.aleshym.co/Quaternions/card_game?rev=fb01881f#fb01881f629647eb649d044a63a145cc1da54599" dependencies = [ "card_game", "rand 0.10.1", "serde", + "serde_derive", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e25c800..f33d476 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,8 +38,8 @@ solitaire_core = { path = "solitaire_core" } solitaire_sync = { path = "solitaire_sync" } solitaire_data = { path = "solitaire_data" } solitaire_engine = { path = "solitaire_engine" } -klondike = { git = "https://git.aleshym.co/Quaternions/card_game", rev = "99b49e62", features = ["serde"] } -card_game = { git = "https://git.aleshym.co/Quaternions/card_game", rev = "99b49e62", features = ["serde"] } +klondike = { git = "https://git.aleshym.co/Quaternions/card_game", rev = "fb01881f", features = ["serde"] } +card_game = { git = "https://git.aleshym.co/Quaternions/card_game", rev = "fb01881f", features = ["serde"] } # Bevy with `default-features = false` to avoid the unused # `bevy_audio → rodio + symphonia + cpal 0.15 + alsa 0.9` chain. diff --git a/solitaire_core/src/klondike_adapter.rs b/solitaire_core/src/klondike_adapter.rs index 3db8362..e364050 100644 --- a/solitaire_core/src/klondike_adapter.rs +++ b/solitaire_core/src/klondike_adapter.rs @@ -211,8 +211,9 @@ pub fn skip_cards_from_count(skip: usize) -> Option { // ── Legacy serde mirror types (kept for backward compatibility) ─────────────── // // These types were introduced when upstream `klondike` had no serde feature. -// At rev 99b49e62, upstream provides full serde support, and `GameState` -// serialises `saved_moves` directly as `Vec` (schema v4). +// Mainline `klondike` now provides full serde support (with a hand-written +// compact `KlondikeInstruction` impl), and `GameState` serialises +// `saved_moves` directly as `Vec` (schema v4). // // The mirror types are retained for three reasons: // 1. Schema v3 migration: `AnyInstruction` in `game_state.rs` uses diff --git a/solitaire_engine/src/feedback_anim_plugin.rs b/solitaire_engine/src/feedback_anim_plugin.rs index a168a28..20fb5f1 100644 --- a/solitaire_engine/src/feedback_anim_plugin.rs +++ b/solitaire_engine/src/feedback_anim_plugin.rs @@ -199,7 +199,7 @@ fn card_to_id(card: &Card) -> u32 { Suit::Hearts => 2, Suit::Spades => 3, }; - suit_index * 13 + (card.rank().value() as u32 - 1) + suit_index * 13 + (card.rank() as u32 - 1) } // --------------------------------------------------------------------------- diff --git a/solitaire_engine/src/radial_menu.rs b/solitaire_engine/src/radial_menu.rs index 0ba9827..131e190 100644 --- a/solitaire_engine/src/radial_menu.rs +++ b/solitaire_engine/src/radial_menu.rs @@ -361,7 +361,7 @@ fn pile_cards(game: &GameState, pile: &KlondikePile) -> Vec<(Card, bool)> { /// Maps a `card_game::Card` to a stable `u32` identity used by `CardEntity` /// and systems that still track cards by numeric ID. -/// Encoding: `suit_index * 13 + (rank.value() - 1)`, range 0..=51. +/// Encoding: `suit_index * 13 + (rank as u8 - 1)`, range 0..=51. fn card_to_id(card: &Card) -> u32 { use solitaire_core::card::Suit; let suit_index: u32 = match card.suit() { @@ -370,7 +370,7 @@ fn card_to_id(card: &Card) -> u32 { Suit::Hearts => 2, Suit::Spades => 3, }; - suit_index * 13 + (card.rank().value() as u32 - 1) + suit_index * 13 + (card.rank() as u32 - 1) } const fn foundations() -> [Foundation; 4] { diff --git a/solitaire_engine/src/theme/mod.rs b/solitaire_engine/src/theme/mod.rs index 877ed3b..86fde60 100644 --- a/solitaire_engine/src/theme/mod.rs +++ b/solitaire_engine/src/theme/mod.rs @@ -43,11 +43,11 @@ pub use registry::{ /// Hashable lookup key into [`CardTheme::faces`]. /// -/// Distinct from `solitaire_core::Card`: the core type carries an `id` -/// and a `face_up` flag that vary per deal, neither of which is -/// relevant to image lookup. `CardKey` is just the (suit, rank) pair -/// that uniquely identifies which artwork to draw. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +/// Distinct from `card_game::Card`, which also encodes a deck id: `CardKey` +/// is just the (suit, rank) pair that uniquely identifies which artwork to +/// draw. Serialised theme manifests address faces by +/// [`CardKey::manifest_name`] strings, not by serialising `CardKey` itself. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct CardKey { pub suit: Suit, pub rank: Rank, diff --git a/solitaire_wasm/src/lib.rs b/solitaire_wasm/src/lib.rs index 70d895b..f6a814e 100644 --- a/solitaire_wasm/src/lib.rs +++ b/solitaire_wasm/src/lib.rs @@ -97,7 +97,7 @@ fn card_to_id(card: &solitaire_core::card::Card) -> u32 { Suit::Hearts => 2, Suit::Spades => 3, }; - suit_index * 13 + (card.rank().value() as u32 - 1) + suit_index * 13 + (card.rank() as u32 - 1) } impl From<&(solitaire_core::card::Card, bool)> for CardSnapshot { @@ -110,7 +110,7 @@ impl From<&(solitaire_core::card::Card, bool)> for CardSnapshot { Suit::Hearts => "hearts", Suit::Spades => "spades", }, - rank: card.rank().value(), + rank: card.rank() as u8, face_up: *face_up, } }