Fix game mode task cycling: Only end game on complete-all mode

Critical fix for timed and score target game modes:

Issue:
- Game was ending when all tasks were shown regardless of game mode
- Timed and score target modes should continue cycling through tasks
- Only 'complete-all' mode should end when all tasks are finished

Fix:
- Updated loadMainTask() to check gameMode before ending game
- Complete-all mode: Ends game when all tasks completed (original behavior)
- Timed/Score modes: Reset usedMainTasks array and continue cycling
- Added console logging for task cycling in non-complete-all modes

Now game modes work correctly:
 Complete All: Ends when all tasks finished
 Timed Challenge: Cycles through tasks until time runs out
 Score Target: Cycles through tasks until target score reached

This enables proper infinite task cycling for time-based and score-based challenges!
This commit is contained in:
fritzsenpai 2025-09-25 22:04:59 -05:00
parent cc853ad667
commit ab26d61904
1 changed files with 13 additions and 3 deletions

16
game.js
View File

@ -2383,9 +2383,19 @@ ${usagePercent > 85 ? '⚠️ Storage getting full - consider deleting some imag
);
if (availableTasks.length === 0) {
// All main tasks completed - end game
this.endGame();
return;
// All main tasks completed
if (this.gameState.gameMode === 'complete-all') {
// Only end game in complete-all mode
this.endGame('complete-all');
return;
} else {
// In timed and score-target modes, reset used tasks and continue
console.log(`All tasks completed in ${this.gameState.gameMode} mode, cycling through tasks again`);
this.gameState.usedMainTasks = [];
// Recursively call loadMainTask to select from reset pool
this.loadMainTask();
return;
}
}
// Select random task and random image from task pool