48 lines
1.8 KiB
JavaScript
48 lines
1.8 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// Read the current gameModeManager.js
|
|
const filePath = path.join(__dirname, '..', 'src', 'core', 'gameModeManager.js');
|
|
const content = fs.readFileSync(filePath, 'utf8');
|
|
|
|
// Find the start of getScenarioData method and the start of getScenarioFromGame method
|
|
const lines = content.split('\n');
|
|
|
|
let startRemoval = -1;
|
|
let endRemoval = -1;
|
|
|
|
// Find where the problematic data starts
|
|
for (let i = 0; i < lines.length; i++) {
|
|
if (lines[i].trim() === 'return this.getScenarioFromGame(scenarioId);' && startRemoval === -1) {
|
|
startRemoval = i + 1; // Start removing after this line
|
|
}
|
|
if (lines[i].trim().includes('if (window.gameData && window.gameData.mainTasks)')) {
|
|
endRemoval = i - 1; // Stop removing before this line
|
|
break;
|
|
}
|
|
}
|
|
|
|
console.log(`Found removal range: lines ${startRemoval + 1} to ${endRemoval + 1}`);
|
|
|
|
if (startRemoval !== -1 && endRemoval !== -1 && startRemoval < endRemoval) {
|
|
// Remove the problematic lines
|
|
const cleanedLines = [
|
|
...lines.slice(0, startRemoval),
|
|
' }',
|
|
'',
|
|
' /**',
|
|
' * Get scenario data from the current game.js implementation',
|
|
' */',
|
|
' getScenarioFromGame(scenarioId) {',
|
|
' // This accesses the scenarios currently defined in game.js',
|
|
...lines.slice(endRemoval + 1)
|
|
];
|
|
|
|
const cleanedContent = cleanedLines.join('\n');
|
|
fs.writeFileSync(filePath, cleanedContent, 'utf8');
|
|
console.log('Fixed gameModeManager.js by removing orphaned scenario data');
|
|
console.log(`Removed ${endRemoval - startRemoval + 1} lines`);
|
|
} else {
|
|
console.log('Could not find proper removal boundaries');
|
|
console.log(`Start: ${startRemoval}, End: ${endRemoval}`);
|
|
} |