From 0e50f39f33079de81c5da473473383d6956ef575 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 24 Nov 2024 12:31:12 +0100 Subject: Add "dont snap" callback to prevent snapshot creation. Use it for Columbia simultaneous card selection states to prevent the "duplicate" snapshot when going from both player selecting to the remaining player only. --- tools/patchgame.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tools/patchgame.js') diff --git a/tools/patchgame.js b/tools/patchgame.js index c2b0802..1426a75 100755 --- a/tools/patchgame.js +++ b/tools/patchgame.js @@ -89,6 +89,16 @@ function is_valid_action(rules, state, role, action, arg) { return false } +function dont_snap(rules, state, old_active) { + if (state.state === "game_over") + return true + if (state.active === old_active) + return true + if (rules.dont_snap && rules.dont_snap(state)) + return true + return false +} + function patch_game(game_id, {validate_actions=true, save_snaps=true, delete_undo=false, delete_invalid=false}, verbose) { let game = select_game.get(game_id) if (!game) { @@ -142,7 +152,7 @@ function patch_game(game_id, {validate_actions=true, save_snaps=true, delete_und item.state = snapshot(state) item.checksum = crc32c(item.state) - if (old_active !== state.active) + if (!dont_snap(rules, state, old_active)) item.save = 1 old_active = state.active -- cgit v1.2.3