refactor(core): derive score/undo/recycle from upstream session stats

Replace the bespoke WXP scoring engine with the upstream
card_game/klondike session stats, eliminating duplicated state that
could drift from the single source of truth.

score()/undo_count()/recycle_count() now read session.stats(); the -15
undo penalty is configured as SessionConfig::undo_penalty and applied by
the upstream score formula. Save schema bumped v4 -> v5 (the three
counters are no longer persisted -- they are rebuilt by replaying the
forward instruction history on load).

- Remove GameState fields score, undo_count, recycle_count (#87)
- Remove score_history / is_recycle_history undo journal (#86)
- Remove KlondikeAdapter::apply_undo_score and the score_for_* helpers,
  plus pre_instruction_score_delta / will_flip_tableau_source (#84)

These three issues are a single atomic change: each removed field/helper
is consumed by the same draw/apply_instruction/undo/serde/PartialEq
paths, so they cannot compile or pass tests in isolation.

Behaviour changes (intentional): the escalating recycle penalty and
per-step score floor are gone (upstream linear scoring, floored once at
0); recycle_count is now cumulative; undo_count resets across save/load.

Refs #84, #86, #87

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
funman300
2026-06-11 10:36:31 -07:00
parent 9e3c6b06b0
commit 372b6423d8
10 changed files with 237 additions and 381 deletions
+4 -4
View File
@@ -184,7 +184,7 @@ impl ReplayPlayer {
StateSnapshot {
step_idx: self.step_idx,
total_steps: self.moves.len(),
score: self.game.score,
score: self.game.score(),
move_count: self.game.move_count(),
is_won: self.game.is_won(),
stock: self
@@ -487,12 +487,12 @@ impl SolitaireGame {
!stock_empty || !waste_empty || !self.game.possible_instructions().is_empty()
};
GameSnapshot {
score: self.game.score,
score: self.game.score(),
move_count: self.game.move_count(),
is_won: self.game.is_won(),
is_auto_completable: self.game.is_auto_completable(),
has_moves,
undo_count: self.game.undo_count,
undo_count: self.game.undo_count(),
undo_stack_len: self.game.undo_stack_len(),
stock: self
.game
@@ -1059,7 +1059,7 @@ mod tests {
draw_mode,
mode: GameMode::Classic,
time_seconds: 120,
final_score: game.game.score,
final_score: game.game.score(),
recorded_at,
moves: exported_moves,
};