fix: Hex Wars - Mine Legende, Kopf nach Explosion auf altes Feld
This commit is contained in:
@@ -321,6 +321,28 @@ router.post('/:id/move', authenticate, (req, res) => {
|
||||
destroyedOwn = explosion.destroyedByOwner;
|
||||
destroyedOpp = explosion.destroyedByOpp;
|
||||
lastEvent = JSON.stringify({ type:'mine', player:me, row, col, blastCells, destroyedOwn, destroyedOpp });
|
||||
|
||||
// Kopf zurücksetzen: Mine-Feld gehört dem Spieler, aber Kopf soll auf das letzte
|
||||
// noch existierende eigene Feld vor dem Mine-Zug zeigen.
|
||||
// Der alte Kopf (myHR, myHC) wird durch explodeMine nicht zerstört (Explosion trifft Nachbarn),
|
||||
// also ist er noch vorhanden — Kopf bleibt beim alten Kopf (vor dem Mine-Zug).
|
||||
// Falls kein alter Kopf bekannt: suche nächstes eigenes Feld neben der Mine.
|
||||
if (myHR !== null) {
|
||||
// Alten Kopf wiederherstellen — Mine-Feld selbst ist kein guter Ausgangspunkt
|
||||
if (game.owner_id === me) newOwnerHead = `${myHR},${myHC}`;
|
||||
else newOppHead = `${myHR},${myHC}`;
|
||||
} else {
|
||||
// Fallback: nächstes eigenes Feld neben der Mine suchen
|
||||
let fallbackHead = null;
|
||||
for (const [dr,dc] of DIRS8) {
|
||||
const nr=row+dr, nc=col+dc;
|
||||
if (nr>=0&&nr<GRID&&nc>=0&&nc<GRID&&grid[nr][nc]===me) { fallbackHead=`${nr},${nc}`; break; }
|
||||
}
|
||||
if (fallbackHead) {
|
||||
if (game.owner_id === me) newOwnerHead = fallbackHead;
|
||||
else newOppHead = fallbackHead;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Mine ins Sichtfeld gekommen: Explosion prüfen ────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user