diff options
-rw-r--r-- | public/common/play.js | 22 | ||||
-rw-r--r-- | server.js | 4 |
2 files changed, 13 insertions, 13 deletions
diff --git a/public/common/play.js b/public/common/play.js index 9432be4..aeb30b9 100644 --- a/public/common/play.js +++ b/public/common/play.js @@ -646,8 +646,9 @@ async function init_replay() { try { eval_action(replay[p]); } catch (err) { - console.log("ERROR IN REPLAY", p, replay[p], s.state, s.automatic_disruption); - replay.length = p; + console.log("ERROR IN REPLAY %d %s %s/%s/%s", p, s.state, replay[p].role, replay[p].action, replay[p].arguments); + console.log(err); + replay.length = 0; break; } @@ -773,17 +774,18 @@ async function init_replay() { update_replay_view(); } + let div = document.createElement("div"); + div.className = "replay"; + if (replay.length > 0) + text_button(div, "Active", () => set_viewpoint("Active")); + for (let r of roles) + text_button(div, r.role, () => set_viewpoint(r.role)); + text_button(div, "Observer", () => set_viewpoint("Observer")); + document.querySelector("header").appendChild(div); + if (replay.length > 0) { console.log("REPLAY READY"); - let div = document.createElement("div"); - div.className = "replay"; - text_button(div, "Active", () => set_viewpoint("Active")); - for (let r of roles) - text_button(div, r.role, () => set_viewpoint(r.role)); - text_button(div, "Observer", () => set_viewpoint("Observer")); - document.querySelector("header").appendChild(div); - div = document.createElement("div"); div.className = "replay"; text_button(div, "<<<", () => goto_replay(1)); @@ -1405,10 +1405,8 @@ app.get('/replay/:game_id', function (req, res) { if (game.status < 2) return res.status(404).send("Invalid game ID."); let players = SQL_SELECT_PLAYERS_JOIN.all(game_id); - let replay = SQL_SELECT_REPLAY.all(game_id); - if (replay.length > 0) - return res.json({players, replay}); let state = SQL_SELECT_GAME_STATE.get(game_id); + let replay = SQL_SELECT_REPLAY.all(game_id); return res.json({players, state, replay}); }); |