Anonymous

Module:Sandbox/AuronTest/ComparisonTables: Difference between revisions

From Melvor Idle
m
no edit summary
mNo edit summary
mNo edit summary
Line 171: Line 171:
   table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Sources')
   table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Sources')


  local equipStats, levelReqs = {}, {}
  local getStatValue = function(item, statName)
    if string.find(statName, '^(.+)LevelRequired$') ~= nil then
      -- Level requirement
      local skillName = Shared.titleCase(string.match(statName, '^(.+)LevelRequired$'))
      return levelReqs[skillName] or 0
    elseif Shared.contains(ItemData.EquipmentStatKeys, statName) then
      -- Equipment stat
      return equipStats[statName] or 0
    else
      -- Something else that we'll assume _getItemStat() will handle
      return Items._getItemStat(item, statName, true)
    end
  end
   table.sort(itemList, function(a, b) return a.id < b.id end)
   table.sort(itemList, function(a, b) return a.id < b.id end)
   for i, item in pairs(itemList) do
   for i, item in pairs(itemList) do
    equipStats = Items._processEquipmentStats(item.equipmentStats)
    levelReqs = Items._processEquipmentLevelReqs(item.equipRequirements)
     if isWeaponType then
     if isWeaponType then
       --Building rows for weapons
       --Building rows for weapons
Line 194: Line 178:
       table.insert(resultPart, '\r\n|style ="text-align: left;padding: 0 0 0 0;"|'..Icons.Icon({item.name, type='item', size=50, notext=true}))
       table.insert(resultPart, '\r\n|style ="text-align: left;padding: 0 0 0 0;"|'..Icons.Icon({item.name, type='item', size=50, notext=true}))
       table.insert(resultPart, '\r\n|style ="text-align: left;padding: 0 0.5em 0 0.5em;"|[['..item.name..']]')
       table.insert(resultPart, '\r\n|style ="text-align: left;padding: 0 0.5em 0 0.5em;"|[['..item.name..']]')
       table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;" |'..Shared.formatnum(equipStats.attackSpeed))
       table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;" |'..Shared.formatnum(Items._getItemStat(item, 'attackSpeed')))
       --That's the first list out of the way, now for 2-Handed
       --That's the first list out of the way, now for 2-Handed
       table.insert(resultPart, '\r\n| style ="text-align: right;"|')
       table.insert(resultPart, '\r\n| style ="text-align: right;"|')
       table.insert(resultPart, Items._getItemStat(item, 'isTwoHanded') and 'Yes' or 'No')
       table.insert(resultPart, Items._getItemStat(item, 'isTwoHanded') and 'Yes' or 'No')
       for j, statName in pairs(statColumns) do
       for j, statName in pairs(statColumns) do
         local statValue = getStatValue(item, statName)
         local statValue = Items._getItemStat(item, statName)
         table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;')
         table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;')
         if string.find(statName, '^(.+)LevelRequired$') == nil then
         if string.find(statName, '^(.+)LevelRequired$') == nil then
Line 230: Line 214:
       table.insert(resultPart, '\r\n|style ="text-align: left;padding: 0 0.5em 0 0.5em;"|[['..item.name..']]')
       table.insert(resultPart, '\r\n|style ="text-align: left;padding: 0 0.5em 0 0.5em;"|[['..item.name..']]')
       for j, statName in pairs(statColumns) do
       for j, statName in pairs(statColumns) do
         local statValue = getStatValue(item, statName)
         local statValue = Items._getItemStat(item, statName)
         table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;')
         table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;')
         if statValue > 0 then
         if statValue > 0 then