From 3322fd425059c76a7bf42c942af8c1290d7d0d52 Mon Sep 17 00:00:00 2001 From: funman300 Date: Tue, 19 May 2026 15:40:16 -0700 Subject: [PATCH] fix(wasm): enable take-from-foundation in web game client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GameState::new_with_mode defaults take_from_foundation=false (non- standard; the flag exists so the desktop can offer it as a setting). The WASM web client has no settings layer, so this flag was never flipped on — every drag or double-click from a foundation pile was silently rejected by the rules engine. Set take_from_foundation=true in both SolitaireGame::new (fresh games) and SolitaireGame::from_saved (restored games, which may have the old default serialised). Co-Authored-By: Claude Sonnet 4.6 --- solitaire_wasm/src/lib.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/solitaire_wasm/src/lib.rs b/solitaire_wasm/src/lib.rs index d89d96a..7cf436d 100644 --- a/solitaire_wasm/src/lib.rs +++ b/solitaire_wasm/src/lib.rs @@ -366,9 +366,10 @@ impl SolitaireGame { } else { DrawMode::DrawOne }; - SolitaireGame { - game: GameState::new_with_mode(seed as u64, dm, GameMode::Classic), - } + let mut game = GameState::new_with_mode(seed as u64, dm, GameMode::Classic); + // The web client has no settings layer; enable standard Klondike rule unconditionally. + game.take_from_foundation = true; + SolitaireGame { game } } /// Full pile snapshot as a JS object. @@ -437,7 +438,12 @@ impl SolitaireGame { /// that can't be deserialised (e.g. from a future schema version). pub fn from_saved(json: &str) -> Result { serde_json::from_str::(json) - .map(|game| SolitaireGame { game }) + .map(|mut game| { + // Older saves serialised with take_from_foundation=false (the core default). + // The web client has no settings layer, so enforce the standard rule here. + game.take_from_foundation = true; + SolitaireGame { game } + }) .map_err(|e| JsValue::from_str(&e.to_string())) }