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:
+17
-2
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user