refactor(core): unify Suit/Rank with card_game upstream types
Replace the parallel solitaire_core::Suit and solitaire_core::Rank
definitions with pub-use re-exports from card_game. card_game upstream
gained serde, is_black(), and value() to make this clean.
- card.rs: remove Suit/Rank enums and impls; add pub use card_game::{Suit,Rank}
- klondike_adapter.rs: remove From<card_game::Suit/Rank> bridges (now same type)
- Simplify card_from_kl: .into() calls become direct assignment
- Cargo.toml: switch to git deps (serde feature), Cargo.lock updated
All 62 solitaire_core tests pass; clippy clean.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -156,39 +156,6 @@ impl KlondikeAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Type-conversion utilities ─────────────────────────────────────────────
|
||||
|
||||
impl From<card_game::Suit> for card::Suit {
|
||||
fn from(s: card_game::Suit) -> Self {
|
||||
match s {
|
||||
card_game::Suit::Clubs => Self::Clubs,
|
||||
card_game::Suit::Diamonds => Self::Diamonds,
|
||||
card_game::Suit::Hearts => Self::Hearts,
|
||||
card_game::Suit::Spades => Self::Spades,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<card_game::Rank> for card::Rank {
|
||||
fn from(r: card_game::Rank) -> Self {
|
||||
match r {
|
||||
card_game::Rank::Ace => Self::Ace,
|
||||
card_game::Rank::Two => Self::Two,
|
||||
card_game::Rank::Three => Self::Three,
|
||||
card_game::Rank::Four => Self::Four,
|
||||
card_game::Rank::Five => Self::Five,
|
||||
card_game::Rank::Six => Self::Six,
|
||||
card_game::Rank::Seven => Self::Seven,
|
||||
card_game::Rank::Eight => Self::Eight,
|
||||
card_game::Rank::Nine => Self::Nine,
|
||||
card_game::Rank::Ten => Self::Ten,
|
||||
card_game::Rank::Jack => Self::Jack,
|
||||
card_game::Rank::Queen => Self::Queen,
|
||||
card_game::Rank::King => Self::King,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert a zero-based tableau index (0..=6) into [`Tableau`].
|
||||
pub fn tableau_from_index(index: usize) -> Option<Tableau> {
|
||||
match index {
|
||||
@@ -239,8 +206,8 @@ pub fn skip_cards_from_count(skip: usize) -> Option<SkipCards> {
|
||||
///
|
||||
/// The id is consistent for the same logical card across all reconstructions.
|
||||
pub fn card_from_kl(kl_card: &KlCard) -> card::Card {
|
||||
let suit: card::Suit = kl_card.suit().into();
|
||||
let rank: card::Rank = kl_card.rank().into();
|
||||
let suit = kl_card.suit();
|
||||
let rank = kl_card.rank();
|
||||
let suit_index = match suit {
|
||||
card::Suit::Clubs => 0,
|
||||
card::Suit::Diamonds => 1,
|
||||
|
||||
Reference in New Issue
Block a user