diff options
author | Tor Andersson <tor@ccxvii.net> | 2025-02-10 22:09:13 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2025-02-12 12:05:30 +0100 |
commit | 4f123a7c8c8719491ddc4a497d37e99bb5dce549 (patch) | |
tree | 3a97a6f60689468428d0169e80967bc82783bc06 /tools/patchgame.js | |
parent | b04c539731bac278eee8544a01c6413b88a088c7 (diff) | |
download | server-4f123a7c8c8719491ddc4a497d37e99bb5dce549.tar.gz |
Support multi-active player states for 3p+ games.
Diffstat (limited to 'tools/patchgame.js')
-rwxr-xr-x | tools/patchgame.js | 6 |
1 files changed, 3 insertions, 3 deletions
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") |