fix(01): add lesson cancel button and handle level 6 completion

- Back button in lesson screen to return to forest without completing
- "Alle Stufen geschafft!" message when all 6 levels are done
- Cap currentLevel at MAX_LEVEL to prevent out-of-bounds progression

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 11:30:55 +02:00
co-authored by Claude Opus 4.6
parent 46fa2e28d5
commit 78d516c55d
5 changed files with 69 additions and 3 deletions
+17 -2
View File
@@ -48,6 +48,8 @@ export function renderLevelMap(
});
}
const MAX_LEVEL = 6;
export async function initForestScreen(
db: IDBDatabase,
onStartLesson: (level: number) => void,
@@ -61,6 +63,19 @@ export async function initForestScreen(
renderLevelMap(mapContainer, progress, onStartLesson);
// Continue button starts the current level
continueBtn.onclick = () => onStartLesson(progress.currentLevel);
const allComplete = levels.every((l) =>
progress.completedLevels.includes(l.level),
);
if (allComplete) {
continueBtn.textContent = "Alle Stufen geschafft!";
continueBtn.disabled = true;
continueBtn.classList.add("forest__continue-btn--done");
} else {
continueBtn.textContent = "Weiter ueben";
continueBtn.disabled = false;
continueBtn.classList.remove("forest__continue-btn--done");
continueBtn.onclick = () =>
onStartLesson(Math.min(progress.currentLevel, MAX_LEVEL));
}
}