Module:Sandbox/Skills/data: Difference between revisions

Add Herblore potion tier levels
m (Revert to previous revision)
(Add Herblore potion tier levels)
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
-- Version: ALPHA V0.21 (?1114)
-- Version: V1.0.3 (?1806)


--[[The text to decode can be generated in the console via
--[[Generated from console via
(function() {
(function() {
   var getGameVersion = function() {
   var getGameVersion = function() {
       var elemNavHeader = document.getElementsByClassName("nav-main-heading")
       var elemVer = document.querySelector("li[data-target='#modal-major-update']:not(.d-none)")
       if (elemNavHeader.length > 0) {
       if (elemVer !== undefined) {
        return Array.from(elemNavHeader).filter((i, idx) => i.innerText.startsWith("ALPHA"))[0].innerText
      return elemVer.innerText
      }
      else {
        return gameVersion
       }
       }
      else { return gameVersion }
     }
     }
  var formatJSON = function(txt) {
  var out = JSON.stringify(txt)
  out = out.replace(/\'/g, "\\\'")
  out = out.replace(/\\\"/g, "\\\\\"")
  return out
  }


   var fullText = "-- Version: " + getGameVersion()
   var fullText = "-- Version: " + getGameVersion()
  fullText += "\r\n\r\nlocal SkillData = {}"
  fullText += "\r\n\r\nSkillData.Skills = mw.text.jsonDecode('" + formatJSON(SKILLS) + "')"


   var itemsAdj = []
   // Prayer
   for (var i = 0; i < items.length; i++) {
  fullText += "\r\n\r\nSkillData.Prayer = mw.text.jsonDecode('" + formatJSON(PRAYER) + "')"
    itemsAdj[i] = {...items[i]}
 
    // Amend elements of specialAttacks to include descriptions
  // Woodcutting
     if (itemsAdj[i].specialAttacks !== undefined) {
  fullText += "\r\n\r\nSkillData.Woodcutting = {}"
       for (var j = 0; j < itemsAdj[i].specialAttacks.length; j++) {
  fullText += "\r\nSkillData.Woodcutting.Trees = mw.text.jsonDecode('" + formatJSON(Woodcutting.trees) + "')"
         itemsAdj[i].specialAttacks[j].description = describeAttack(itemsAdj[i].specialAttacks[j], youNoun, enemyNoun).replaceAll(/<span class=\".+?\">(.+?)<\/span>/ig, '$1')
 
  // Fishing
  fullText += "\r\n\r\nSkillData.Fishing = {}"
  fullText += "\r\nSkillData.Fishing.Fish = mw.text.jsonDecode('" + formatJSON(Fishing.data) + "')"
  fullText += "\r\nSkillData.Fishing.Areas = mw.text.jsonDecode('" + formatJSON(Fishing.areas) + "')"
  fullText += "\r\nSkillData.Fishing.JunkItems = mw.text.jsonDecode('" + formatJSON(Fishing.junkItems) + "')"
  fullText += "\r\nSkillData.Fishing.SpecialItems = mw.text.jsonDecode('" + formatJSON(Fishing.specialItems) + "')"
 
  // Firemaking
   fullText += "\r\n\r\nSkillData.Firemaking = mw.text.jsonDecode('" + formatJSON(Firemaking.recipes) + "')"
 
  // Cooking
  fullText += "\r\n\r\nSkillData.Cooking = {}"
  fullText += "\r\nSkillData.Cooking.Recipes = mw.text.jsonDecode('" + formatJSON(Cooking.recipes) + "')"
 
  // Mining
  fullText += "\r\n\r\nSkillData.Mining = {}"
  fullText += "\r\nSkillData.Mining.Rocks = mw.text.jsonDecode('" + formatJSON(Mining.rockData) + "')"
 
  // Smithing
  fullText += "\r\n\r\nSkillData.Smithing = {}"
  fullText += "\r\nSkillData.Smithing.Recipes = mw.text.jsonDecode('" + formatJSON(Smithing.recipes) + "')"
 
  // Thieving
  fullText += "\r\n\r\nSkillData.Thieving = {}"
  fullText += "\r\nSkillData.Thieving.NPCs = mw.text.jsonDecode('" + formatJSON(Thieving.npcs) + "')"
  fullText += "\r\nSkillData.Thieving.Areas = mw.text.jsonDecode('" + formatJSON(Thieving.areas) + "')"
  fullText += "\r\nSkillData.Thieving.RareItems = mw.text.jsonDecode('" + formatJSON(Thieving.generalRareItems) + "')"
 
  // Farming
  // The below function returns a modified version of newFarmingAreas, removing various properties
  // from each patch object that relate to what the user has planted & are therefore useless for
  // wiki purposes. Not required, but simply makes the data cleaner.
  function wikiGetFarmingAreas() {
    let allowedPatchKeys = ['level', 'cost']
     let wikiFarmingAreas = []
    for (i = 0; i < newFarmingAreas.length; i++) {
      let keyList = Object.keys(newFarmingAreas[i]).filter((n) => n !== 'patches')
      let newPatches = []
      let newArea = {}
       for (j = 0; j < newFarmingAreas[i].patches.length; j++) {
         let newPatch = {}
        allowedPatchKeys.forEach((k) => newPatch[k] = newFarmingAreas[i].patches[j][k])
        newPatches[j] = newPatch
       }
       }
      keyList.forEach((n) => newArea[n] = newFarmingAreas[i][n])
      newArea['patches'] = newPatches
      wikiFarmingAreas[i] = newArea
     }
     }
     // Adjust structure of equipmentStats data
     return wikiFarmingAreas
    if (itemsAdj[i].equipmentStats !== undefined) {
  }
      var newStats = {}
  fullText += "\r\n\r\nSkillData.Farming = {}"
      var stat = null
  fullText += "\r\nSkillData.Farming.Patches = mw.text.jsonDecode('" + formatJSON(wikiGetFarmingAreas()) + "')"
      for (var j = 0; j < itemsAdj[i].equipmentStats.length; j++) {
 
        stat = itemsAdj[i].equipmentStats[j]
  // Fletching
        if (newStats[stat.key] === undefined) {
  fullText += "\r\n\r\nSkillData.Fletching = {}"
          newStats[stat.key] = stat.value
  fullText += "\r\nSkillData.Fletching.Recipes = mw.text.jsonDecode('" + formatJSON(Fletching.recipes) + "')"
        }
 
        else {
  // Crafting
          newstats[stat.key] += stat.value
  fullText += "\r\n\r\nSkillData.Crafting = {}"
        }
  fullText += "\r\nSkillData.Crafting.Recipes = mw.text.jsonDecode('" + formatJSON(Crafting.recipes) + "')"
      }
 
      itemsAdj[i].equipmentStats = newStats
  // Runecrafting
    }
  fullText += "\r\n\r\nSkillData.Runecrafting = {}"
    // Adjust structure of equipRequirements data, specifically any level requirements
  fullText += "\r\nSkillData.Runecrafting.Recipes = mw.text.jsonDecode('" + formatJSON(Runecrafting.recipes) + "')"
    if (itemsAdj[i].equipRequirements !== undefined) {
 
      var newReqs = {}
  // Herblore
      var req = null
  fullText += "\r\n\r\nSkillData.Herblore = {}"
      for (var j = 0; j < itemsAdj[i].equipRequirements.length; j++) {
  fullText += "\r\nSkillData.Herblore.Potions = mw.text.jsonDecode('" + formatJSON(Herblore.potions) + "')"
        req = itemsAdj[i].equipRequirements[j]
  fullText += "\r\nSkillData.Herblore.TierMasteryLevels = mw.text.jsonDecode('" + formatJSON(Herblore.tierMasteryLevels) + "')"
        if (req.type === "Level") {
 
          newReqs[req.type] = {}
  // Agility
          for (var k = 0; k < req.levels.length; k++) {
  fullText += "\r\n\r\nSkillData.Agility = {}"
            newReqs[req.type][req.levels[k].skill] = req.levels[k].level
  fullText += "\r\nSkillData.Agility.Obstacles = mw.text.jsonDecode('" + formatJSON(Agility.obstacles) + "')"
          }
  fullText += "\r\nSkillData.Agility.Pillars = mw.text.jsonDecode('" + formatJSON(Agility.passivePillars) + "')"
        }
 
        else {
  // Summoning
          newReqs[req.type] = req
  fullText += "\r\n\r\nSkillData.Summoning = {}"
        }
  fullText += "\r\nSkillData.Summoning.RecipeGPCost = mw.text.jsonDecode('" + formatJSON(Summoning.recipeGPCost) + "')"
      }
  fullText += "\r\nSkillData.Summoning.MarkLevels = mw.text.jsonDecode('" + formatJSON(Summoning.markLevels) + "')"
      itemsAdj[i].equipRequirements = newReqs
  fullText += "\r\nSkillData.Summoning.Marks = mw.text.jsonDecode('" + formatJSON(Summoning.marks) + "')"
    }
  fullText += "\r\nSkillData.Summoning.Synergies = mw.text.jsonDecode('" + formatJSON(Summoning.synergies) + "')"
 
  // Astrology
  fullText += "\r\n\r\nSkillData.Astrology = {}"
  fullText += "\r\nSkillData.Astrology.Constellations = mw.text.jsonDecode('" + formatJSON(Astrology.constellations) + "')"
  fullText += "\r\nSkillData.Astrology.BaseStardustChance = mw.text.jsonDecode('" + formatJSON(Astrology.baseStardustChance) + "')"
  fullText += "\r\nSkillData.Astrology.BaseGoldenStardustChance = mw.text.jsonDecode('" + formatJSON(Astrology.baseGoldenStardustChance) + "')"
  fullText += "\r\nSkillData.Astrology.BaseInterval = mw.text.jsonDecode('" + formatJSON(Astrology.baseInterval) + "')"
  fullText += "\r\nSkillData.Astrology.ModifierMagnitudeChances = mw.text.jsonDecode('" + formatJSON(Astrology.modifierMagnitudeChances) + "')"
 
  // Mastery
  var skillKeys = Object.keys(SKILLS);
  var tempUnlocks = {};
  for(var i = 0; i < skillKeys.length; i++) {
  var key = skillKeys[i];
  if(SKILLS[key].hasMastery){
  var chkArray = [];
  var unlockArray = masteryUnlocks[key];
  for(var j = 0; j < unlockArray.length; j++) {
  chkArray[j] = {level: unlockArray[j].level, unlock: getMasteryUnlock(key, j)}
  }
  tempUnlocks[key] = chkArray;
  }
  }
  fullText += "\r\n\r\nSkillData.MasteryUnlocks = mw.text.jsonDecode('" + formatJSON(tempUnlocks) + "')"
 
  var tempCheckpoints = {};
  for(var i = 0; i < skillKeys.length; i++) {
  var key = skillKeys[i];
  if(SKILLS[key].hasMastery){
  var chkArray = [];
  for(var j = 0; j < 4; j++) {
  chkArray[j] = getMasteryCheckpointBonus(key, j)
  }
  tempCheckpoints[key] = {bonuses: chkArray};
  }
  }
  fullText += "\r\n\r\nSkillData.MasteryCheckpoints = mw.text.jsonDecode('" + formatJSON(tempCheckpoints) + "')"
 
  var MasteryPoolXP = []
  for(var i = 0; i < skillKeys.length; i++){
  var key = skillKeys[i];
  if(SKILLS[key].hasMastery){
  MasteryPoolXP[key] = getMasteryPoolTotalXP(key);
  }
   }
   }
  var txt = JSON.stringify(itemsAdj)
   fullText += "\r\n\r\nSkillData.MasteryPoolXP = mw.text.jsonDecode('" + formatJSON(MasteryPoolXP) + "')"
  txt = txt.replace(/\'/g, "\\\'")
  txt = txt.replace(/\\\"/g, "\\\\\"")
   fullText += "\r\n\r\nlocal itemData = {}\r\nitemData.Items = mw.text.jsonDecode('" + txt + "')"


   txt = JSON.stringify(Object.getOwnPropertyNames(new EquipmentStats()))
   var skillMilestones = Object.keys(SKILLS).map(function(s) { if (MILESTONES[SKILLS[s].name] === undefined) { return null } else { return MILESTONES[SKILLS[s].name].length } })
  txt = txt.replace(/\'/g, "\\\'")
   fullText += "\r\n\r\nSkillData.Milestones = mw.text.jsonDecode('" + formatJSON(skillMilestones) + "')"
  txt = txt.replace(/\\\"/g, "\\\\\"")
   fullText += "\r\n\r\nitemData.EquipmentStatKeys = mw.text.jsonDecode('" + txt + "')"


   fullText += "\r\n\r\nreturn itemData"
  // Adventure mode skill unlock costs
   fullText += "\r\n\r\nSkillData.SkillUnlockCosts = mw.text.jsonDecode('" + formatJSON(priceToUnlockSkill) + "')"


  fullText += "\r\n\r\nreturn SkillData"
   console.log(fullText)
   console.log(fullText)
})()
})()
--]]
--]]


local itemData
local SkillData = {}
 
SkillData.Skills = mw.text.jsonDecode('{"0":{"name":"Woodcutting","media":"assets/media/skills/woodcutting/woodcutting.svg","hasMastery":true,"masteryTokenID":481,"maxLevel":99,"miniBarItems"


itemData.EquipmentStatKeys = mw.text.jsonDecode('["attackSpeed","stabAttackBonus","slashAttackBonus","blockAttackBonus","rangedAttackBonus","magicAttackBonus","meleeStrengthBonus","rangedStrengthBonus","magicDamageBonus","meleeDefenceBonus","rangedDefenceBonus","magicDefenceBonus","damageReduction","summoningMaxhit"]')
SkillData.SkillUnlockCosts = mw.text.jsonDecode('[10000,25000,50000,200000,250000,400000,1000000,2500000,10000000,25000000,50000000,100000000,200000000,500000000,500000000,500000000,500000000,500000000,500000000]')


return itemData
return SkillData