Files
plugins/gitadora@asphyxia/webui/leaderboards.pug
2026-10-29 03:25:31 +08:00

139 lines
4.1 KiB
Plaintext

//DATA//
infos: DB.Find(null, { collection: 'playerinfo' })
profiles: DB.Find(null, { collection: 'profile' })
-
-
function getFullGameName(shortName) {
switch (shortName) {
case "dm" :
return "DrumMania"
case "gf":
return "GuitarFreaks"
default:
return "Unknown"
}
}
function getFullGameVersion(shortVer) {
switch (shortVer) {
case "re" :
return "Tri-Boost Re:EVOLVE"
case "matixx":
return "Matixx"
case "exchain":
return "EXCHAIN"
case "nextage":
return "NEX+AGE"
case "highvoltage":
return "HIGH-VOLTAGE"
case "fuzzup":
return "FUZZ-UP"
case "galaxywave":
return "GALAXY WAVE"
case "galaxywave_delta":
return "GALAXY WAVE DELTA"
default:
return "Unknown"
}
}
const versions = ["re", "matixx", "exchain", "nextage", "highvoltage", "fuzzup", "galaxywave", "galaxywave_delta"]
const games = ["gf", "dm"]
function generateLeaderboard(infos, profiles, version, game) {
let entries = []
let idx = 1
let currentProfiles = profiles.filter((e) => e.game === game && e.version === version)
currentProfiles = currentProfiles.sort((a, b) => b.skill - a.skill)
for (const profile of currentProfiles) {
const info = infos.find(i => i.__refid === profile.__refid)
const name = info ? info.name : "Unknown"
const scoreData = {
rank: idx,
name: name,
skill: profile.skill / 100,
all_skill: profile.all_skill / 100,
clear_music_num : profile.clear_music_num,
clear_diff: profile.clear_diff / 100
}
entries.push(scoreData)
idx++
}
return {
version: version,
game: game,
entries: entries
}
}
// Group leaderboards by version first, then by game (GuitarFreaks / DrumMania) within each version.
// Versions/games with no entries are omitted entirely.
function generateLeaderboardsByVersion(infos, profiles) {
let result = []
for (const version of versions) {
let gameBoards = []
for (const game of games) {
const board = generateLeaderboard(infos, profiles, version, game)
if (board.entries.length > 0) gameBoards.push(board)
}
if (gameBoards.length > 0) {
result.push({ version, games: gameBoards })
}
}
return result
}
-
const versionGroups = generateLeaderboardsByVersion(infos, profiles)
mixin leaderboardTable(entries)
table
tr
th Rank
th Name
th Skill
th All Skill
th Songs Cleared
th Hardest Clear
each e in entries
tr
td #{e.rank}
td #{e.name}
td #{e.skill}
td #{e.all_skill}
td #{e.clear_music_num}
td #{e.clear_diff}
link(rel="stylesheet", href="static/css/webui_util.css", type="text/css")
script(src = "static/js/webui_util.js")
if versionGroups.length == 0
p.has-text-grey No leaderboard data available yet.
else
.tabs.is-toggle.is-toggle-rounded.is-small#tabs
ul
each vg, vIdx in versionGroups
li(tab-group="leaderboard-version", tab-index=vIdx, class=(vIdx == 0) ? "is-active" : "")
a #{getFullGameVersion(vg.version)}
each vg, vIdx in versionGroups
#tab-content(tab-group="leaderboard-version", tab-index=vIdx, class=(vIdx == 0) ? "is-active" : "")
if vg.games.length > 1
.tabs#tabs
ul
each board, gIdx in vg.games
li(tab-group=("leaderboard-game-" + vg.version), tab-index=gIdx, class=(gIdx == 0) ? "is-active" : "")
a #{getFullGameName(board.game)}
each board, gIdx in vg.games
#tab-content(tab-group=("leaderboard-game-" + vg.version), tab-index=gIdx, class=(gIdx == 0) ? "is-active" : "")
+leaderboardTable(board.entries)
else
each board in vg.games
h4 #{getFullGameName(board.game)}
+leaderboardTable(board.entries)