refactor: replace local DrawMode with upstream klondike::DrawStockConfig (#82)

DrawMode was a 1:1 mirror of klondike::DrawStockConfig (DrawOne/DrawThree).
Delete it and use the upstream type everywhere; re-export DrawStockConfig from
solitaire_core. config_for assigns draw_stock directly and draw_mode() returns
session.config().inner.draw_stock.

Serde is unchanged — DrawStockConfig serialises to the same "DrawOne"/"DrawThree"
named variants, so persisted game_state.json / replay JSON stay byte-compatible
(no migration). Field/method/variable names containing draw_mode are unchanged.

35 files, mechanical type swap across all crates. Implemented via a multi-agent
workflow (core → per-crate consumers → verify). cargo test --workspace and
clippy --workspace --all-targets -- -D warnings green.

Closes #82

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
funman300
2026-06-11 16:01:11 -07:00
parent d045781119
commit 5c992cbdca
35 changed files with 257 additions and 274 deletions
+8 -8
View File
@@ -279,7 +279,7 @@ fn cleanup_tmp_files_in(dir: &Path) {
mod tests {
use super::*;
use crate::stats::{StatsExt, StatsSnapshot};
use solitaire_core::DrawMode;
use solitaire_core::DrawStockConfig;
use std::env;
fn tmp_path(name: &str) -> PathBuf {
@@ -292,7 +292,7 @@ mod tests {
let _ = fs::remove_file(&path);
let mut stats = StatsSnapshot::default();
stats.update_on_win(1000, 180, &DrawMode::DrawOne);
stats.update_on_win(1000, 180, &DrawStockConfig::DrawOne);
save_stats_to(&path, &stats).expect("save");
let loaded = load_stats_from(&path);
@@ -381,7 +381,7 @@ mod tests {
let path = gs_path("round_trip");
let _ = fs::remove_file(&path);
let gs = GameState::new(12345, DrawMode::DrawOne);
let gs = GameState::new(12345, DrawStockConfig::DrawOne);
save_game_state_to(&path, &gs).expect("save");
let loaded = load_game_state_from(&path).expect("load");
@@ -410,7 +410,7 @@ mod tests {
let path = gs_path("won_skip");
let _ = fs::remove_file(&path);
let mut gs = GameState::new(99, DrawMode::DrawOne);
let mut gs = GameState::new(99, DrawStockConfig::DrawOne);
gs.set_test_won(true);
save_game_state_to(&path, &gs).expect("save should be no-op, not error");
assert!(
@@ -423,7 +423,7 @@ mod tests {
fn delete_game_state_removes_file() {
use solitaire_core::game_state::GameState;
let path = gs_path("delete");
let gs = GameState::new(1, DrawMode::DrawOne);
let gs = GameState::new(1, DrawStockConfig::DrawOne);
save_game_state_to(&path, &gs).expect("save");
assert!(path.exists());
delete_game_state_at(&path).expect("delete");
@@ -441,7 +441,7 @@ mod tests {
fn save_game_state_is_atomic() {
use solitaire_core::game_state::GameState;
let path = gs_path("atomic");
let gs = GameState::new(55, DrawMode::DrawThree);
let gs = GameState::new(55, DrawStockConfig::DrawThree);
save_game_state_to(&path, &gs).expect("save");
let tmp = path.with_extension("json.tmp");
assert!(!tmp.exists(), ".tmp must be cleaned up after rename");
@@ -512,7 +512,7 @@ mod tests {
let path = gs_path("v4_mid_game");
let _ = fs::remove_file(&path);
let mut gs = GameState::new(42, DrawMode::DrawOne);
let mut gs = GameState::new(42, DrawStockConfig::DrawOne);
// Draw several times to populate the instruction history with
// RotateStock entries and expose waste cards for further moves.
@@ -619,7 +619,7 @@ mod tests {
.expect("schema v3 must be accepted and migrated to v4");
// The loaded game should match a fresh game that had one draw applied.
let mut expected = GameState::new(42, DrawMode::DrawOne);
let mut expected = GameState::new(42, DrawStockConfig::DrawOne);
expected.draw().expect("draw must succeed on a fresh game");
assert_eq!(loaded, expected, "migrated v3 game state must match equivalent v4 state");
}