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:
+10
-1
@@ -20,6 +20,8 @@ export function getDB(): IDBDatabase {
|
||||
return db;
|
||||
}
|
||||
|
||||
const MAX_LEVEL = 6;
|
||||
|
||||
async function handleLessonComplete(completedLevel: number): Promise<void> {
|
||||
// Update progress after lesson completion
|
||||
const progress = await getProgress(db);
|
||||
@@ -31,7 +33,8 @@ async function handleLessonComplete(completedLevel: number): Promise<void> {
|
||||
}
|
||||
|
||||
// Advance to next level if this was the current level (LEVL-02, LEVL-03)
|
||||
if (completedLevel === progress.currentLevel) {
|
||||
// Cap at MAX_LEVEL + 1 so we don't go beyond defined levels
|
||||
if (completedLevel === progress.currentLevel && completedLevel < MAX_LEVEL) {
|
||||
progress.currentLevel = completedLevel + 1;
|
||||
}
|
||||
|
||||
@@ -51,6 +54,11 @@ async function handleLessonComplete(completedLevel: number): Promise<void> {
|
||||
showScreen("forest");
|
||||
}
|
||||
|
||||
async function handleLessonCancel(): Promise<void> {
|
||||
await initForestScreen(db, startLessonFromForest);
|
||||
showScreen("forest");
|
||||
}
|
||||
|
||||
function startLessonFromForest(level: number): void {
|
||||
// Clean up previous lesson if any
|
||||
if (lessonCleanup) {
|
||||
@@ -69,6 +77,7 @@ function startLessonFromForest(level: number): void {
|
||||
level,
|
||||
layout,
|
||||
handleLessonComplete,
|
||||
handleLessonCancel,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user