Module:GameData/doc: Difference between revisions

Update script - Firemaking: Initialize primaryProducts & secondaryProducts properties for logs with default values when absent
(Support all remaining data modifications & dependent data)
(Update script - Firemaking: Initialize primaryProducts & secondaryProducts properties for logs with default values when absent)
Line 144: Line 144:
console.log('Processing dependent data for all packages...');
console.log('Processing dependent data for all packages...');
this.processDependentData();
this.processDependentData();
// Apply modifications that are to be performed across all packages
this.transformConsolidatedData();
// All data packages should now be within this.gameData
// All data packages should now be within this.gameData
}
}
Line 323: Line 325:
// Special case for skillData so that certain values initialized when the various Skill
// Special case for skillData so that certain values initialized when the various Skill
// classes are initialized may be added here also
// classes are initialized may be added here also
if (categoryName === 'skillData' && dataNode.skillID !== undefined && dataNode.data !== undefined) {
const curSkillID = dataNode.skillID;
if (categoryName === 'skillData' && curSkillID !== undefined && dataNode.data !== undefined) {
// We are currently at the topmost level of a skill object
// We are currently at the topmost level of a skill object
const gameSkill = game.skills.getObjectByID(dataNode.skillID);
const gameSkill = game.skills.getObjectByID(curSkillID);
// For every skill with mastery, add mastery checkpoint descriptions
// For every skill with mastery, add mastery checkpoint descriptions
if (
if (
Line 332: Line 335:
dataNode.data.masteryCheckpoints === undefined
dataNode.data.masteryCheckpoints === undefined
) {
) {
const localID = this.getLocalID(dataNode.skillID);
const localID = this.getLocalID(curSkillID);
dataNode.data.baseMasteryPoolCap = gameSkill.baseMasteryPoolCap;
dataNode.data.baseMasteryPoolCap = gameSkill.baseMasteryPoolCap;
dataNode.data.masteryCheckpoints = [];
dataNode.data.masteryCheckpoints = [];
Line 339: Line 342:
});
});
}
}
if (!this.skillDataInit[dataNode.skillID]) {
if (!this.skillDataInit[curSkillID]) {
if (gameSkill !== undefined) {
if (gameSkill !== undefined) {
// Import other attributes varying by skill
// Import other attributes varying by skill
let importKeys = [];
let importKeys = [];
switch (dataNode.skillID) {
switch (curSkillID) {
case 'melvorD:Mining':
case 'melvorD:Mining':
importKeys = ['baseInterval', 'baseRockHP', 'passiveRegenInterval'];
importKeys = ['baseInterval', 'baseRockHP', 'passiveRegenInterval'];
Line 414: Line 417:
}
}
}
}
this.skillDataInit[dataNode.skillID] = true;
this.skillDataInit[curSkillID] = true;
}
}
// Appy localization (skills)
// Appy localization (skills)
this.langApply(parentNode, nodeKey, true);
this.langApply(parentNode, nodeKey, true);
}
}
// Applies any transformations that must be performed on the consolidated gameData
// rather than on a per package basis
transformConsolidatedData() {
// Firemaking - Apply default primary & secondary products to logs
const skillDataFM = this.getObjectByID(this.gameData.skillData, 'melvorD:Firemaking', 'skillID');
if (skillDataFM !== undefined) {
skillDataFM.data.logs.forEach((log) => {
if (log.primaryProducts === undefined) {
log.primaryProducts = [...skillDataFM.data.defaultPrimaryProducts];
}
if (log.secondaryProducts === undefined) {
log.secondaryProducts = [...skillDataFM.data.defaultSecondaryProducts];
}
});
}
}
}
}