feat(server)!: websocket lobby, server-run matches, server economy, new schema (P1-2, P1-4, P2-1, P2-1b, P2-5)

Replaces the Firebase-style /db facade (rtdb, rules, nodes tree) with explicit REST endpoints and a
WebSocket hub. Login by name or optional e-mail, seed accounts via npm run db:reset.

BREAKING CHANGE: old clients (lobby/netfight over /db) no longer work against this server; database is new.
This commit is contained in:
Benjamin Oezcan
2026-11-19 01:52:30 +01:00
parent 46499e354b
commit dca1032ac4
20 changed files with 908 additions and 322 deletions

View File

@@ -47,6 +47,14 @@ class Room {
if (raw && Number.isInteger(raw.seq)) this.acks[seat] = raw.seq;
}
disconnect(seat) { if (!this.away[seat]) this.away[seat] = 1; }
// player gives up: his robot is knocked out at once
forfeit(seat) {
const s = this.s, r = s.robots[seat];
if (this.ended || !r || s.result) return;
r.hp = 0; r.dead = true;
s.result = { winner: 1 - seat, reason: 'ko' }; s.endIn = 0;
if (this.tickN <= COUNTDOWN) this.tickN = COUNTDOWN; // end now even during the countdown
}
reconnect(seat) { this.away[seat] = 0; this.ai[seat] = null; }
connected(seat) { return !this.away[seat]; }