From ae02f4cde98879b6fddc12c87c4fd3c5663d493e Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 14 Jun 2022 20:39:02 +0200 Subject: Add debug mode for super-user. Like replay but for live games. Shows available actions. Doesn't remove undo actions. --- server.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'server.js') diff --git a/server.js b/server.js index f85935d..0f7470e 100644 --- a/server.js +++ b/server.js @@ -1513,6 +1513,19 @@ app.get('/:title_id/replay\::game_id', function (req, res) { return res.sendFile(__dirname + '/public/' + title_id + '/play.html') }) +app.get('/:title_id/debug\::game_id', function (req, res) { + if (!req.user || req.user.user_id !== 1) + return res.status(401).send("Not authorized to debug.") + let title_id = req.params.title_id + let game_id = req.params.game_id + let game = SQL_SELECT_GAME.get(game_id) + if (!game) + return res.status(404).send("Invalid game ID.") + if (game.title_id !== title_id) + return res.status(404).send("Invalid game ID.") + return res.sendFile(__dirname + '/public/' + title_id + '/play.html') +}) + app.get('/replay/:game_id', function (req, res) { let game_id = req.params.game_id let game = SQL_SELECT_GAME.get(game_id) @@ -1524,6 +1537,16 @@ app.get('/replay/:game_id', function (req, res) { return res.json({players, state, replay}) }) +app.get('/debug/:game_id', function (req, res) { + if (!req.user || req.user.user_id !== 1) + return res.status(401).send("Not authorized to debug.") + let game_id = req.params.game_id + let players = SQL_SELECT_PLAYERS_JOIN.all(game_id) + let state = SQL_SELECT_GAME_STATE.get(game_id) + let replay = SQL_SELECT_REPLAY.all(game_id) + return res.json({players, state, replay}) +}) + /* * MAIL NOTIFICATIONS */ -- cgit v1.2.3