feat: Schocken - Würfel bei Aufdecken sichtbar, Admin-Abbrechen

This commit is contained in:
2026-07-05 00:33:56 +02:00
parent 3e75333b6a
commit bd558ab34f
2 changed files with 75 additions and 5 deletions

View File

@@ -586,4 +586,19 @@ function getGame(id, requesterId) {
};
}
// ── Spiel abbrechen (Admin only, keine Punkte) ───────────────────────────────
router.post('/:id/cancel', authenticate, (req, res) => {
if (req.user?.role !== 'admin') return res.status(403).json({ error: 'Nur Admin' });
const game = db.prepare('SELECT * FROM schocken_games WHERE id=?').get(req.params.id);
if (!game) return res.status(404).json({ error: 'Nicht gefunden' });
if (game.status === 'finished') return res.status(400).json({ error: 'Spiel bereits beendet' });
db.prepare(`UPDATE schocken_games SET status='finished', phase_status='cancelled',
updated_at=datetime('now','localtime') WHERE id=?`).run(game.id);
const players = JSON.parse(game.players);
for (const p of players) {
sendPush(p.id, '🎲 Schocken', 'Das Spiel wurde vom Admin abgebrochen.');
}
res.json({ ok: true });
});
module.exports = router;