fix(wasm): enable take-from-foundation in web game client
Android Release / build-apk (push) Successful in 3m56s

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 <noreply@anthropic.com>
This commit is contained in:
funman300
2026-05-19 15:40:16 -07:00
parent 90eb5fd207
commit 3322fd4250
+10 -4
View File
@@ -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<SolitaireGame, JsValue> {
serde_json::from_str::<GameState>(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()))
}