Weiter am Chastity Ingame gearbeitet
Some checks failed
Host-Based Deploy (Java 21 Fix) / build-and-run (push) Has been cancelled

This commit is contained in:
2026-04-27 17:41:00 +02:00
parent 0aa794600e
commit 34e5fcd777
53 changed files with 905 additions and 847 deletions

View File

@@ -176,7 +176,7 @@
<h2>Level 6 erreicht!</h2>
<div class="game-label" id="finisherTitle"></div>
<div class="game-text" id="finisherText" style="margin-top:0.5rem;text-align:left;"></div>
<button class="btn-secondary" onclick="goBack()" style="margin-top:1.25rem;">Zurück zum Lock</button>
<button class="btn-primary" onclick="completeGame()" style="margin-top:1.25rem;">✓ Spiel beenden</button>
</div>
</div>
@@ -189,8 +189,9 @@
</div>
<script>
const params = new URLSearchParams(location.search);
const lockId = params.get('lockId');
const params = new URLSearchParams(location.search);
const lockId = params.get('lockId');
const autoGameSetId = params.get('gameSetId');
let _state = null;
let _timerInt = null;
let _pendingIsLock = false;
@@ -201,13 +202,23 @@
else history.back();
}
async function completeGame() {
const url = '/lock-game/complete' + (lockId ? '?lockId=' + lockId : '');
await fetch(url, { method: 'POST' });
goBack();
}
// ── Init ──────────────────────────────────────────────────────────────────
async function boot() {
try {
const r = await fetch('/lock-game/state');
if (r.status === 404) {
await loadGroups();
if (autoGameSetId) {
await autoStartGame(autoGameSetId);
} else {
await loadGroups();
}
return;
}
if (!r.ok) throw new Error('Fehler beim Laden des Spielzustands');
@@ -219,6 +230,19 @@
}
}
async function autoStartGame(gameSetId) {
try {
const r = await fetch('/lock-game/init?aufgabenGruppeId=' + gameSetId, { method: 'POST' });
if (!r.ok) throw new Error('Initialisierung fehlgeschlagen');
const stateR = await fetch('/lock-game/state');
_state = await stateR.json();
hide('loadingHint');
await runGameLoop();
} catch (e) {
showError(e.message);
}
}
async function loadGroups() {
const r = await fetch('/lock-game/groups');
const groups = r.ok ? await r.json() : [];