fix: Schocken - Abbrechen löscht Spiel komplett
This commit is contained in:
@@ -586,15 +586,13 @@ function getGame(id, requesterId) {
|
||||
};
|
||||
}
|
||||
|
||||
// ── Spiel abbrechen (Admin only, keine Punkte) ───────────────────────────────
|
||||
// ── Spiel abbrechen (Admin only) — wird komplett gelöscht ───────────────────
|
||||
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);
|
||||
db.prepare('DELETE FROM schocken_games WHERE id=?').run(game.id);
|
||||
for (const p of players) {
|
||||
sendPush(p.id, '🎲 Schocken', 'Das Spiel wurde vom Admin abgebrochen.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user