17,376
edits
(Update for v1.1.2) |
(Update for v1.1.2) |
||
Line 92: | Line 92: | ||
inclCat.forEach((cat) => gameDataFiltered[cat] = wd.gameData[cat]); | inclCat.forEach((cat) => gameDataFiltered[cat] = wd.gameData[cat]); | ||
const escapeQuotes = (data) => { | |||
var newData = data.replace(/\'/g, "\\\'"); | |||
newData = newData.replace(/\\\"/g, "\\\\\""); | |||
return newData; | |||
}; | |||
const dataFormatter = (category, data) => { | |||
if (category === 'skillData') { | |||
return '"' + category + '":[' + data.map((x) => escapeQuotes(JSON.stringify(x))).join(",' ..\n'") + ']'; | |||
} | |||
else { | |||
return '"' + category + '":' + escapeQuotes(JSON.stringify(data)); | |||
} | |||
}; | |||
// Convert game data into a JSON string for export | // Convert game data into a JSON string for export | ||
dataObjText = undefined; | dataObjText = undefined; | ||
if (this.prettyPrint) { | if (this.prettyPrint) { | ||
dataObjText = JSON.stringify(gameDataFiltered, undefined, '\t'); | dataObjText = escapeQuotes(JSON.stringify(gameDataFiltered, undefined, '\t')); | ||
} | } | ||
else { | else { | ||
dataObjText = JSON.stringify(gameDataFiltered); | dataObjText = "{" + Object.keys(gameDataFiltered).map((k) => dataFormatter(k, gameDataFiltered[k])).join(",' ..\n'") + "}"; //JSON.stringify(gameDataFiltered); | ||
} | } | ||
let dataText = '-- Version: ' + this.getGameVersion(); | let dataText = '-- Version: ' + this.getGameVersion(); | ||
Line 285: | Line 296: | ||
{from: 'MAX_WORSHIP', to: 'maxWorship'}, | {from: 'MAX_WORSHIP', to: 'maxWorship'}, | ||
{from: 'MINIMUM_HEALTH', to: 'minimumHealth'}, | {from: 'MINIMUM_HEALTH', to: 'minimumHealth'}, | ||
{from: 'populationForTier', to: 'populationForTier'}, | |||
{from: 'TICK_LENGTH', to: 'tickLength'}, | {from: 'TICK_LENGTH', to: 'tickLength'}, | ||
{from: 'RARE_SEASON_CHANCE', to: 'rareSeasonChance'}, | {from: 'RARE_SEASON_CHANCE', to: 'rareSeasonChance'}, | ||
Line 807: | Line 819: | ||
} | } | ||
} | } | ||
const passiveDesc = | const passiveDesc = (data) => { | ||
const passive = game.combatPassives.getObjectByID(data.id); | const passive = game.combatPassives.getObjectByID(data.id); | ||
if (passive !== undefined) { | if (passive !== undefined) { | ||
Line 813: | Line 825: | ||
} | } | ||
} | } | ||
const spAttDesc = | const spAttDesc = (data) => { | ||
const spAtt = game.specialAttacks.getObjectByID(data.id); | const spAtt = game.specialAttacks.getObjectByID(data.id); | ||
if (spAtt !== undefined) { | if (spAtt !== undefined) { | ||
return spAtt.description; | return spAtt.description; | ||
} | |||
} | |||
const tsWorshipName = (data) => { | |||
const worship = game.township.worships.getObjectByID(data.id); | |||
if (worship !== undefined) { | |||
return worship.name; | |||
} | |||
} | |||
const tsWorshipStatueName = (data) => { | |||
const worship = game.township.worships.getObjectByID(data.id); | |||
if (worship !== undefined) { | |||
return worship.statueName; | |||
} | } | ||
} | } | ||
Line 990: | Line 1,014: | ||
}, | }, | ||
worships: { | worships: { | ||
name: { | name: { stringSpecial: 'tsWorshipName' }, | ||
statueName: { | statueName: { stringSpecial: 'tsWorshipStatueName' } | ||
} | } | ||
}, | }, | ||
Line 1,130: | Line 1,154: | ||
case 'spAttDesc': | case 'spAttDesc': | ||
langString = spAttDesc(target); | langString = spAttDesc(target); | ||
break; | |||
case 'tsWorshipName': | |||
langString = tsWorshipName(target); | |||
break; | |||
case 'tsWorshipStatueName': | |||
langString = tsWorshipStatueName(target); | |||
break; | break; | ||
} | } |