fix: Hex Wars - Mine Legende, Kopf nach Explosion auf altes Feld

This commit is contained in:
2026-06-28 14:53:42 +02:00
parent c543ea3401
commit 628272e762
2 changed files with 23 additions and 1 deletions

View File

@@ -321,6 +321,28 @@ router.post('/:id/move', authenticate, (req, res) => {
destroyedOwn = explosion.destroyedByOwner; destroyedOwn = explosion.destroyedByOwner;
destroyedOpp = explosion.destroyedByOpp; destroyedOpp = explosion.destroyedByOpp;
lastEvent = JSON.stringify({ type:'mine', player:me, row, col, blastCells, destroyedOwn, destroyedOpp }); 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 ──────────────────────── // ── Mine ins Sichtfeld gekommen: Explosion prüfen ────────────────────────

View File

@@ -375,7 +375,7 @@ function GameBoard({ game, myId, onMove, toast }) {
{/* Legende */} {/* Legende */}
<div style={{ display:'flex', gap:6, marginBottom:4, flexWrap:'wrap' }}> <div style={{ display:'flex', gap:6, marginBottom:4, flexWrap:'wrap' }}>
{[['⭐','Gold +3','#ffe66d'],['💣','Mine 3','#ff6b9d'],['🪨','Felsen','rgba(255,255,255,0.35)'],['🌫️','Nebel','rgba(255,255,255,0.25)']].map(([icon,label,color]) => ( {[['⭐','Gold +3','#ffe66d'],['💣','Mine 💥','#ff6b9d'],['🪨','Felsen','rgba(255,255,255,0.35)'],['🌫️','Nebel','rgba(255,255,255,0.25)']].map(([icon,label,color]) => (
<div key={label} style={{ display:'flex', alignItems:'center', gap:4 }}> <div key={label} style={{ display:'flex', alignItems:'center', gap:4 }}>
<span style={{ fontSize:12 }}>{icon}</span> <span style={{ fontSize:12 }}>{icon}</span>
<span style={{ color, fontFamily:'monospace', fontSize:10 }}>{label}</span> <span style={{ color, fontFamily:'monospace', fontSize:10 }}>{label}</span>