From 8cc48b1bc653657b44b7d82f38568deb138c50d1 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 22 Aug 2026 17:17:33 +0200 Subject: [PATCH] Klima: Aktuell-Linien gruen->rot (CO2/Temp/Geflutet/Budget/Bev.) + "Nochmal spielen" setzt wirklich zurueck - teacher.html: LIVE_PRIMARY_FIELDS.klima Kennzahlen mit _liveBar-Ampel (absolute Skalen), _liveBar +Nachkomma-Param; tick-Spalte entfernt (redundant zu Jahr) - game-2d/3d: beendete Laeufe (phase=end) werden beim Resume verworfen -> "Nochmal spielen"/erneutes Oeffnen startet frisch statt im Endbildschirm Co-Authored-By: Claude Opus 4.8 --- App/sims/klima/game-2d.html | 5 ++++- App/sims/klima/game-3d.html | 3 +++ App/teacher.html | 17 +++++++++-------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/App/sims/klima/game-2d.html b/App/sims/klima/game-2d.html index 8820108..1d25e1b 100644 --- a/App/sims/klima/game-2d.html +++ b/App/sims/klima/game-2d.html @@ -1009,7 +1009,7 @@
- +
@@ -4148,6 +4148,9 @@ function tryResume() { try { const d = JSON.parse(raw); if (!d || !d.tick || d.tick <= 0) continue; + // Beendete Läufe nie wieder aufnehmen — sonst landet „Nochmal spielen" / + // erneutes Öffnen direkt im Endbildschirm. Alten Stand verwerfen. + if (d.phase === 'end') { localStorage.removeItem(SAVE_KEY_BASE + '-' + lvl); continue; } deserializeState(d); hideOverlay('level-select-overlay'); state.phase = (d.phase === 'citizen' ? 'playing' : d.phase) || 'playing'; diff --git a/App/sims/klima/game-3d.html b/App/sims/klima/game-3d.html index 291a8c4..ecac31f 100644 --- a/App/sims/klima/game-3d.html +++ b/App/sims/klima/game-3d.html @@ -5641,6 +5641,9 @@ function tryResume() { try { const d = JSON.parse(raw); if (!d || !d.tick || d.tick <= 0) continue; + // Beendete Läufe nie wieder aufnehmen — sonst landet erneutes Öffnen + // direkt im Endbildschirm. Alten Stand verwerfen. + if (d.phase === 'end') { localStorage.removeItem(SAVE_KEY_BASE + '-' + lvl); continue; } deserializeState(d); hideOverlay('level-select-overlay'); state.phase = (d.phase === 'citizen' ? 'playing' : d.phase) || 'playing'; diff --git a/App/teacher.html b/App/teacher.html index 53aab23..4cfb91d 100644 --- a/App/teacher.html +++ b/App/teacher.html @@ -614,7 +614,7 @@ function _fmtSeconds(s) { // goodWhen 'high' → grün ab >= 60% der Range, gelb ab >= 30%, sonst rot // goodWhen 'low' → invers (z. B. Fehlerzahl, idleMs) // goodWhen 'mid' → neutral grau (z. B. Progress) -function _liveBar(val, min, max, goodWhen) { +function _liveBar(val, min, max, goodWhen, dec) { if (val == null || isNaN(val)) return ''; var span = (max - min) || 1; var pct = Math.max(0, Math.min(100, ((val - min) / span) * 100)); @@ -626,12 +626,13 @@ function _liveBar(val, min, max, goodWhen) { } else { c = pct >= 60 ? '#5a8a5e' : pct >= 30 ? '#c9913a' : '#c07a6b'; } + var disp = (dec != null) ? Number(val).toFixed(dec) : Math.round(val); return '' + '' + '' - + ''+Math.round(val)+'' + + ''+disp+'' + ''; } @@ -732,13 +733,13 @@ var LIVE_PRIMARY_FIELDS = { ], klima: [ {k:'level', label:'Stufe'}, - {k:'tick', label:'Tick'}, {k:'year', label:'Jahr'}, - {k:'budget', label:'Budget', unit:'Mio €'}, - {k:'co2', label:'CO₂', unit:'ppm'}, - {k:'temp', label:'Temp', unit:'°C'}, - {k:'floodedPct', label:'Geflutet', fmt:function(v){ return _liveBar(v, 0, 100, 'low'); }}, - {k:'population', label:'Bev.'}, + // Kennzahlen mit Ampel-Linien (grün→rot), absolute Skalen wie im Spiel: + {k:'co2', label:'CO₂', unit:'ppm', fmt:function(v){ return _liveBar(v, 280, 700, 'low'); }}, + {k:'temp', label:'Temp', unit:'°C', fmt:function(v){ return _liveBar(v, 14, 20, 'low', 1); }}, + {k:'floodedPct', label:'Geflutet', unit:'%', fmt:function(v){ return _liveBar(v, 0, 100, 'low'); }}, + {k:'budget', label:'Budget', unit:'Mio €', fmt:function(v){ return _liveBar(v, -500, 3000, 'high'); }}, + {k:'population', label:'Bev.', fmt:function(v){ return _liveBar(v, 1500, 4500, 'high'); }}, {k:'measures', label:'Maßn.'}, {k:'speed', label:'Speed', unit:'×'}, ],