Fix FlashcardLearning content loading priority

Issue: Game failed with "No suitable content available for flashcards"
even when chapter had vocabulary data.

Root Cause:
- FlashcardLearning.init() tried window.contentLoader.getContent() first
- This synchronous utils ContentLoader might not have content yet
- Game already receives content via dependencies from GameLoader

Fix:
- Prioritize this._content (from dependencies) first
- Only fallback to window.contentLoader if no dependency content
- Content is guaranteed to be loaded by GameLoader before init()

Changes:
- src/games/FlashcardLearning.js:178 - Reversed content loading priority

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
StillHammer 2025-10-13 10:11:38 +08:00
parent cdae675f9c
commit 0d17fb560c

View File

@ -172,7 +172,10 @@ class FlashcardLearning extends Module {
try {
this._isActive = true; // Set active before starting
this._container = this._config.container;
const content = window.contentLoader ? window.contentLoader.getContent(window.currentChapterId) : this._content;
// Prioritize content from dependencies (passed by GameLoader)
// Fallback to window.contentLoader only if no content in dependencies
const content = this._content || (window.contentLoader ? window.contentLoader.getContent(window.currentChapterId) : null);
if (!content || (!content.vocabulary && !content.sentences)) {
throw new Error('No suitable content available for flashcards');