Objekt-Anzahl stufenweise, Ban-CLI, Live-Abbruch bei privat

- Objekt-Anzahl waechst ab STEP_START zusaetzlich schrittweise (Deckel 100),
  Mindestgroesse leicht gesenkt fuer dichte Felder
- Ban per CLI: ban/unban/bans (namensbasiert), gebannte Namen koennen keinen Score
  eintragen (/api/score -> 403) und werden beim Bannen aus der Rangliste entfernt
- Privat-Modus bricht laufende Spiele ab: Client pollt /api/status und laedt neu,
  sobald Spielen auf dem Pfad nicht mehr erlaubt ist (geheimer Pfad wird nicht verraten)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Guido
2026-08-05 12:09:47 +02:00
parent 53cdfc7346
commit 8dbff16cec
4 changed files with 144 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ import { randomUUID } from 'node:crypto';
import { readLeaderboard, buildBoards, addScore } from './leaderboardStore.js';
import { getMode } from './modeStore.js';
import { isBanned } from './banStore.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = join(__dirname, '..');
@@ -117,6 +118,14 @@ app.post('/api/game/hit', (req, res) => {
res.json({ counted: true });
});
// Darf auf dem aktuellen Pfad gespielt werden? (Client sendet nur seinen Pfad-Slug,
// der geheime Pfad wird NICHT preisgegeben.) Dient zum Abbruch laufender Spiele.
app.get('/api/status', (req, res) => {
const m = getMode();
const slug = String(req.query.path || '').replace(/^\/+/, '');
res.json({ allowed: m.mode === 'public' || slug === m.path });
});
// Ranglisten: Allzeit-Top-5 + Heute-Top-10
app.get('/api/leaderboard', (req, res) => {
res.json(buildBoards(readLeaderboard()));
@@ -134,6 +143,7 @@ app.post('/api/score', (req, res) => {
const score = Math.max(0, Math.min(g.hits, maxByTime, ABS_CAP));
const cleanName = String(name || 'Anonym').trim().slice(0, 20) || 'Anonym';
if (isBanned(cleanName)) return res.status(403).json({ error: 'Name gesperrt.' });
res.json(addScore(cleanName, score));
});