88 lines
3.0 KiB
JavaScript
88 lines
3.0 KiB
JavaScript
/**
|
|
* Scenario Extractor Utility
|
|
* Analyzes gameModeManager.js to find scenario boundaries and extract them
|
|
*/
|
|
|
|
const fs = require('fs').promises;
|
|
const path = require('path');
|
|
|
|
async function analyzeScenarios() {
|
|
const filePath = path.join(__dirname, '..', 'src', 'core', 'gameModeManager.js');
|
|
const content = await fs.readFile(filePath, 'utf8');
|
|
const lines = content.split('\n');
|
|
|
|
console.log('🔍 Analyzing scenario structure in gameModeManager.js...\n');
|
|
|
|
// Find key markers
|
|
let scenarioMapStart = -1;
|
|
let additionalScenariosStart = -1;
|
|
let scenarioMapEnd = -1;
|
|
|
|
for (let i = 0; i < lines.length; i++) {
|
|
const line = lines[i].trim();
|
|
|
|
if (line.includes('const scenarioMap = {')) {
|
|
scenarioMapStart = i;
|
|
console.log(`📍 scenarioMap starts at line: ${i + 1}`);
|
|
}
|
|
|
|
if (line.includes('const additionalScenarios = {')) {
|
|
additionalScenariosStart = i;
|
|
console.log(`📍 additionalScenarios starts at line: ${i + 1}`);
|
|
}
|
|
|
|
if (line.includes('Object.assign(scenarioMap, additionalScenarios);')) {
|
|
scenarioMapEnd = i;
|
|
console.log(`📍 Scenario data ends at line: ${i + 1}`);
|
|
}
|
|
}
|
|
|
|
// Find individual scenarios
|
|
console.log('\n🎯 Individual Scenarios Found:');
|
|
const scenarioPattern = /^\s*'(scenario-[^']+)':\s*{/;
|
|
|
|
for (let i = scenarioMapStart; i < scenarioMapEnd; i++) {
|
|
const line = lines[i];
|
|
const match = line.match(scenarioPattern);
|
|
|
|
if (match) {
|
|
const scenarioId = match[1];
|
|
console.log(` - ${scenarioId} at line ${i + 1}`);
|
|
|
|
// Find the end of this scenario (look for closing brace at same indent level)
|
|
const indent = line.search(/\S/);
|
|
let endLine = -1;
|
|
let braceCount = 0;
|
|
|
|
for (let j = i; j < scenarioMapEnd; j++) {
|
|
const currentLine = lines[j];
|
|
|
|
// Count braces
|
|
for (const char of currentLine) {
|
|
if (char === '{') braceCount++;
|
|
if (char === '}') braceCount--;
|
|
}
|
|
|
|
// If we're back to the original indent level and braces are balanced
|
|
if (j > i && braceCount === 0 && currentLine.trim().endsWith('},')) {
|
|
endLine = j;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (endLine > 0) {
|
|
console.log(` └─ ends at line ${endLine + 1} (${endLine - i + 1} lines)`);
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log('\n✅ Analysis complete!');
|
|
console.log(`📝 Total scenario data spans lines ${scenarioMapStart + 1} to ${scenarioMapEnd + 1}`);
|
|
}
|
|
|
|
// Run if called directly
|
|
if (require.main === module) {
|
|
analyzeScenarios().catch(console.error);
|
|
}
|
|
|
|
module.exports = { analyzeScenarios }; |