- Replace scoring system with XP-based progression
- Task-based XP: 2 XP per regular task, 5 XP per scenario step
- Overall XP counter for rankings/leveling (persistent across sessions)
- No overall XP awarded for quit/abandoned sessions (only completed sessions)
- Session XP always displayed but only added to overall on completion
- Simplified from time/activity bonuses to pure task completion rewards
- Updated UI with dual XP display: Session XP / Total XP
- Audio playlist system continues in background during gameplay
CRITICAL AUDIO FIXES:
1. DUPLICATE AUDIO PREVENTION:
Fixed skipTask() triggering both 'mocking' + 'denial' punishment audio
Added skipAudioPlayed flag to prevent consequence audio when skip audio is playing
Modified displayCurrentTask() to check flag before playing consequence audio
2. AUDIO OVERLAP ELIMINATION:
Made audio stopping in playAudio() synchronous instead of calling stopCategory()
Forcibly stop existing audio immediately: pause() + currentTime=0 + src=''
Enhanced stopAllImmediate() to use same aggressive stopping method
Removed fadeOut delays in completeTask() and skipTask() (now immediate stop)
3. TIMING IMPROVEMENTS:
completeTask() now stops audio immediately (0ms) before playing reward audio
skipTask() stops task audio immediately (0ms) before punishment audio
Added 100ms delay before reward audio to ensure previous audio fully stopped
4. TECHNICAL DETAILS:
- Audio elements now get src='' to fully release resources
- Synchronous audio stopping prevents race conditions
- Clear fade timeouts to prevent delayed audio operations
- Aggressive stopping in both individual playAudio() and global stopAllImmediate()
EXPECTED RESULT:
- Only ONE audio stream plays at a time
- No overlapping punishment/task/reward audio
- Clean audio transitions without interruption errors
- Proper audio stopping when games end
PROBLEM:
- Task audio and punishment audio would continue playing after completing games
- Interactive task manager had delayed completions that could trigger after endGame()
- AudioManager didn't check game state before playing new audio
SOLUTION:
Enhanced endGame() method with multiple audio stop attempts
Added game state check in AudioManager.playAudio() to prevent new audio after game ends
Modified AudioManager constructor to accept game instance for state checking
Added game state validation in all interactive task completion methods
Enhanced cleanupInteractiveTask() to explicitly stop audio categories
Added safeguards in completeInteractiveTask(), giveUpInteractiveTask(), resumeFromCamera()
TECHNICAL DETAILS:
- endGame() now calls stopAllImmediate() twice (immediate + 100ms delay)
- AudioManager checks if game.gameState.isRunning before playing any new audio
- Interactive task manager validates game state before calling completeTask()
- All delayed completions now verify game is still running before proceeding
- Interactive task cleanup now explicitly stops 'tasks' and 'punishments' audio
Audio will now properly stop when games end and won't restart from delayed task completions!