Module:Sandbox/AuronTest/ComparisonTables: Difference between revisions

removing sources and seeing if that does anything helpful
(testing what happens if I remove the icons)
(removing sources and seeing if that does anything helpful)
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 171: Line 169:
     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 209: Line 204:
         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, ItemSourceTables._getItemSources(item))
     else
     else
       --Building rows for armour
       --Building rows for armour
       table.insert(resultPart, '\r\n|-')
       table.insert(resultPart, '\r\n|-')
       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..']]')
       for j, statName in pairs(statColumns) do
       for j, statName in pairs(statColumns) do
Line 238: Line 230:
         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, ItemSourceTables._getItemSources(item))
     end
     end
   end
   end
Line 408: Line 397:
     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