// === STORY BUILDER GAME - STORY CONSTRUCTOR === class StoryBuilderGame { constructor(options) { this.container = options.container; this.content = options.content; this.contentEngine = options.contentEngine; this.onScoreUpdate = options.onScoreUpdate || (() => {}); this.onGameEnd = options.onGameEnd || (() => {}); // Game state this.score = 0; this.currentStory = []; this.availableElements = []; this.storyTarget = null; this.gameMode = 'vocabulary'; // 'vocabulary', 'sequence', 'dialogue', 'scenario' // Extract vocabulary using ultra-modular format this.vocabulary = this.extractVocabulary(this.content); this.wordsByType = this.groupVocabularyByType(this.vocabulary); // Configuration this.maxElements = 6; this.timeLimit = 180; // 3 minutes this.timeLeft = this.timeLimit; this.isRunning = false; // Timers this.gameTimer = null; this.init(); } init() { // Check if we have enough vocabulary if (!this.vocabulary || this.vocabulary.length < 6) { logSh('Not enough vocabulary for Story Builder', 'ERROR'); this.showInitError(); return; } this.createGameBoard(); this.setupEventListeners(); this.loadStoryContent(); } showInitError() { this.container.innerHTML = `
This content doesn't have enough vocabulary for Story Builder.
The game needs at least 6 vocabulary words with types (noun, verb, adjective, etc.).
Choose a mode and let's start!