Module:GameData/doc: Difference between revisions

From Melvor Idle
(Update code: Add spellBook property for spells)
(Update code)
Line 8: Line 8:
{{SpoilerBox|color=default|title=Code|text=<pre>// TODO:
{{SpoilerBox|color=default|title=Code|text=<pre>// TODO:
// Special attack description generation
// Special attack description generation
// Handle modifications portion of data packages
class Wiki {
class Wiki {
     constructor() {
     constructor() {
Line 18: Line 19:
         this.packData = {};
         this.packData = {};
         this.gameData = {};
         this.gameData = {};
        this.skillDataInit = {};
         this.dataPropFilters = {
         this.dataPropFilters = {
             // Specifies rules for properties of entities (items, monsters, etc.) which
             // Specifies rules for properties of entities (items, monsters, etc.) which
Line 219: Line 221:
         // 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
         else if ((categoryName === 'skillData') && dataNode.skillID !== undefined && dataNode.data !== undefined) {
         if ((categoryName === 'skillData') && dataNode.skillID !== undefined && dataNode.data !== undefined && !this.skillDataInit[dataNode.skillID]) {
             // 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.registeredObjects.get(dataNode.skillID);
             const gameSkill = game.skills.registeredObjects.get(dataNode.skillID);
             if (gameSkill !== undefined) {
             if (gameSkill !== undefined) {
                dataNode.data.name = getLangString('SKILL_NAME', this.getLocalID(dataNode.skillID));
                if (gameSkill.milestones !== undefined && dataNode.data.milestoneCount === undefined) {
                    dataNode.data.milestoneCount = gameSkill.milestones.length;
                }
                // For every skill with mastery, add mastery checkpoint descriptions
                if (gameSkill instanceof SkillWithMastery && dataNode.data.masteryTokenID !== undefined && dataNode.data.masteryCheckpoints === undefined) {
                    const localID = this.getLocalID(dataNode.skillID);
                    dataNode.data.baseMasteryPoolCap = gameSkill.baseMasteryPoolCap;
                    dataNode.data.masteryCheckpoints = [];
                    masteryCheckpoints.forEach((pct, idx) => {
                        dataNode.data.masteryCheckpoints[idx] = getLangString('MASTERY_CHECKPOINT', `${ localID }_${ idx }`);
                    });
                }
                // Import other attributes varying by skill
                 let importKeys = [];
                 let importKeys = [];
                 switch(dataNode.skillID) {
                 switch(dataNode.skillID) {
Line 245: Line 263:
                     case 'melvorD:Runecrafting':
                     case 'melvorD:Runecrafting':
                     case 'melvorD:Herblore':
                     case 'melvorD:Herblore':
                    case 'melvorD:Summoning':
                         importKeys = [
                         importKeys = [
                             'baseInterval'
                             'baseInterval'
Line 262: Line 279:
                             'obstacleUnlockLevels'
                             'obstacleUnlockLevels'
                         ];
                         ];
                        break;
                    case 'melvorD:Summoning':
                        importKeys = [
                            'baseInterval'
                        ];
                        const sumKeys = [
                            'recipeGPCost',
                            'markLevels' 
                        ];
                        sumKeys.forEach((k) => dataNode.data[k] = Summoning[k]);
                         break;
                         break;
                     case 'melvorD:Astrology':
                     case 'melvorD:Astrology':
Line 271: Line 298:
                             'uniqueModifierCosts',
                             'uniqueModifierCosts',
                             'baseStardustChance',
                             'baseStardustChance',
                             'goldenStardustChance',
                             'baseGoldenStardustChance',
                             'baseInterval'
                             'baseInterval'
                         ];
                         ];
                         astKeys.forEach((k) => dataNode.data[k] = Astrology[k]);
                         astKeys.forEach((k) => dataNode.data[k] = Astrology[k]);
                        break;
                     case 'melvorD:Township':
                     case 'melvorD:Township':
                         // Remap a number of keys from their in-game names
                         // Remap a number of keys from their in-game names
Line 298: Line 326:
                         ];
                         ];
                         townKeys.forEach((k) => dataNode.data[k.to] = gameSkill[k.from]);
                         townKeys.forEach((k) => dataNode.data[k.to] = gameSkill[k.from]);
                        break;
                 }
                 }
                 if (importKeys.length > 0) {
                 if (importKeys.length > 0) {
Line 303: Line 332:
                 }
                 }
             }
             }
            this.skillDataInit[dataNode.skillID] = true;
         }
         }
     }
     }
Line 337: Line 367:
                 newData.forEach((x) => x.spellBook = spellType);
                 newData.forEach((x) => x.spellBook = spellType);
                 categoryData = newData;
                 categoryData = newData;
            }
            else if (categoryName === 'golbinRaid') {
             }
             }
             // Data must be pushed into the consoldiated data, rules for vary
             // Data must be pushed into the consoldiated data, rules for vary
Line 421: Line 454:
                     if (this.gameData[categoryName] === undefined) {
                     if (this.gameData[categoryName] === undefined) {
                         this.gameData[categoryName] = categoryData;
                         this.gameData[categoryName] = categoryData;
                        this.gameData.golbinRaid.possibleModifiers = RaidManager.possibleModifiers;
                     }
                     }
                     else {
                     else {
Line 484: Line 518:
             });
             });
             this.gameData.combatTriangles = ctData;
             this.gameData.combatTriangles = ctData;
        }
        if (this.gameData.masteryCheckpoints === undefined) {
            this.gameData.masteryCheckpoints = masteryCheckpoints;
        }
        if (this.gameData.combatAreaDifficulties === undefined) {
            this.gameData.combatAreaDifficulties = CombatAreaMenu.difficulty.map((i) => i.name);
        }
        if (this.gameData.equipmentSlots === undefined) {
            this.gameData.equipmentSlots = EquipmentSlots;
        }
        if (this.gameData.attackTypes === undefined) {
            this.gameData.attackTypes = AttackTypeID;
        }
        if (this.gameData.slayerTiers === undefined) {
            const newData = structuredClone(SlayerTask.data)
            newData.forEach((tier) => delete tier.engDisplay);
            this.gameData.slayerTiers = newData;
         }
         }
     }
     }