This commit is contained in:
cay 2026-04-14 10:14:51 +01:00
parent 0fdfda8b0a
commit a17a6c1414
3 changed files with 410 additions and 495 deletions

File diff suppressed because it is too large Load Diff

View File

@ -437,8 +437,9 @@ function registerHimmelstorHandlers(io, socket) {
const aiRoom = htAiRooms.get(matchId);
if (!aiRoom) return;
// Socket aktualisieren (nach Reconnect)
// Socket + Namen aktualisieren
aiRoom.playerSocketId = socket.id;
const myIngameName = data.playerName || 'Du';
const ioRoom = io._arenaRooms?.get(matchId);
if (ioRoom) ioRoom.sockets.player1 = socket.id;
@ -456,23 +457,27 @@ function registerHimmelstorHandlers(io, socket) {
// HP initialisieren
socket.emit('hp_init', { hp: aiRoom.hp, maxHp: aiRoom.maxHp });
// Spieler braucht "bereit" nicht direkt Zug starten
// (Wir simulieren ready_status so dass der Client den leftSlot setzt)
// ht_ai_setup: setzt links/rechts explizit ohne seed-basierten Flip
setTimeout(() => {
socket.emit('ready_status', {
readyCount: 2,
readySlots: ['player1', 'player2'],
socket.emit('ht_ai_setup', {
playerSlot : aiRoom.playerSlot, // 'player1'
leftSlot : aiRoom.leftSlot, // 'player1' (Spieler immer links)
playerName : myIngameName || 'Du',
aiName : GUARD_NAMES[aiRoom.station] || `Wächter ${aiRoom.station}`,
hp : aiRoom.hp,
maxHp : aiRoom.maxHp,
});
}, 200);
}, 250);
// Zug starten (nach Setup-Animation)
setTimeout(() => {
socket.emit('turn_change', {
activeSlot: aiRoom.playerSlot, // Spieler fängt an
activeSlot: aiRoom.playerSlot,
boardSync : [],
hp : aiRoom.hp,
maxHp : aiRoom.maxHp,
});
}, 600);
}, 700);
console.log(`[HT] arena_join KI-Match: ${matchId}`);
});

View File

@ -790,6 +790,7 @@ function registerArenaHandlers(io, socket) {
socket.on("start_turn_request", async (data) => {
const { matchId, starterSlot } = data;
if (!matchId || !starterSlot) return;
if (htAiMatchIds.has(matchId)) return; // KI-Match: turn wird von himmelstor.socket gestartet
if (!io._turnInit) io._turnInit = new Set();
if (io._turnInit.has(matchId)) return;
io._turnInit.add(matchId);