-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b69dc0e
commit f02a8e3
Showing
6 changed files
with
76 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,55 @@ | ||
terminal.addCommand("highscore-admin", async function(args) { | ||
await terminal.modules.import("game", window) | ||
|
||
if (args.d) { | ||
if (args.delete) { | ||
localStorage.removeItem("highscore_password") | ||
HighscoreApi.tempPassword = null | ||
terminal.printLine("Removed password from local storage") | ||
return | ||
} else if (args.list) { | ||
await HighscoreApi.loginAdmin(true) | ||
const highscores = await HighscoreApi.getUnconfirmedHighscores() | ||
highscores.sort((a, b) => a.game.localeCompare(b.game)) | ||
|
||
terminal.printLine(`Showing ${highscores.length} Highscores...`) | ||
terminal.printTable(highscores.map(s => [ | ||
s.id, s.game, s.name, s.score, s.time | ||
]), ["id", "game", "name", "score", "time"]) | ||
} else if (args.tinder) { | ||
await HighscoreApi.loginAdmin(true) | ||
const highscores = await HighscoreApi.getUnconfirmedHighscores() | ||
highscores.sort((a, b) => a.game.localeCompare(b.game)) | ||
|
||
let i = 0 | ||
for (let s of highscores) { | ||
i++ | ||
|
||
terminal.printLine(`> Highscore #${i}/${highscores.length}:`) | ||
try { | ||
terminal.printTable([[ | ||
s.id, s.game, s.name, s.score, s.time | ||
]], ["id", "game", "name", "score", "time"]) | ||
await terminal.acceptPrompt("Looks good?") | ||
await HighscoreApi.confirmHighscore(s.uid, 1) | ||
terminal.addLineBreak() | ||
} catch { | ||
await HighscoreApi.confirmHighscore(s.uid, 2) | ||
terminal.printSuccess("Removed Highscore successfully") | ||
terminal.addLineBreak() | ||
} | ||
} | ||
|
||
terminal.printSuccess("You're finished!") | ||
} else { | ||
await HighscoreApi.loginAdmin() | ||
} | ||
await HighscoreApi.loginAdmin() | ||
|
||
}, { | ||
description: "Login as Admin", | ||
description: "Highscore Admin Management", | ||
isSecret: true, | ||
args: { | ||
"?d": "Delete password from local storage" | ||
"?l=list:b": "List all unconfirmed highscores", | ||
"?t=tinder:b": "Play Tinder Swiping with highscores", | ||
"?d=delete:b": "Delete password from local storage" | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters