diff --git a/App/pages/klima-3d.php b/App/pages/klima-3d.php index 3baaac0..4aebea5 100644 --- a/App/pages/klima-3d.php +++ b/App/pages/klima-3d.php @@ -111,10 +111,13 @@ if ($html === false) { $bp = BASE_PATH; $baseTag = ''; $ctxJs = ''; +// Plattform-Live-Client: Heartbeat + Pause-Overlay + Spectator-Mode für ?view=teacher +$liveJs = ''; // -Tag direkt nach einfügen, damit relative Pfade aus /sims/klima/ heraus auflösen $html = preg_replace('//i', '' . "\n" . $baseTag, $html, 1); -// Session-Kontext vor -$html = str_replace('', $ctxJs . "\n", $html); +// Session-Kontext + Live-Client vor +$html = str_replace('', $ctxJs . "\n" . $liveJs . "\n", $html); +$html = str_replace('href="/schueler"', 'href="' . cockpit_href() . '"', $html); echo $html; diff --git a/App/sims/klima/game-3d.html b/App/sims/klima/game-3d.html index 4d1eed9..0b01fde 100644 --- a/App/sims/klima/game-3d.html +++ b/App/sims/klima/game-3d.html @@ -793,7 +793,7 @@ HEADER ============================================================ --> @@ -1544,6 +1544,34 @@ Object.assign(state, { pendingCitizenEvent: null, }); +// Live-State-Hook für Lehrer-Spectator (s. _inbox/klima/2026-05-05-0140-…). +// Plattform-`live-client.js` ruft das alle ~4 s und sendet den Snapshot +// an `/api/live`. Selbe Felder wie 2D plus drei 3D-spezifische Flags +// (variant, placing, tourismus) und Citizen-Event-Indikatoren. +window.GGS_LIVE_STATE = function () { + if (!state) return null; + return { + variant: '3d', + tick: state.tick, + year: (state.startYear || 2025) + (state.tick || 0), + level: state.difficulty || state.level || null, + phase: state.phase || null, + budget: Math.round(state.budget || 0), + population: Math.round(state.population || 0), + co2: Math.round(state.co2Ppm || 0), + temp: +(state.currentTemp || 0).toFixed(2), + floodedPct: Math.round(state.floodedPct || 0), + seaLevelCm: Math.round(state.seaLevelCm || 0), + speed: state.speed || 0, + measures: Array.isArray(state.actionLog) ? state.actionLog.filter(a=>a.action==='buy').length : 0, + levelWon: !!state.levelWon, + tourism: !!state.tourismMode, + hasShield: !!state.hasMountainShield, + hasBeach: !!state.hasSandBeach, + placing: typeof placementId !== 'undefined' && placementId !== null ? placementId : null, + }; +}; + /* ============================================================ UI HELPERS ============================================================ */ @@ -5704,6 +5732,11 @@ const GLOSSAR_DB_KNOWN = new Set([ 'klimawandel','kohlenstoffkreislauf','megawatt','methan','nachhaltigkeit', 'pariser-abkommen','permafrost','photovoltaik','ppm','treibhauseffekt', 'treibhausgas','wasserkraft','watt','windenergie', + // Klima-Sim-Begriffe (Migration 2026-05-02): 4 Aliasse + 14 Volleinträge + 'windpark','solaranlage','erneuerbar','kohlekraftwerk', + 'budget','strom','mangrove','klimafolgen','kuestenschutz', + 'wartung','tourismus','blackout','steuern','temperatur', + 'meeresspiegel','bevoelkerung','ueberflutung','co2_filter', ]); function resolveGlossarDbKey(key) { const aliased = KLIMA_TO_DB_KEY[key] || key;