summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-04-29 09:46:23 +0200
committerTor Andersson <tor@ccxvii.net>2024-05-04 23:38:50 +0200
commit25279f5d6bbe3a55451faaf1dc830d4a0795a665 (patch)
tree1a83b06ee3302fd247bdcf42985a3268535eb1d3
parent71e3087f5a8382a38b0780758b4b9b44230e8c98 (diff)
downloadserver-25279f5d6bbe3a55451faaf1dc830d4a0795a665.tar.gz
Show more detail in rewind links.
-rw-r--r--server.js3
-rw-r--r--views/join.pug7
2 files changed, 6 insertions, 4 deletions
diff --git a/server.js b/server.js
index e9baf8d..e13a227 100644
--- a/server.js
+++ b/server.js
@@ -1254,6 +1254,7 @@ const SQL_FINISH_GAME = SQL(`
`)
const SQL_REWIND_GAME = SQL("update games set status=1,moves=?,active=?,mtime=datetime() where game_id=?")
+const SQL_SELECT_REWIND = SQL("select snap_id, state->>'$.active' as active, state->>'$.state' as state from game_snap where game_id=? order by snap_id desc")
const SQL_UPDATE_GAME_ACTIVE = SQL("update games set active=?,mtime=datetime(),moves=moves+1 where game_id=?")
const SQL_UPDATE_GAME_MOVES = SQL("update games set moves=? where game_id=?")
@@ -1890,7 +1891,7 @@ app.get("/join/:game_id", function (req, res) {
if (game.owner_id === req.user.user_id)
friends = SQL_SELECT_CONTACT_FRIEND_NAMES.all(req.user.user_id)
if (req.user.user_id === 1)
- rewind = SQL_SELECT_SNAP_COUNT.get(game_id)
+ rewind = SQL_SELECT_REWIND.all(game_id)
}
let ready = (game.status === STATUS_OPEN) && is_game_ready(game.player_count, players)
diff --git a/views/join.pug b/views/join.pug
index c3960b7..96fb935 100644
--- a/views/join.pug
+++ b/views/join.pug
@@ -106,7 +106,8 @@ html
p <a href="/login">Login</a> or <a href="/signup">sign up</a> to play.
if user && user.user_id === 1
- p
- - for (let snap_id = rewind; snap_id > 0 && snap_id > rewind-5; --snap_id)
- a(href="/admin/rewind/" + game.game_id + "/" + snap_id) REWIND #{snap_id}
+ hr
+ div: p
+ each snap in rewind
+ <a href="/admin/rewind/#{game.game_id}/#{snap.snap_id}">REWIND #{snap.snap_id}</a> - #{snap.state} - #{snap.active}
br