import { extraWords } from './extra-words.mjs'; import { DICTIONARY_SET } from '../src/data/lexicon.js'; // Build and validate target words pool for Quartiles export const targetWordsPool = []; { const existing = new Set(); let added = 0; for (const item of extraWords) { const problems = []; if (existing.has(item.word)) problems.push('duplicate word'); if (item.tiles.length !== 4) problems.push('not 4 tiles'); if (item.tiles.join('') !== item.word) problems.push(`tiles spell "${item.tiles.join('')}"`); if (!item.tiles.every(t => t.length >= 2)) problems.push('tile < 2 letters'); if (new Set(item.tiles).size !== item.tiles.length) problems.push('repeated tile within word'); if (!DICTIONARY_SET.has(item.word)) problems.push('not in runtime dictionary'); if (problems.length) { console.warn(` Skipping target word "${item.word}": ${problems.join(', ')}`); continue; } existing.add(item.word); targetWordsPool.push(item); added++; } console.log(`Loaded and validated ${added} target words.`); } // Validate pool integrity for (const item of targetWordsPool) { if (item.tiles.join('') !== item.word) { throw new Error(`Word spelling mismatch: ${item.word} !== ${item.tiles.join('')}`); } if (!item.tiles.every(t => t.length >= 2)) { throw new Error(`Word contains tile < 2 chars: ${item.word} -> ${JSON.stringify(item.tiles)}`); } if (item.tiles.length !== 4) { throw new Error(`Word does not have 4 tiles: ${item.word}`); } } console.log('Target words pool verified! Total words:', targetWordsPool.length);