Commit Graph

5 Commits

Author SHA1 Message Date
dilgenfritz 84b17a7930 Implement simplified XP system with overall counter
- 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
2025-10-30 11:41:26 -05:00
dilgenfritz c43737a71d Save current state: Fixed text readability in scenarios and interactive tasks 2025-10-29 17:04:42 -05:00
dilgenfritz f250d015b8 fix: Prevent multiple audio streams and overlapping audio
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
2025-10-28 08:12:16 -05:00
dilgenfritz 66bee4821b fix: Prevent audio from continuing after game completion
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!
2025-10-28 08:07:13 -05:00
dilgenfritz 3a57f1ce71 Refactor file structure with feature-based organization
New Structure:
- src/core/ - Core game engine (game.js, gameModeManager.js, main.js, preload.js)
- src/features/ - Feature modules organized by functionality:
  - webcam/ - Photography system (webcamManager.js)
  - tasks/ - Task management (interactiveTaskManager.js, aiTaskManager.js)
  - audio/ - Audio system (audioManager.js)
  - images/ - Image management (popupImageManager.js, image-discovery-fix.js)
  - ui/ - UI components (flashMessageManager.js)
- src/data/ - Game data and configuration (gameData.js)
- src/styles/ - CSS stylesheets (styles.css and variants)
- src/utils/ - Utility functions (desktop-file-manager.js)

 Benefits:
- Feature-based organization for better maintainability
- Clear separation of concerns
- Easier testing and debugging
- Scalable architecture for future development
- Self-contained feature modules

Updated package.json, index.html paths, and main.js for new structure.
Added comprehensive README.md documenting the architecture.
2025-10-27 14:46:30 -05:00