Klima 3D: Live-State-Hook für Lehrer-Spectator
Atlas-Auftrag aus _inbox/klima/2026-05-05-0140 — analog zum 2D-Hook,
plus 3D-spezifische Felder.
- game-3d.html: window.GGS_LIVE_STATE liefert {variant:'3d', tick, year,
level, phase, budget, population, co2, temp, floodedPct, seaLevelCm,
speed, measures, levelWon, tourism, hasShield, hasBeach, placing}.
Aufruf alle ~4s durch live-client.js, gepostet an /api/live.
- klima-3d.php: Live-Client-Script-Tag nachgezogen (war nur in
klima-2d.php). Wird wie üblich vor </body> injiziert.
Heartbeat → DB live_sessions, Lehrer-Cockpit zeigt Karten an mit
Live-Kennzahlen.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -111,10 +111,13 @@ if ($html === false) {
|
||||
$bp = BASE_PATH;
|
||||
$baseTag = '<base href="' . htmlspecialchars($bp . '/sims/klima/', ENT_QUOTES) . '">';
|
||||
$ctxJs = '<script>window.__GGS__ = ' . json_encode($ctx, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . ';</script>';
|
||||
// Plattform-Live-Client: Heartbeat + Pause-Overlay + Spectator-Mode für ?view=teacher
|
||||
$liveJs = '<script src="' . htmlspecialchars($bp . '/assets/js/live-client.js', ENT_QUOTES) . '" defer></script>';
|
||||
|
||||
// <base>-Tag direkt nach <head> einfügen, damit relative Pfade aus /sims/klima/ heraus auflösen
|
||||
$html = preg_replace('/<head>/i', '<head>' . "\n" . $baseTag, $html, 1);
|
||||
// Session-Kontext vor </body>
|
||||
$html = str_replace('</body>', $ctxJs . "\n</body>", $html);
|
||||
// Session-Kontext + Live-Client vor </body>
|
||||
$html = str_replace('</body>', $ctxJs . "\n" . $liveJs . "\n</body>", $html);
|
||||
$html = str_replace('href="/schueler"', 'href="' . cockpit_href() . '"', $html);
|
||||
|
||||
echo $html;
|
||||
|
||||
Reference in New Issue
Block a user