17,376
edits
(Update code: Amend namespace data) |
(Update code: Add spellBook property for spells) |
||
Line 12: | Line 12: | ||
this.getLocalID = this.getLocalID.bind(this); | this.getLocalID = this.getLocalID.bind(this); | ||
this.namespaces = { | this.namespaces = { | ||
melvorD: { displayName: "Demo", url: "https:// | melvorD: { displayName: "Demo", url: "https://melvoridle.com/assets/data/melvorDemo.json" }, | ||
melvorF: { displayName: "Full Version", url: "https:// | melvorF: { displayName: "Full Version", url: "https://melvoridle.com/assets/data/melvorFull.json" }, | ||
melvorTotH: { displayName: "Throne of the Herald", url: "https:// | melvorTotH: { displayName: "Throne of the Herald", url: "https://melvoridle.com/assets/data/melvorTotH.json" } | ||
}; | }; | ||
this.packData = {}; | this.packData = {}; | ||
Line 78: | Line 78: | ||
}); | }); | ||
return newStats; | return newStats; | ||
}, | |||
altSpells: function(entityType, entity) { | |||
if (entityType !== 'skillData') { | |||
return entity; | |||
} | |||
else { | |||
const newData = structuredClone(entity); | |||
newData.forEach((i) => i.spellBook == 'altMagic'); | |||
return newData; | |||
} | |||
} | } | ||
}; | }; | ||
Line 150: | Line 160: | ||
this.transformDataPackage(dataPackage); | this.transformDataPackage(dataPackage); | ||
this.packData[dataPackage.namespace] = dataPackage | this.packData[dataPackage.namespace] = dataPackage; | ||
this.registerDataPackage(dataPackage.namespace); | this.registerDataPackage(dataPackage.namespace); | ||
} | } | ||
Line 298: | Line 308: | ||
// Consolidates the data package identified by namespace with existing data within | // Consolidates the data package identified by namespace with existing data within | ||
// this.gameData | // this.gameData | ||
const packData = this.packData[namespace]; | const packData = this.packData[namespace].data; | ||
if (packData === undefined) { | if (packData === undefined) { | ||
throw new Error(`Couldn't find data for package ${ namespace }`); | throw new Error(`Couldn't find data for package ${ namespace }`); | ||
Line 307: | Line 317: | ||
Object.keys(packData).forEach((categoryName) => { | Object.keys(packData).forEach((categoryName) => { | ||
let categoryData = packData[categoryName]; | let categoryData = packData[categoryName]; | ||
// Some data is adjusted before combining - do this here | |||
if (['combatAreas', 'dungeons', 'slayerAreas'].includes(categoryName)) { | |||
// Add area type to each area object | |||
const areaTypes = { | |||
'combatAreas': 'combatArea', | |||
'dungeons': 'dungeon', | |||
'slayerAreas': 'slayerArea' | |||
} | |||
const areaType = areaTypes[categoryName]; | |||
const newData = structuredClone(categoryData); | |||
newData.forEach((x) => x.type = areaType); | |||
categoryData = newData; | |||
} | |||
else if (['ancientSpells', 'archaicSpells', 'auroraSpells', 'curseSpells', 'standardSpells'].includes(categoryName)) { | |||
// For spell books, add the spell type to each spell object. | |||
// Alt Magic spells are handled elsewhere, as they are within a skill object | |||
const spellType = categoryName.replace('Spells', ''); | |||
const newData = structuredClone(categoryData); | |||
newData.forEach((x) => x.spellBook = spellType); | |||
categoryData = newData; | |||
} | |||
// Data must be pushed into the consoldiated data, rules for vary | // Data must be pushed into the consoldiated data, rules for vary | ||
// depending on the category in question | // depending on the category in question | ||
switch(categoryName) { | switch(categoryName) { | ||
case 'ancientSpells': | case 'ancientSpells': | ||
case 'archaicSpells': | case 'archaicSpells': | ||
Line 328: | Line 346: | ||
case 'attacks': | case 'attacks': | ||
case 'auroraSpells': | case 'auroraSpells': | ||
case 'combatAreas': | |||
case 'combatEvents': | case 'combatEvents': | ||
case 'combatPassives': | case 'combatPassives': | ||
case 'curseSpells': | case 'curseSpells': | ||
case 'dungeons': | |||
case 'gamemodes': | case 'gamemodes': | ||
case 'itemEffects': | case 'itemEffects': | ||
Line 346: | Line 366: | ||
case 'shopPurchases': | case 'shopPurchases': | ||
case 'shopUpgradeChains': | case 'shopUpgradeChains': | ||
case 'slayerAreas': | |||
case 'stackingEffects': | case 'stackingEffects': | ||
case 'standardSpells': | case 'standardSpells': |