1e51ef7def
- Konzept/, didaktik_geografie/, didaktik_simulation/, v2-modules/, v2-platform/ - 12 code-workspace-Files - STATUS-*.md - viele M/D/R-Änderungen an bereits getrackten Files - .gitignore verstärkt: **/.humaninput/, **/secret_keys.txt Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
291 lines
9.1 KiB
HTML
291 lines
9.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
|
<title>autobahn-game — Test</title>
|
|
<!--
|
|
Diese Test-Datei lädt three.min.js relativ aus ./three/three.min.js.
|
|
Bitte vor dem Öffnen folgende Datei platzieren:
|
|
./three/three.min.js (Three.js r128 oder kompatibel)
|
|
./autobahn-game.js (das Modul)
|
|
Kein CDN, kein Netzwerk-Call.
|
|
-->
|
|
<script src="./three/three.min.js"></script>
|
|
<script src="./autobahn-game.js"></script>
|
|
<style>
|
|
:root {
|
|
--bg: #f5f3ea;
|
|
--card: #efe9d8;
|
|
--border: #c8c1a8;
|
|
--primary: #2d6d4d;
|
|
--primary-hover: #245840;
|
|
--accent: #e8c547;
|
|
--text: #2a2a2a;
|
|
--muted: #6a6258;
|
|
}
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
margin: 0;
|
|
padding: 32px;
|
|
max-width: 880px;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
}
|
|
h1 {
|
|
color: var(--primary);
|
|
margin: 0 0 8px;
|
|
font-size: 26px;
|
|
}
|
|
p.lede {
|
|
color: var(--muted);
|
|
font-size: 14px;
|
|
margin: 0 0 24px;
|
|
line-height: 1.6;
|
|
}
|
|
.options {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 16px;
|
|
align-items: center;
|
|
margin-bottom: 16px;
|
|
padding: 14px 18px;
|
|
background: var(--card);
|
|
border: 1px solid var(--border);
|
|
border-radius: 10px;
|
|
}
|
|
.options label {
|
|
font-size: 13px;
|
|
color: var(--muted);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
cursor: pointer;
|
|
}
|
|
.scenario-buttons {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
|
gap: 10px;
|
|
margin-bottom: 24px;
|
|
}
|
|
.scenario-buttons button {
|
|
padding: 14px 16px;
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
border: 1.5px solid var(--primary);
|
|
background: var(--primary);
|
|
color: var(--bg);
|
|
border-radius: 8px;
|
|
font-family: inherit;
|
|
transition: background 0.12s, transform 0.06s;
|
|
}
|
|
.scenario-buttons button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
|
|
.scenario-buttons button:active { transform: scale(0.98); }
|
|
.result-box {
|
|
background: var(--card);
|
|
border: 1px solid var(--border);
|
|
border-radius: 10px;
|
|
padding: 16px;
|
|
min-height: 120px;
|
|
}
|
|
.result-box h2 {
|
|
font-size: 14px;
|
|
color: var(--muted);
|
|
margin: 0 0 8px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.6px;
|
|
font-weight: 700;
|
|
}
|
|
.result-box pre {
|
|
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
font-size: 13px;
|
|
margin: 0;
|
|
white-space: pre-wrap;
|
|
}
|
|
.result-row {
|
|
padding: 8px 0;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
.result-row:last-child { border-bottom: none; }
|
|
.badge {
|
|
display: inline-block;
|
|
padding: 2px 10px;
|
|
border-radius: 10px;
|
|
font-size: 12px;
|
|
font-weight: 700;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.4px;
|
|
margin-right: 8px;
|
|
}
|
|
.badge-success { background: var(--primary); color: var(--bg); }
|
|
.badge-late { background: var(--accent); color: #2a2a2a; }
|
|
.badge-crash { background: #b03a3a; color: white; }
|
|
.game-overlay {
|
|
position: fixed;
|
|
inset: 0;
|
|
background: rgba(20, 30, 25, 0.55);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
z-index: 9999;
|
|
padding: 24px;
|
|
}
|
|
.game-modal {
|
|
background: var(--bg);
|
|
border-radius: 14px;
|
|
width: 100%;
|
|
max-width: 1100px;
|
|
max-height: 90dvh;
|
|
box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
|
|
overflow: hidden;
|
|
}
|
|
.nodes-info {
|
|
margin-top: 24px;
|
|
font-size: 13px;
|
|
color: var(--muted);
|
|
}
|
|
.nodes-info summary { cursor: pointer; font-weight: 600; }
|
|
.nodes-info pre { background: var(--card); padding: 10px; border-radius: 6px; }
|
|
.three-warn {
|
|
background: #f8e3e3;
|
|
border: 1px solid #b03a3a;
|
|
color: #5a1a1a;
|
|
padding: 12px 16px;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
margin-bottom: 16px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>autobahn-game — Modul-Test</h1>
|
|
<p class="lede">
|
|
Standalone-Demo des Moduls <code>window.lgAutobahnGame</code>.
|
|
Wähle ein Szenario, das Spiel öffnet sich in einem Modal-Overlay.
|
|
Nach Spielende wird das <code>result</code>-Objekt unten und in der Konsole ausgegeben.
|
|
</p>
|
|
|
|
<div id="three-warn" class="three-warn" style="display:none;">
|
|
<strong>Hinweis:</strong> <code>window.THREE</code> wurde nicht geladen.
|
|
Bitte <code>three.min.js</code> unter <code>./three/three.min.js</code> ablegen
|
|
(Three.js r128 oder kompatibel) und Seite neu laden.
|
|
</div>
|
|
|
|
<div class="options">
|
|
<label>
|
|
<input type="checkbox" id="opt-easy" />
|
|
<span>Easy-Mode (langsameres Tempo)</span>
|
|
</label>
|
|
<label>
|
|
Fahrer:
|
|
<input type="text" id="opt-driver" value="Anna" style="padding: 4px 8px; font-size: 13px; border: 1px solid var(--border); border-radius: 4px; font-family: inherit;" />
|
|
</label>
|
|
</div>
|
|
|
|
<div class="scenario-buttons" id="buttons"></div>
|
|
|
|
<div class="result-box">
|
|
<h2>Letztes Ergebnis</h2>
|
|
<div id="result-display"><em style="color: var(--muted);">Noch kein Spiel gespielt.</em></div>
|
|
</div>
|
|
|
|
<details class="nodes-info">
|
|
<summary>Knotenpunkt-Geokoordinaten (NODES-Export)</summary>
|
|
<pre id="nodes-output">…</pre>
|
|
</details>
|
|
|
|
<script>
|
|
(function () {
|
|
'use strict';
|
|
|
|
if (!window.THREE) {
|
|
document.getElementById('three-warn').style.display = 'block';
|
|
}
|
|
if (!window.lgAutobahnGame) {
|
|
document.body.insertAdjacentHTML('afterbegin',
|
|
'<div style="background:#f8e3e3;padding:16px;color:#5a1a1a;border-radius:8px;margin-bottom:16px;">' +
|
|
'<strong>Fehler:</strong> <code>window.lgAutobahnGame</code> nicht gefunden. ' +
|
|
'Bitte <code>autobahn-game.js</code> neben dieser Datei platzieren.</div>'
|
|
);
|
|
return;
|
|
}
|
|
|
|
const SCENARIO_LABELS = {
|
|
bregenz: 'Bregenz',
|
|
salzburg: 'Salzburg-West',
|
|
innsbruck: 'Innsbruck',
|
|
muenchen: 'München-Nord',
|
|
leipzig: 'Leipzig-West',
|
|
verona: 'Verona Nord'
|
|
};
|
|
|
|
const buttonsContainer = document.getElementById('buttons');
|
|
Object.keys(SCENARIO_LABELS).forEach(key => {
|
|
const btn = document.createElement('button');
|
|
btn.textContent = SCENARIO_LABELS[key];
|
|
btn.dataset.scenario = key;
|
|
btn.addEventListener('click', () => runScenario(key));
|
|
buttonsContainer.appendChild(btn);
|
|
});
|
|
|
|
function runScenario(scenario) {
|
|
if (!window.THREE) {
|
|
alert('Three.js fehlt. Siehe Hinweis oben auf der Seite.');
|
|
return;
|
|
}
|
|
|
|
const overlay = document.createElement('div');
|
|
overlay.className = 'game-overlay';
|
|
const modal = document.createElement('div');
|
|
modal.className = 'game-modal';
|
|
overlay.appendChild(modal);
|
|
document.body.appendChild(overlay);
|
|
|
|
const easy = document.getElementById('opt-easy').checked;
|
|
const driver = document.getElementById('opt-driver').value || '';
|
|
|
|
try {
|
|
window.lgAutobahnGame.start({
|
|
container: modal,
|
|
scenario: scenario,
|
|
driverName: driver,
|
|
truckLabel: 'Test-LKW',
|
|
easyMode: easy,
|
|
onEnd: (result) => {
|
|
console.log('lgAutobahnGame onEnd →', result);
|
|
renderResult(result);
|
|
if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
|
|
}
|
|
});
|
|
} catch (err) {
|
|
console.error('lgAutobahnGame.start ist fehlgeschlagen:', err);
|
|
if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
|
|
alert('Fehler beim Starten: ' + err.message);
|
|
}
|
|
}
|
|
|
|
function renderResult(result) {
|
|
const display = document.getElementById('result-display');
|
|
const badgeClass = 'badge-' + result.outcome;
|
|
const lines = [
|
|
'<div class="result-row"><span class="badge ' + badgeClass + '">' + result.outcome + '</span>' +
|
|
'Szenario: <strong>' + result.scenario + '</strong></div>',
|
|
'<div class="result-row">Spielzeit: <strong>' + (result.decisionTimeMs / 1000).toFixed(1) + ' s</strong> · ' +
|
|
'Spurwechsel: <strong>' + result.laneChanges + '</strong> · ' +
|
|
'Bremse benutzt: <strong>' + (result.brakeUsed ? 'ja' : 'nein') + '</strong></div>',
|
|
'<details class="result-row" style="border-bottom:none;"><summary style="cursor:pointer;font-size:12px;color:var(--muted);">JSON</summary>' +
|
|
'<pre>' + JSON.stringify(result, null, 2) + '</pre></details>'
|
|
];
|
|
display.innerHTML = lines.join('');
|
|
}
|
|
|
|
document.getElementById('nodes-output').textContent =
|
|
JSON.stringify(window.lgAutobahnGame.NODES, null, 2);
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|