From 4f123a7c8c8719491ddc4a497d37e99bb5dce549 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 10 Feb 2025 22:09:13 +0100 Subject: Support multi-active player states for 3p+ games. --- tools/patchgame.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/patchgame.js b/tools/patchgame.js index a28ce1f..bd719ba 100755 --- a/tools/patchgame.js +++ b/tools/patchgame.js @@ -74,7 +74,7 @@ function snapshot(state) { function is_valid_action(rules, state, role, action, arg) { if (action === "undo") // for jc, hots, r3, and cr compatibility return true - if (state.active !== role && state.active !== "Both") + if (state.active !== role && state.active !== "Both" && !state.active.includes(role)) return false let view = rules.view(state, role) let va = view.actions[action] @@ -90,7 +90,7 @@ function is_valid_action(rules, state, role, action, arg) { function dont_snap(rules, state, old_active) { if (state.state === "game_over") return true - if (state.active === old_active) + if (String(state.active) === String(old_active)) return true if (rules.dont_snap && rules.dont_snap(state)) return true @@ -219,7 +219,7 @@ function patch_game(game_id, {validate_actions=true, save_snaps=true, delete_und insert_snap.run(game_id, ++snap_id, item.replay_id, item.state) } - update_active.run(state.active, game_id) + update_active.run(String(state.active), game_id) update_state.run(JSON.stringify(state), game_id) if (state.state === "game_over") -- cgit v1.2.3