feat(engine): surface upstream move-type counters and replay seek
Test / test (pull_request) Successful in 36m35s
Test / test (pull_request) Successful in 36m35s
Two unused-for-free upstream card_game/klondike features: - GameState now exposes the granular KlondikeStats counters (move_to_foundation_count, move_to_tableau_count, move_from_foundation_count, flip_up_count) and the win modal shows a quiet per-move-type recap line built from them (e.g. "21 to foundation - 14 tableau moves - 9 flips") - wasm ReplayPlayer gains seek(step): clamped jump to any position, rewinding via a stored copy of the recorded deal instead of reparsing the replay JSON; replay.js Prev now uses it Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -315,10 +315,9 @@ btnPlay.addEventListener("click", () => {
|
||||
}, STEP_INTERVAL_MS);
|
||||
});
|
||||
|
||||
/// Step the player back one move. Re-creates the ReplayPlayer and fast-
|
||||
/// forwards to (step_idx - 1) without rendering intermediate frames, then
|
||||
/// renders once so the CSS transition animates each card to its previous
|
||||
/// position.
|
||||
/// Step the player back one move via the wasm-side seek (rewinds to the
|
||||
/// recorded deal and fast-forwards internally), then renders once so the
|
||||
/// CSS transition animates each card to its previous position.
|
||||
function stepBack() {
|
||||
if (!player || player.step_idx() === 0) return;
|
||||
if (playInterval) {
|
||||
@@ -326,12 +325,7 @@ function stepBack() {
|
||||
playInterval = null;
|
||||
btnPlay.textContent = "▶ Play";
|
||||
}
|
||||
const target = player.step_idx() - 1;
|
||||
player = new ReplayPlayer(replayJson);
|
||||
for (let i = 0; i < target; i++) {
|
||||
player.step();
|
||||
}
|
||||
render(player.state());
|
||||
render(player.seek(player.step_idx() - 1));
|
||||
btnPrev.disabled = player.step_idx() === 0;
|
||||
btnRestart.disabled = player.step_idx() === 0;
|
||||
btnStep.disabled = false;
|
||||
|
||||
Reference in New Issue
Block a user