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:
@@ -22,7 +22,6 @@ use klondike::{
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::game_state::{DrawMode, GameMode};
|
||||
use crate::pile::PileType;
|
||||
|
||||
/// Bridges `solitaire_core` game config and scoring to the upstream `klondike` crate.
|
||||
///
|
||||
@@ -97,12 +96,12 @@ impl KlondikeAdapter {
|
||||
/// - Waste → Tableau: +5
|
||||
/// - Foundation → Tableau: −15
|
||||
/// - All other moves: 0
|
||||
pub fn score_for_move(&self, from: &PileType, to: &PileType) -> i32 {
|
||||
pub fn score_for_move(&self, from: &KlondikePile, to: &KlondikePile) -> i32 {
|
||||
let sc = &self.config.scoring;
|
||||
match (from, to) {
|
||||
(_, PileType::Foundation(_)) => sc.move_to_foundation,
|
||||
(PileType::Waste, PileType::Tableau(_)) => sc.move_to_tableau,
|
||||
(PileType::Foundation(_), PileType::Tableau(_)) => sc.move_from_foundation,
|
||||
(_, KlondikePile::Foundation(_)) => sc.move_to_foundation,
|
||||
(KlondikePile::Stock, KlondikePile::Tableau(_)) => sc.move_to_tableau,
|
||||
(KlondikePile::Foundation(_), KlondikePile::Tableau(_)) => sc.move_from_foundation,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
@@ -146,7 +145,12 @@ impl KlondikeAdapter {
|
||||
/// Score delta for a card move, accounting for game mode.
|
||||
///
|
||||
/// Returns 0 in [`GameMode::Zen`] (all scoring suppressed).
|
||||
pub fn score_for_move_with_mode(&self, from: &PileType, to: &PileType, mode: GameMode) -> i32 {
|
||||
pub fn score_for_move_with_mode(
|
||||
&self,
|
||||
from: &KlondikePile,
|
||||
to: &KlondikePile,
|
||||
mode: GameMode,
|
||||
) -> i32 {
|
||||
if mode == GameMode::Zen { 0 } else { self.score_for_move(from, to) }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user