This commit is contained in:
biglyderv 2025-01-02 22:00:28 -05:00
parent c603bc8755
commit 9c2deb3dcb
2 changed files with 24 additions and 22 deletions

44
game.js
View file

@ -20,7 +20,7 @@ class Game extends GameBasic {
}
async updateLeaderboard() {
let jason = await db.all('SELECT * FROM stats ORDER BY CAST(ko AS REAL) DESC LIMIT 1000');
let scoresOld = this.scores || [];
let scores = {};
@ -38,7 +38,7 @@ class Game extends GameBasic {
let s = Object.entries(scores).sort((a, b) => b[1] - a[1]).filter(a => a[1] > 5);
for (let x in s) {
let jk = jason.filter(y => y.ip == s[x][0]).map(y => y.ko).sort((a,b) => b - a);
let jk = jason.filter(y => y.ip == s[x][0]).map(y => y.ko).sort((a, b) => b - a);
s[x].push(jk.join(', '));
}
@ -46,7 +46,7 @@ class Game extends GameBasic {
this.scores = s;
s = [...s];
s.length = Math.min(s.length,10);
s.length = Math.min(s.length, 10);
let message = [];
@ -119,7 +119,7 @@ class Game extends GameBasic {
basic[posn] = sround(posp);
}
}
let str = JSON.stringify(basic,null);
let str = JSON.stringify(basic, null);
entList.push({ entity, str, basic });
}
@ -221,31 +221,33 @@ class Game extends GameBasic {
async authUser(ws, data) {
ws.token = data;
let f = new FormData();
f.append('token', ws.token);
let j = await fetch("https://bg.dervland.net/api/form/auth_api/",
{
"method": "post",
"body": f
}
);
j = await j.text();
let j = false;
try {
j = JSON.parse(j);
j = await fetch("https://nbg.dervland.net/auth.php",
{
"method": "get",
"headers": {
"cookie": `token=${data}`
}
}
);
j = await j.text();
} catch (err) {
j = {};
j = false;
}
if (j.username == '!nobody' || !j.username) return;
j = j.replaceAll(/\s+/g,'');
if (this.ws.findIndex(x => x.username == j.username && x.ent.health > 0) != -1) {
console.log(`Player ${ws.ent.you} uses username ${j.username} illegally`)
if (!j || j == '') return;
if (this.ws.findIndex(x => x.username == j && x.ent.health > 0) != -1) {
console.log(`Player ${ws.ent.you} uses username ${j} illegally`)
return;
}
ws.ent.username = ws.username = j.username;
ws.ent.username = ws.username = j;
console.log(`Player ${ws.ent.you} uses username ${ws.username}`)
}

View file

@ -12,7 +12,7 @@
<p>The <b>left mouse button</b> is the only input. No keyboard, moving the mouse, or anything else.</p>
<p>Click to launch... figure out the rest of the combos yourself.</p>
<a class='button' href='https://dervland.net/'>Created by 08draven</a>
<a class='button' href='https://bg.dervland.net/client/login?redirect=https://ub.dervland.net/'>Log in</a>
<a class='button' href='https://nbg.dervland.net/login.php?next=https://ub.dervland.net/'>Log in</a>
<canvas id='canvas'></canvas>
</div>
</section>