diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-12-22 17:32:02 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-12-27 16:15:44 +0100 |
commit | 75566438c2ba942abf3849b724e318cfa050f1ad (patch) | |
tree | 84e99d5edb1a8ff3e447a2507706a7759ad88a50 /public | |
parent | 3e9bc21e757fc13cc8d66cea1d5dcf813f27b4f0 (diff) | |
download | server-75566438c2ba942abf3849b724e318cfa050f1ad.tar.gz |
Move more player/game info stuff into SQL.
Update invite_count with triggers.
Add games.is_ready generated column.
Add games.is_opposed generated column.
Add player_view with is_active column.
Diffstat (limited to 'public')
-rw-r--r-- | public/join.js | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/public/join.js b/public/join.js index 6ae4deb..e0f6c3c 100644 --- a/public/join.js +++ b/public/join.js @@ -129,20 +129,12 @@ function is_enemy(p) { return blacklist && blacklist.includes(p.user_id) } -function is_active(player, role) { - return (game.active === role || game.active === "Both" || game.active === "All") -} - -function is_solo() { - return players.every(p => p.user_id === players[0].user_id) -} - function user_link(player) { return `<a class="black" href="/user/${player.name}">${player.name}</a>` } function play_link(player) { - return `\xbb <a href="/${game.title_id}/play.html?game=${game.game_id}&role=${encodeURIComponent(player.role)}">Play</a>` + return `\xbb <a href="/${game.title_id}/play.html?game=${game.game_id}&role=${encodeURIComponent(player.role)}">${player.name}</a>` } function action_link(player, action, color, text) { @@ -193,7 +185,7 @@ function update_no_login() { if (game.is_match) { if (player) { if (game.status === 1) - element.classList.toggle("is_active", is_active(player, role)) + element.classList.toggle("is_active", player.is_active) element.innerHTML = user_link(player) } else { element.innerHTML = `<i>Empty</i>` @@ -215,7 +207,7 @@ function update_no_login() { element.classList.add("is_invite") element.innerHTML = user_link(player) + " ?" } else { - element.classList.toggle("is_active", is_active(player, role)) + element.classList.toggle("is_active", player.is_active) element.innerHTML = user_link(player) } break @@ -248,7 +240,7 @@ function update_login() { if (game.is_match) { if (player) { if (game.status === 1) - element.classList.toggle("is_active", is_active(player, role)) + element.classList.toggle("is_active", player.is_active) if (player.user_id === user_id && (game.status === 1 || game.status === 2)) element.innerHTML = play_link(player) else @@ -283,7 +275,7 @@ function update_login() { else element.innerHTML = user_link(player) + " ?" } else { - element.classList.toggle("is_active", is_active(player, role)) + element.classList.toggle("is_active", player.is_active) if (player.user_id === user_id) element.innerHTML = play_link(player) + action_link(player, "part", "red", "\u274c") else if (game.owner_id === user_id) @@ -344,7 +336,7 @@ function update_login() { if (game.owner_id === user_id) { window.start_button.disabled = !ready window.start_button.classList = (game.status === 0) ? "" : "hide" - window.delete_button.classList = (game.status === 0 || is_solo()) ? "" : "hide" + window.delete_button.classList = (game.status === 0 || game.user_count <= 1) ? "" : "hide" if (game.status === 0 && ready) start_blinker("READY TO START") else |