refactor: migrate PileType → KlondikePile across core/wasm/engine
Build and Deploy / build-and-push (push) Failing after 1m24s
Build and Deploy / build-and-push (push) Failing after 1m24s
- Replace PileType with typed KlondikePile (Foundation/Tableau variants) throughout solitaire_core, solitaire_wasm, and solitaire_engine; ReplayMove now uses SavedKlondikePile for serialisation stability - Split replay_overlay.rs into replay_overlay/ module (mod, format, input, update, tests) for maintainability - Add klondike dep to solitaire_engine and solitaire_data Cargo.toml - Add TestPileState infrastructure to game_state.rs for engine unit tests - Rebuild solitaire_wasm pkg (js + wasm artefacts updated) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,9 +8,9 @@
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy::window::WindowResized;
|
||||
use klondike::{Foundation, KlondikePile, Tableau};
|
||||
use solitaire_core::card::Suit;
|
||||
use solitaire_core::game_state::{DrawMode, GameMode};
|
||||
use solitaire_core::pile::PileType;
|
||||
|
||||
use crate::auto_complete_plugin::AutoCompleteState;
|
||||
use crate::avatar_plugin::AvatarResource;
|
||||
@@ -2316,7 +2316,7 @@ fn update_hud(
|
||||
// Hide when not in Draw-Three or after the game is won.
|
||||
String::new()
|
||||
} else {
|
||||
let stock_len = g.piles[&solitaire_core::pile::PileType::Stock].cards.len();
|
||||
let stock_len = g.stock_cards().len();
|
||||
let next_draw = stock_len.min(3);
|
||||
format!("Cycle: {next_draw}/3")
|
||||
};
|
||||
@@ -2380,15 +2380,14 @@ fn update_selection_hud(
|
||||
let Ok(mut t) = q.single_mut() else { return };
|
||||
let label = match selection.as_deref().and_then(|s| s.selected_pile.as_ref()) {
|
||||
None => String::new(),
|
||||
Some(PileType::Waste) => "▶ Waste".to_string(),
|
||||
Some(PileType::Stock) => "▶ Stock".to_string(),
|
||||
Some(PileType::Foundation(slot)) => match game.as_deref() {
|
||||
Some(KlondikePile::Stock) => "▶ Waste".to_string(),
|
||||
Some(KlondikePile::Foundation(slot)) => match game.as_deref() {
|
||||
Some(g) => foundation_selection_label(*slot, &g.0),
|
||||
// No game resource means we can't probe claimed_suit; show the
|
||||
// slot-based placeholder so the HUD still surfaces the selection.
|
||||
None => format!("▶ Foundation {}", slot + 1),
|
||||
None => format!("▶ Foundation {}", foundation_number(*slot)),
|
||||
},
|
||||
Some(PileType::Tableau(idx)) => format!("▶ Column {}", idx + 1),
|
||||
Some(KlondikePile::Tableau(idx)) => format!("▶ Column {}", tableau_number(*idx)),
|
||||
};
|
||||
**t = label;
|
||||
}
|
||||
@@ -2398,11 +2397,11 @@ fn update_selection_hud(
|
||||
/// When the slot has a claimed suit (any card has landed) the announcement is
|
||||
/// "▶ {Suit} Foundation"; while the slot is empty it falls back to a
|
||||
/// "▶ Foundation N" placeholder labelled by the 1-based slot index.
|
||||
fn foundation_selection_label(slot: u8, game: &solitaire_core::game_state::GameState) -> String {
|
||||
fn foundation_selection_label(slot: Foundation, game: &solitaire_core::game_state::GameState) -> String {
|
||||
let claimed = game
|
||||
.piles
|
||||
.get(&PileType::Foundation(slot))
|
||||
.and_then(|p| p.claimed_suit());
|
||||
.pile(KlondikePile::Foundation(slot))
|
||||
.first()
|
||||
.map(|c| c.suit);
|
||||
match claimed {
|
||||
Some(suit) => {
|
||||
let s = match suit {
|
||||
@@ -2413,7 +2412,28 @@ fn foundation_selection_label(slot: u8, game: &solitaire_core::game_state::GameS
|
||||
};
|
||||
format!("▶ {s} Foundation")
|
||||
}
|
||||
None => format!("▶ Foundation {}", slot + 1),
|
||||
None => format!("▶ Foundation {}", foundation_number(slot)),
|
||||
}
|
||||
}
|
||||
|
||||
const fn foundation_number(foundation: Foundation) -> u8 {
|
||||
match foundation {
|
||||
Foundation::Foundation1 => 1,
|
||||
Foundation::Foundation2 => 2,
|
||||
Foundation::Foundation3 => 3,
|
||||
Foundation::Foundation4 => 4,
|
||||
}
|
||||
}
|
||||
|
||||
const fn tableau_number(tableau: Tableau) -> u8 {
|
||||
match tableau {
|
||||
Tableau::Tableau1 => 1,
|
||||
Tableau::Tableau2 => 2,
|
||||
Tableau::Tableau3 => 3,
|
||||
Tableau::Tableau4 => 4,
|
||||
Tableau::Tableau5 => 5,
|
||||
Tableau::Tableau6 => 6,
|
||||
Tableau::Tableau7 => 7,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user