Module:Sandbox/Skills/data: Difference between revisions

m
no edit summary
(Invert attacker/target for special descriptions)
mNo edit summary
Line 1: Line 1:
-- Version: ALPHA V0.21 (?1113)
--[[The text to decode can be generated in the console via
--[[The text to decode can be generated in the console via
(function() {
(function() {
Line 14: Line 16:
   for (var i = 0; i < items.length; i++) {
   for (var i = 0; i < items.length; i++) {
     itemsAdj[i] = {...items[i]}
     itemsAdj[i] = {...items[i]}
     // Amend elements of specialAttacks to be IDs rather than objects
     // Amend elements of specialAttacks to include descriptions
     if (itemsAdj[i].specialAttacks !== undefined) {
     if (itemsAdj[i].specialAttacks !== undefined) {
       itemsAdj[i].specialAttacks = itemsAdj[i].specialAttacks.map((i, idx) => i.id)
       for (var j = 0; j < itemsAdj[i].specialAttacks.length; j++) {
        itemsAdj[i].specialAttacks[j].description = describeAttack(itemsAdj[i].specialAttacks[j], youNoun, enemyNoun).replaceAll(/<span class=\".+?\">(.+?)<\/span>/ig, '$1')
      }
     }
     }
   }
   }
Line 23: Line 27:
   txt = txt.replace(/\\\"/g, "\\\\\"")
   txt = txt.replace(/\\\"/g, "\\\\\"")
   fullText += "\r\n\r\nlocal itemData = {}\r\nitemData.Items = mw.text.jsonDecode('" + txt + "')"
   fullText += "\r\n\r\nlocal itemData = {}\r\nitemData.Items = mw.text.jsonDecode('" + txt + "')"
  var attacksByID = []
  for (const k of Object.keys(attacks)) {
    var a = attacks[k]
    attacksByID[a.id] = {...a}
    attacksByID[a.id].key = k
    // attacksByID[a.id].descTemplate = a.description
    attacksByID[a.id].description = describeAttack(a, youNoun, enemyNoun).replaceAll(/<span class=\".+?\">(.+?)<\/span>/ig, '$1')
  }
  txt = JSON.stringify(attacksByID)
  txt = txt.replace(/\'/g, "\\\'")
  txt = txt.replace(/\\\"/g, "\\\\\"")
  fullText += "\r\n\r\nitemData.SpecialAttacks = mw.text.jsonDecode('" + txt + "')"


   txt = JSON.stringify(Object.getOwnPropertyNames(new EquipmentStats()))
   txt = JSON.stringify(Object.getOwnPropertyNames(new EquipmentStats()))
Line 47: Line 38:
})()
})()
--]]
--]]
-- Version: ALPHA V0.21 (?1105)


local itemData = {}
local itemData = {}
itemData.Items
itemData


itemData.EquipmentStatKeys = mw.text.jsonDecode('["attackSpeed","stabAttackBonus","slashAttackBonus","blockAttackBonus","rangedAttackBonus","magicAttackBonus","meleeStrengthBonus","rangedStrengthBonus","magicDamageBonus","meleeDefenceBonus","rangedDefenceBonus","magicDefenceBonus","damageReduction","summoningMaxhit"]')
itemData.EquipmentStatKeys = mw.text.jsonDecode('["attackSpeed","stabAttackBonus","slashAttackBonus","blockAttackBonus","rangedAttackBonus","magicAttackBonus","meleeStrengthBonus","rangedStrengthBonus","magicDamageBonus","meleeDefenceBonus","rangedDefenceBonus","magicDefenceBonus","damageReduction","summoningMaxhit"]')


return itemData
return itemData