90 lines
2.6 KiB
JavaScript
90 lines
2.6 KiB
JavaScript
/**
|
|
* Script to parse Unity Concord characters from uc.txt and add them to trusts.json
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
|
|
// Read the uc.txt file
|
|
const ucText = fs.readFileSync('uc.txt', 'utf8');
|
|
|
|
// Read the existing trusts.json file
|
|
const trustsJson = JSON.parse(fs.readFileSync('trusts.json', 'utf8'));
|
|
|
|
// Parse the Unity Concord characters
|
|
const ucCharacters = [];
|
|
const lines = ucText.split('\n');
|
|
|
|
let currentChar = null;
|
|
let currentSection = '';
|
|
|
|
for (let i = 0; i < lines.length; i++) {
|
|
const line = lines[i].trim();
|
|
|
|
if (line === 'Unity Concord' || line === '') continue;
|
|
|
|
// Check if this is a character name (ends with (UC))
|
|
if (line.includes('(UC)')) {
|
|
// Start a new character
|
|
currentChar = {
|
|
name: line.replace(' (UC)', ''),
|
|
role: 'Unity Concord'
|
|
};
|
|
ucCharacters.push(currentChar);
|
|
currentSection = 'name';
|
|
continue;
|
|
}
|
|
|
|
// Check for section headers
|
|
if (line === 'Job') {
|
|
currentSection = 'job';
|
|
continue;
|
|
} else if (line === 'Spells') {
|
|
currentSection = 'spells';
|
|
continue;
|
|
} else if (line === 'Abilities') {
|
|
currentSection = 'abilities';
|
|
continue;
|
|
} else if (line === 'Weapon Skills') {
|
|
currentSection = 'weapon_skills';
|
|
continue;
|
|
} else if (line === 'Acquisition') {
|
|
currentSection = 'acquisition';
|
|
continue;
|
|
} else if (line === 'Special Features') {
|
|
currentSection = 'special_features';
|
|
continue;
|
|
} else if (line === 'Trust Synergy') {
|
|
currentSection = 'trust_synergy';
|
|
continue;
|
|
}
|
|
|
|
// Handle section content
|
|
if (currentChar && currentSection) {
|
|
// Skip the tab character lines
|
|
if (line === '\t') continue;
|
|
|
|
// For job section, we need to handle it specially
|
|
if (currentSection === 'job' && line.includes('/')) {
|
|
currentChar[currentSection] = line;
|
|
continue;
|
|
}
|
|
|
|
// For other sections, append the content
|
|
if (currentSection !== 'name') {
|
|
if (!currentChar[currentSection]) {
|
|
currentChar[currentSection] = line;
|
|
} else {
|
|
currentChar[currentSection] += '\n' + line;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Add the Unity Concord characters to the trusts.json file
|
|
trustsJson.push(...ucCharacters);
|
|
|
|
// Write the updated JSON back to the file
|
|
fs.writeFileSync('trusts.json', JSON.stringify(trustsJson, null, 2), 'utf8');
|
|
|
|
console.log(`Added ${ucCharacters.length} Unity Concord characters to trusts.json`);
|