fix(wasm): enable take-from-foundation in web game client
Android Release / build-apk (push) Successful in 3m56s
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:
@@ -366,9 +366,10 @@ impl SolitaireGame {
|
|||||||
} else {
|
} else {
|
||||||
DrawMode::DrawOne
|
DrawMode::DrawOne
|
||||||
};
|
};
|
||||||
SolitaireGame {
|
let mut game = GameState::new_with_mode(seed as u64, dm, GameMode::Classic);
|
||||||
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.
|
/// 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).
|
/// that can't be deserialised (e.g. from a future schema version).
|
||||||
pub fn from_saved(json: &str) -> Result<SolitaireGame, JsValue> {
|
pub fn from_saved(json: &str) -> Result<SolitaireGame, JsValue> {
|
||||||
serde_json::from_str::<GameState>(json)
|
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()))
|
.map_err(|e| JsValue::from_str(&e.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user