Module:AuronTest/ComparisonTables: Difference between revisions

Removed do-nothing function
mNo edit summary
(Removed do-nothing function)
 
(13 intermediate revisions by 2 users not shown)
Line 7: Line 7:
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Items = require('Module:AuronTest')
local Items = require('Module:AuronTest')
local ItemSourceTables = require('Module:AuronTest/SourceTables')
local ItemUseTables = require('Module:AuronTest/UseTables')


local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'}
local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'}
Line 37: Line 35:
     local ndx = 1
     local ndx = 1
     while Shared.tableCount(ignoreColumns) >= ndx do
     while Shared.tableCount(ignoreColumns) >= ndx do
       if 1 ~= 0 then
       if Items._getItemStat(item, ignoreColumns[ndx], true) ~= 0 then
         table.remove(ignoreColumns, ndx)
         table.remove(ignoreColumns, ndx)
       else
       else
Line 92: Line 90:
   end
   end
   if includeModifiers and includeDescription then
   if includeModifiers and includeDescription then
     table.insert(resultPart, '\r\n!colspan="3"|')
     table.insert(resultPart, '\r\n!colspan="2"|')
   elseif includeModifiers or includeDescription then
   elseif includeModifiers or includeDescription then
    table.insert(resultPart, '\r\n!colspan="2"|')
  else
     table.insert(resultPart, '\r\n!colspan="1"|')
     table.insert(resultPart, '\r\n!colspan="1"|')
   end
   end
Line 167: Line 163:
     table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Description')
     table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Description')
   end
   end
  --And finally Sources
  table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Sources')


   table.sort(itemList, function(a, b) return a.id < b.id end)
   table.sort(itemList, function(a, b) return a.id < b.id end)
Line 178: Line 171:
       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(1))
       table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;" |'..Shared.formatnum(Items._getItemStat(item, 'attackSpeed', true)))
       --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, false 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 = 1
         local statValue = Items._getItemStat(item, statName, true)
         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 205: Line 198:
         table.insert(resultPart, item.description ~= nil and item.description or '')
         table.insert(resultPart, item.description ~= nil and item.description or '')
       end
       end
      --Finally, the Sources
      table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0.5em;" |')
      table.insert(resultPart, ' x') --ItemSourceTables._getItemSources(item))
     else
     else
       --Building rows for armour
       --Building rows for armour
Line 214: Line 204:
       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 = 1
         local statValue = Items._getItemStat(item, statName, true)
         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
Line 234: Line 224:
         table.insert(resultPart, item.description ~= nil and item.description or '')
         table.insert(resultPart, item.description ~= nil and item.description or '')
       end
       end
      --Finally, the Sources
      table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0.5em;" |')
      table.insert(resultPart, ' x') --ItemSourceTables._getItemSources(item))
     end
     end
   end
   end


   table.insert(resultPart, '\r\n|}')
   table.insert(resultPart, '\r\n|}')
   return table.concat(resultPart)
   return table.concat(resultPart)
end
end
Line 296: Line 284:
   end
   end


   return p._getEquipmentTable(itemList).."[[Category:getEquipmentTable]]"
   local result = p._getEquipmentTable(itemList).."[[Category:getEquipmentTable]]"
 
  return result
end
end


Line 305: Line 295:


   local itemList = Items.getItems(function(item)
   local itemList = Items.getItems(function(item)
       local isMatch = item.isEquipment
       local isMatch = true
       if isMatch then
       if style == 'Melee' then
        if style == 'Melee' then
        if (Items._getItemStat(item, 'defenceLevelRequired') == nil and Items._getItemStat(item, 'attackLevelRequired') == nil) and not Shared.contains(styleOverrides.Melee, item.name) then isMatch = false end
          if (Items._getItemStat(item, 'defenceLevelRequired') == nil and Items._getItemStat(item, 'attackLevelRequired') == nil) and not Shared.contains(styleOverrides.Melee, item.name) then isMatch = false end
      elseif style == 'Ranged' then
        elseif style == 'Ranged' then
        if Items._getItemStat(item, 'rangedLevelRequired') == nil and not Shared.contains(styleOverrides.Ranged, item.name) then isMatch = false end
          if Items._getItemStat(item, 'rangedLevelRequired') == nil and not Shared.contains(styleOverrides.Ranged, item.name) then isMatch = false end
      elseif style == 'Magic' then
        elseif style == 'Magic' then
        if Items._getItemStat(item, 'magicLevelRequired') == nil and not Shared.contains(styleOverrides.Magic, item.name) then isMatch = false end
          if Items._getItemStat(item, 'magicLevelRequired') == nil and not Shared.contains(styleOverrides.Magic, item.name) then isMatch = false end
      elseif style == 'None' then
        elseif style == 'None' then
        if (Items._getItemStat(item, 'defenceLevelRequired') ~= nil or Items._getItemStat(item, 'rangedLevelRequired') ~= nil or Items._getItemStat(item, 'magicLevelRequired') ~= nil or
          if (Items._getItemStat(item, 'defenceLevelRequired') ~= nil or Items._getItemStat(item, 'rangedLevelRequired') ~= nil or Items._getItemStat(item, 'magicLevelRequired') ~= nil or
          Shared.contains(styleOverrides.Melee, item.name) or Shared.contains(styleOverrides.Ranged, item.name) or Shared.contains(styleOverrides.Magic, item.name)) and
            Shared.contains(styleOverrides.Melee, item.name) or Shared.contains(styleOverrides.Ranged, item.name) or Shared.contains(styleOverrides.Magic, item.name)) and
          not Shared.contains(styleOverrides.None, item.name) then
            not Shared.contains(styleOverrides.None, item.name) then
          isMatch = false
            isMatch = false
          end
         end
         end
        if slot == nil or not Shared.contains(item.validSlots, slot) then isMatch = false end
      end
      if slot == nil or not Shared.contains(item.validSlots, slot) then isMatch = false end


        if isMatch and other ~= nil then
      if isMatch and other ~= nil then
          if slot == 'Weapon' then --For quiver slot or weapon slot, 'other' is the ammo type
        if slot == 'Weapon' then --For quiver slot or weapon slot, 'other' is the ammo type
            if other == 'Arrows' then
          if other == 'Arrows' then
              if item.ammoTypeRequired ~= 0 then isMatch = false end
            if item.ammoTypeRequired ~= 0 then isMatch = false end
            elseif other == 'Bolts' then
          elseif other == 'Bolts' then
              if item.ammoTypeRequired ~= 1 then isMatch = false end
            if item.ammoTypeRequired ~= 1 then isMatch = false end
            end
          end
          elseif slot == 'Quiver' then
        elseif slot == 'Quiver' then
            if other == 'Arrows' then
          if other == 'Arrows' then
              if item.ammoType ~= 0 then isMatch = false end
            if item.ammoType ~= 0 then isMatch = false end
            elseif other == 'Bolts' then
          elseif other == 'Bolts' then
              if item.ammoType ~= 1 then isMatch = false end
            if item.ammoType ~= 1 then isMatch = false end
            elseif other == 'Javelins' then
          elseif other == 'Javelins' then
              if item.ammoType ~= 2 then isMatch = false end
            if item.ammoType ~= 2 then isMatch = false end
            elseif other == 'Throwing Knives' then
          elseif other == 'Throwing Knives' then
              if item.ammoType ~= 3 then isMatch = false end
            if item.ammoType ~= 3 then isMatch = false end
            elseif other == 'Thrown' then
          elseif other == 'Thrown' then
              if item.ammoType ~= 2 and item.ammoType ~= 3 then isMatch = false end
            if item.ammoType ~= 2 and item.ammoType ~= 3 then isMatch = false end
            end
           end
           end
         end
         end
Line 348: Line 336:
     end)
     end)


   return p._getEquipmentTable(itemList, includeModifiers, includeDescription)
   local result = p._getEquipmentTable(itemList, includeModifiers, includeDescription)
 
  return result
end
end


Line 389: Line 379:
     return p._getEquipmentTable(itemList, includeModifiers)
     return p._getEquipmentTable(itemList, includeModifiers)
   end
   end
end
function p.getDoubleLootTable(frame)
  local modsDL = {
    'increasedChanceToDoubleLootCombat',
    'decreasedChanceToDoubleLootCombat',
    'increasedChanceToDoubleLootThieving',
    'decreasedChanceToDoubleLootThieving',
    'increasedChanceToDoubleItemsGlobal',
    'decreasedChanceToDoubleItemsGlobal'
  }
  local modDetail = {}
  for i, modName in pairs(modsDL) do
    local mName, mText, mSign, mIsNeg, mValUnsigned = Constants.getModifierDetails(modName)
    modDetail[modName] = { mult = (mSign == "+" and 1 or -1) }
  end
  local itemList = Items.getItems(function(item)
      if item.modifiers ~= nil then
        for modName, val in pairs(item.modifiers) do
          if Shared.contains(modsDL, modName) then return true end
        end
        return false
      end
    end)
  table.sort(itemList, function(a, b) return a.id < b.id end)
  local resultPart = {}
  table.insert(resultPart, '{| class="wikitable sortable stickyHeader"\r\n|-class="headerRow-0"')
  table.insert(resultPart, '\r\n!colspan="2"|Name!!Bonus!!Description!!Sources')
  for i, item in Shared.skpairs(itemList) do
    local lootValue = 0
    for modName, modDet in pairs(modDetail) do
      lootValue = lootValue + (item.modifiers[modName] or 0) * modDet.mult
    end
    table.insert(resultPart, '\r\n|-')
    table.insert(resultPart, '\r\n|data-sort-value="'..item.name..'"|'..Icons.Icon({item.name, type='item', size=50, notext=true}))
    table.insert(resultPart, '||[['..item.name..']]')
    table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..lootValue..'"|'..lootValue..'%')
    table.insert(resultPart, '||'..item.description)
    table.insert(resultPart, '\r\n| style ="text-align: right;white-space: nowrap;padding: 0 0.5em 0 0.5em;" |')
    table.insert(resultPart, ItemSourceTables._getItemSources(item))
  end
  table.insert(resultPart, '\r\n|}')
  return table.concat(resultPart)
end
function p.getItemTableRows(frame)
  local startID = frame.args ~= nil and frame.args[1] or frame[1]
  local rowCount = frame.args ~= nil and frame.args[2] or frame[2]
  if type(startID ) == 'string' then startID = tonumber(startID) end
  if rowCount == nil then rowCount = 200 end
  if type(rowCount) == 'string' then rowCount = tonumber(rowCount) end
  local rowResult = {}
  for i = startID, startID + rowCount - 1, 1 do
    local item = Items.getItemByID(i)
    if item == nil then break end
    local rowPart = {}
    table.insert(rowPart, '|-\r\n|'..Icons.Icon({item.name, type='item', size='50', notext=true})..'||[['..item.name..']]')
    table.insert(rowPart, '||style="text-align:right;"|'..i..'||'..item.category..'||'..item.type)
    table.insert(rowPart, '||style="text-align:right;" data-sort-value="'..item.sellsFor..'"|'..Icons.GP(item.sellsFor))
    table.insert(rowPart, '||style="text-align:right;"|'..ItemSourceTables._getItemSources(item, false, 'false'))
    table.insert(rowPart, '||style="text-align:right;"|'..ItemUseTables._getItemUses(item, false, 'false'))
    table.insert(rowResult, table.concat(rowPart))
  end
  return table.concat(rowResult, '\r\n')
end
end


Line 475: Line 396:


   --Unfortunately just gonna have to manually check all the changes I think...
   --Unfortunately just gonna have to manually check all the changes I think...
   getSpecificStatString(Items._getItemStat(item1, 'stabAttackBonus'), Items._getItemStat(item2, 'stabAttackBonus'), '{V} '..Icons.Icon({'Melee', notext=true})..' Stab Bonus')
   local statList = {
  getSpecificStatString(Items._getItemStat(item1, 'slashAttackBonus'), Items._getItemStat(item2, 'slashAttackBonus'), '{V} '..Icons.Icon({'Melee', notext=true})..' Slash Bonus')
    -- {'statName', 'statDescription'}
  getSpecificStatString(Items._getItemStat(item1, 'blockAttackBonus'), Items._getItemStat(item2, 'blockAttackBonus'), '{V} '..Icons.Icon({'Melee', notext=true})..' Block Bonus')
    {'stabAttackBonus', '{V} '..Icons.Icon({'Melee', notext=true})..' Stab Bonus'},
 
    {'slashAttackBonus', '{V} '..Icons.Icon({'Melee', notext=true})..' Slash Bonus'},
  getSpecificStatString(Items._getItemStat(item1, 'meleeStrengthBonus'), Items._getItemStat(item2, 'meleeStrengthBonus'), '{V} '..Icons.Icon({'Strength', type='skill', notext=true})..' Strength Bonus')
    {'blockAttackBonus', '{V} '..Icons.Icon({'Melee', notext=true})..' Block Bonus'},
  getSpecificStatString(Items._getItemStat(item1, 'rangedStrengthBonus'), Items._getItemStat(item2, 'rangedStrengthBonus'), '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Strength Bonus')
    {'meleeStrengthBonus', '{V} '..Icons.Icon({'Strength', type='skill', notext=true})..' Strength Bonus'},
  getSpecificStatString(Items._getItemStat(item1, 'magicStrengthBonus'), Items._getItemStat(item2, 'magicStrengthBonus'), '{V}% '..Icons.Icon({'Magic', type='skill', notext=true})..' Damage Bonus')
    {'rangedStrengthBonus', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Strength Bonus'},
 
    {'magicStrengthBonus', '{V}% '..Icons.Icon({'Magic', type='skill', notext=true})..' Damage Bonus'},
  getSpecificStatString(Items._getItemStat(item1, 'meleeDefenceBonus'), Items._getItemStat(item2, 'meleeDefenceBonus'), '{V} '..Icons.Icon({'Defence', type='skill', notext=true})..' Defence Bonus')
    {'meleeDefenceBonus', '{V} '..Icons.Icon({'Defence', type='skill', notext=true})..' Defence Bonus'},
  getSpecificStatString(Items._getItemStat(item1, 'rangedDefenceBonus'), Items._getItemStat(item2, 'rangedDefenceBonus'), '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Defence Bonus')
    {'rangedDefenceBonus', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Defence Bonus'},
  getSpecificStatString(Items._getItemStat(item1, 'magicDefenceBonus'), Items._getItemStat(item2, 'magicDefenceBonus'), '{V} '..Icons.Icon({'Magic', type='skill', notext=true})..' Defence Bonus')
    {'magicDefenceBonus', '{V} '..Icons.Icon({'Magic', type='skill', notext=true})..' Defence Bonus'},
  getSpecificStatString(Items._getItemStat(item1, 'damageReduction'), Items._getItemStat(item2, 'damageReduction'), '{V}% Damage Reduction')
    {'damageReduction', '{V}% Damage Reduction'},
 
    {'increasedSlayerXP', '{V}% '..Icons.Icon({'Slayer', type='skill', notext=true})..' Bonus XP'},
  getSpecificStatString(Items._getItemModifier(item1, 'increasedSkillXP', 'Slayer'), Items._getItemModifier(item2, 'increasedSkillXP', 'Slayer'), '{V}% '..Icons.Icon({'Slayer', type='skill', notext=true})..' Bonus XP')
    {'attackLevelRequired', '{V} '..Icons.Icon({'Attack', type='skill', notext=true})..' Level Required'},
 
    {'defenceLevelRequired', '{V} '..Icons.Icon({'Defence', type='skill', notext=true})..' Level Required'},
  getSpecificStatString(Items._getItemStat(item1, 'attackLevelRequired'), Items._getItemStat(item2, 'attackLevelRequired'), '{V} '..Icons.Icon({'Attack', type='skill', notext=true})..' Level Required')
    {'rangedLevelRequired', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Level Required'},
  getSpecificStatString(Items._getItemStat(item1, 'defenceLevelRequired'), Items._getItemStat(item2, 'defenceLevelRequired'), '{V} '..Icons.Icon({'Defence', type='skill', notext=true})..' Level Required')
    {'magicLevelRequired', '{V} '..Icons.Icon({'Magic', type='skill', notext=true})..' Level Required'},
  getSpecificStatString(Items._getItemStat(item1, 'rangedLevelRequired'), Items._getItemStat(item2, 'rangedLevelRequired'), '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Level Required')
  }
  getSpecificStatString(Items._getItemStat(item1, 'magicLevelRequired'), Items._getItemStat(item2, 'magicLevelRequired'), '{V} '..Icons.Icon({'Magic', type='skill', notext=true})..' Level Required')
  for i, stat in ipairs(statList) do
    if stat[1] == 'increasedSlayerXP' then
      getSpecificStatString(Items._getItemModifier(item1, stat[1], 'Slayer'), Items._getItemModifier(item2, stat[1], 'Slayer'), stat[2])
    else
      getSpecificStatString(Items._getItemStat(item1, stat[1]), Items._getItemStat(item2, stat[1]), stat[2])
    end
  end


   return table.concat(changeArray, '<br/>')
   return table.concat(changeArray, '<br/>')