Module:Sandbox/AuronTest/SourceTables: Difference between revisions

0.21 testing
(Clone live module)
 
(0.21 testing)
Line 2: Line 2:


local MonsterData = mw.loadData('Module:Monsters/data')
local MonsterData = mw.loadData('Module:Monsters/data')
local ItemData = mw.loadData('Module:Items/data')
local ItemData = mw.loadData('Module:AuronTest/data')
local SkillData = mw.loadData('Module:Skills/data')
local SkillData = mw.loadData('Module:Skills/data')
local Constants = mw.loadData('Module:Constants/data')


local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Magic = require('Module:Magic')
local Magic = require('Module:Magic')
local Areas = require('Module:CombatAreas')
local Areas = require('Module:CombatAreas')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Items = require('Module:Items')
local Items = require('Module:AuronTest')
local Shop = require('Module:Shop')
local Shop = require('Module:Shop')
local Monsters = require('Module:Monsters')
local Monsters = require('Module:Monsters')
Line 34: Line 34:
   local qty = nil
   local qty = nil
   local req = nil
   local req = nil
  local result = ''


   local tables = {}
   local tables = {}
Line 82: Line 81:
     skill = 'Herblore'
     skill = 'Herblore'
     req = item.herbloreReq
     req = item.herbloreReq
     --Currently using 'herbloreMasteryID' as shorthand to find details, could be a better method
     --Currently using 'masteryID' as shorthand to find details, could be a better method
     local potionID = item.herbloreMasteryID
     local potionID = item.masteryID[2]
     local potionData = SkillData.Herblore.ItemData[potionID + 1]
     local potionData = SkillData.Herblore.ItemData[potionID + 1]
     lvl = potionData.herbloreLevel
     lvl = potionData.herbloreLevel
Line 90: Line 89:
     table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time))
     table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time))
   end
   end
   if item.miningID ~= nil then
   if item.masteryID ~= nil and item.masteryID[1] == 4 then
     skill = 'Mining'
     skill = 'Mining'
     lvl = SkillData.Mining.Rocks[item.masteryID[2] + 1].level
     lvl = SkillData.Mining.Rocks[item.masteryID[2] + 1].level
Line 184: Line 183:
           local item = Items.getItemByID(cost.id)
           local item = Items.getItemByID(cost.id)
           if item.type ~= 'Shard' then
           if item.type ~= 'Shard' then
             local sellPrice = item.sellsFor
             local sellPrice = math.max(item.sellsFor, 20)
            if sellPrice < 20 then sellPrice = 20 end
             table.insert(nonShardArray, Icons.Icon({item.name, type='item', notext=true, qty=math.max(1, math.floor(recipeGPCost / sellPrice))}))
             table.insert(nonShardArray, Icons.Icon({item.name, type='item', notext=true, qty=math.max(1, math.floor(recipeGPCost / sellPrice))}))
           end
           end
Line 208: Line 206:
     table.insert(tables, p.buildAltMagicTable('Just Learning'))
     table.insert(tables, p.buildAltMagicTable('Just Learning'))
   elseif item.name == 'Bones' then
   elseif item.name == 'Bones' then
     table.insert(tables, p.buildAltMagicTable('Bone Offering'))
     table.insert(tables, p.buildAltMagicTable('Bone Offering'))
   elseif item.name == 'Holy Dust' then
   elseif item.name == 'Holy Dust' then
     table.insert(tables, p.buildAltMagicTable('Blessed Offering'))
     table.insert(tables, p.buildAltMagicTable('Blessed Offering'))
Line 222: Line 220:
function p.buildAltMagicTable(spellName)
function p.buildAltMagicTable(spellName)
   local spell = Magic.getSpell(spellName, 'AltMagic')
   local spell = Magic.getSpell(spellName, 'AltMagic')
   local result = '{|class="wikitable"\r\n|-'
   local resultPart = {}
   result = result..'\r\n!colspan="2"|'..Icons.Icon({spell.name, type='spell'})
  table.insert(resultPart, '{|class="wikitable"\r\n|-')
   result = result..'\r\n|-\r\n!style="text-align:right;"|Requirements'
   table.insert(resultPart, '\r\n!colspan="2"|'..Icons.Icon({spell.name, type='spell'}))
   result = result..'\r\n|'..Icons._SkillReq('Magic', spell.magicLevelRequired)
   table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Requirements')
   table.insert(resultPart, '\r\n|'..Icons._SkillReq('Magic', spell.magicLevelRequired))
   -- 1 means select any item. 0 would mean Superheat, but that's handled elsewhere
   -- 1 means select any item. 0 would mean Superheat, but that's handled elsewhere
   -- -1 means no item is needed, so hide this section
   -- -1 means no item is needed, so hide this section
   if spell.selectItem == 1 then
   if spell.selectItem == 1 then
     result = result..'\r\n|-\r\n!style="text-align:right;"|Materials'
     table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Materials')
     result = result..'\r\n|1 of any item'
     table.insert(resultPart, '\r\n|1 of any item')
   end
   end
   --Add runes
   --Add runes
   result = result..'\r\n|-\r\n!style="text-align:right;"|Runes\r\n|'
   table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Runes\r\n|')
   for i, req in pairs(spell.runesRequired) do
   for i, req in pairs(spell.runesRequired) do
     local rune = Items.getItemByID(req.id)
     local rune = Items.getItemByID(req.id)
     if i > 1 then result = result..', ' end
     if i > 1 then table.insert(resultPart, ', ') end
     result = result..Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})
     table.insert(resultPart, Icons.Icon({rune.name, type='item', notext=true, qty=req.qty}))
   end
   end
   if spell.runesRequiredAlt ~= nil and Shared.tableCount(spell.runesRequired) ~= Shared.tableCount(spell.runesRequiredAlt) then
   if spell.runesRequiredAlt ~= nil and Shared.tableCount(spell.runesRequired) ~= Shared.tableCount(spell.runesRequiredAlt) then
     result = result.."<br/>'''OR'''<br/>"
     table.insert(resultPart, "<br/>'''OR'''<br/>")
     for i, req in pairs(spell.runesRequiredAlt) do
     for i, req in pairs(spell.runesRequiredAlt) do
       local rune = Items.getItemByID(req.id)
       local rune = Items.getItemByID(req.id)
       if i > 1 then result = result..', ' end
       if i > 1 then table.insert(resultPart, ', ') end
       result = result..Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})
       table.insert(resultPart, Icons.Icon({rune.name, type='item', notext=true, qty=req.qty}))
     end
     end
   end
   end


   --Now just need the output quantity, xp, and casting time (which is always 2)
   --Now just need the output quantity, xp, and casting time (which is always 2)
   result = result..'\r\n|-\r\n!style="text-align:right;"|Base Quantity\r\n|'..spell.convertToQty
   table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Quantity\r\n|'..spell.convertToQty)
   result = result..'\r\n|-\r\n!style="text-align:right;"|Base XP\r\n|'..spell.magicXP
   table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base XP\r\n|'..spell.magicXP)
   result = result..'\r\n|-\r\n!style="text-align:right;"|Cast Time\r\n|2s'
   table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Cast Time\r\n|2s')
   result = result..'\r\n|}'
   table.insert(resultPart, '\r\n|}')
   return result
   return table.concat(resultPart)
end
end


function p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq)
function p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq)
   if qty == nil then qty = 1 end
   if qty == nil then qty = 1 end
   local result = '{|class="wikitable"'
   local resultPart = {}
  table.insert(resultPart, '{|class="wikitable"')
   if req ~= nil then
   if req ~= nil then
     result = result..'\r\n!colspan="2"|Item Creation'
     table.insert(resultPart, '\r\n!colspan="2"|Item Creation')
   else
   else
     result = result..'\r\n!colspan="2"|Item Production'
     table.insert(resultPart, '\r\n!colspan="2"|Item Production')
   end
   end
   result = result..'\r\n|-\r\n!style="text-align: right;"|Requirements'
   table.insert(resultPart, '\r\n|-\r\n!style="text-align: right;"|Requirements')
   result = result..'\r\n|'..Icons._SkillReq(skill, lvl)
   table.insert(resultPart, '\r\n|'..Icons._SkillReq(skill, lvl))
   if specialReq ~= nil then result = result..'<br/>'..specialReq end
   if specialReq ~= nil then table.insert(resultPart, '<br/>'..specialReq) end


   if req ~= nil then  
   if req ~= nil then
     result = result..'\r\n|-\r\n!style="text-align: right;"|Materials\r\n|'
     table.insert(resultPart, '\r\n|-\r\n!style="text-align: right;"|Materials\r\n|')
     if type(req) == 'table' then
     if type(req) == 'table' then
       for i, mat in pairs(req) do
       for i, mat in pairs(req) do
         if i > 1 then result = result..'<br/>' end
         if i > 1 then table.insert(resultPart, '<br/>') end
         local matItem = Items.getItemByID(mat.id)
         local matItem = Items.getItemByID(mat.id)
         if matItem == nil then
         if matItem == nil then
           result = result..mat.qty..'x ?????'
           table.insert(resultPart, mat.qty..'x ?????')
         else
         else
           result = result..Icons.Icon({matItem.name, type='item', qty=mat.qty})
           table.insert(resultPart, Icons.Icon({matItem.name, type='item', qty=mat.qty}))
         end
         end
       end
       end
     else
     else
     result = result..req
     table.insert(resultPart, req)
     end
     end
   end
   end
   result = result..'\r\n|-\r\n!style="text-align:right;"|Base Quantity'
   table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Quantity')
   result = result..'\r\n|'..qty
   table.insert(resultPart, '\r\n|'..qty)
   result = result..'\r\n|-\r\n!style="text-align:right;"|Base Experience'
   table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Experience')
   result = result..'\r\n|'..Shared.formatnum(xp)..' XP'
   table.insert(resultPart, '\r\n|'..Shared.formatnum(xp)..' XP')
   result = result..'\r\n|-\r\n!style="text-align:right;"|Base Creation Time'
   table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Creation Time')
   result = result..'\r\n|'..Shared.formatnum(Shared.round(time, 2, 0))..'s'
   table.insert(resultPart, '\r\n|'..Shared.formatnum(Shared.round(time, 2, 0))..'s')
   if maxTime ~= nil then result = result..' - '..Shared.formatnum(Shared.round(maxTime, 2, 0))..'s' end
   if maxTime ~= nil then table.insert(resultPart, ' - '..Shared.formatnum(Shared.round(maxTime, 2, 0))..'s') end
   result = result..'\r\n|}'
   table.insert(resultPart, '\r\n|}')


   return result
   return table.concat(resultPart)
end
end


Line 302: Line 302:
     return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
     return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
   end
   end
 
 
   return p._getCreationTable(item)
   return p._getCreationTable(item)
end
end


function p._getItemSources(item, asList, addCategories)
function p._getItemSources(item, asList, addCategories)
  local result = nil
   local lineArray = {}
   local lineArray = {}
   local categoryArray = {}
   local categoryArray = {}
Line 346: Line 345:
         --If this is a boss then we actually are completing dungeons for this and need to figure out which one
         --If this is a boss then we actually are completing dungeons for this and need to figure out which one
         for j, dung in pairs(areaList) do
         for j, dung in pairs(areaList) do
           if string.len(dungeonStr) > 0 then  
           if string.len(dungeonStr) > 0 then
             dungeonStr = dungeonStr..','
             dungeonStr = dungeonStr..','
           else
           else
Line 483: Line 482:


   --MineCheck:
   --MineCheck:
   if item.miningID ~= nil then
   if item.masteryID ~= nil and item.masteryID[1] == 4 then
     table.insert(lineArray, Icons._SkillReq("Mining", SkillData.Mining.Rocks[item.masteryID[2] + 1].level))
     table.insert(lineArray, Icons._SkillReq("Mining", SkillData.Mining.Rocks[item.masteryID[2] + 1].level))
   end
   end
Line 495: Line 494:


   --HerbCheck:
   --HerbCheck:
   if item.herbloreMasteryID ~= nil then
   if item.masteryID ~= nil and item.masteryID[1] == 19 then
     local potionData = SkillData.Herblore.ItemData[item.herbloreMasteryID + 1].herbloreLevel
     local potionData = SkillData.Herblore.ItemData[item.masteryID[2] + 1].herbloreLevel
     table.insert(lineArray, Icons._SkillReq("Herblore", potionData))
     table.insert(lineArray, Icons._SkillReq("Herblore", potionData))
   end
   end
Line 563: Line 562:


   --Tokens are from the appropriate skill
   --Tokens are from the appropriate skill
   if item.isToken then
   if item.isToken and item.skill ~= nil then
    for skill, id in pairs(Constants.skill) do
    table.insert(lineArray, Icons._SkillReq(Constants.getSkillName(item.skill), 1))
      if id == item.skill then
        table.insert(lineArray, Icons._SkillReq(skill, 1))
      end
    end
   end
   end


Line 582: Line 577:
   end
   end


   local result = ''
   local resultPart = {}
   if asList then
   if asList then
     result = '* '..table.concat(lineArray, "\r\n* ")
     table.insert(resultPart, '* '..table.concat(lineArray, "\r\n* "))
   else
   else
     result = table.concat(lineArray, "<br/>")
     table.insert(resultPart, '<div style="max-width:180px;text-align:right">' .. table.concat(lineArray, "<br/>") .. '</div>')
    result = '<div style="max-width:180px;text-align:right">'..result..'</div>'
   end
   end
   if addCategories then result = result..table.concat(categoryArray, '') end
   if addCategories then table.insert(resultPart, table.concat(categoryArray, '')) end
   return result
   return table.concat(resultPart)
end
end


Line 598: Line 592:
   local asList = false
   local asList = false
   local addCategories = false
   local addCategories = false
   if frame.args ~= nil then  
   if frame.args ~= nil then
     asList = frame.args.asList ~= nil and frame.args.asList ~= '' and frame.args.asList ~= 'false'
     asList = frame.args.asList ~= nil and frame.args.asList ~= '' and frame.args.asList ~= 'false'
     addCategories = frame.args.addCategories ~= nil and frame.args.addCategories ~= '' and frame.args.addCategories ~= 'false'
     addCategories = frame.args.addCategories ~= nil and frame.args.addCategories ~= '' and frame.args.addCategories ~= 'false'
Line 610: Line 604:


function p._getItemLootSourceTable(item)
function p._getItemLootSourceTable(item)
   local result = '{| class="wikitable sortable stickyHeader"'
   local resultPart = {}
   result = result..'\r\n|- class="headerRow-0"'
  table.insert(resultPart, '{| class="wikitable sortable stickyHeader"')
   result = result..'\r\n!Source!!Source Type!!Quantity!!colspan="2"|Chance'
   table.insert(resultPart, '\r\n|- class="headerRow-0"')
   table.insert(resultPart, '\r\n!Source!!Source Type!!Quantity!!colspan="2"|Chance')


   --Set up function for adding rows
   --Set up function for adding rows
   local buildRow = function(source, type, minqty, qty, weight, totalWeight)
   local buildRow = function(source, type, minqty, qty, weight, totalWeight)
     if minqty == nil then minqty = 1 end
     if minqty == nil then minqty = 1 end
     local rowTxt = '\r\n|-'
     local rowPart = {}
     rowTxt = rowTxt..'\r\n|style="text-align: left;"|'..source
    table.insert(rowPart, '\r\n|-')
     rowTxt = rowTxt..'\r\n|style="text-align: left;"|'..type
     table.insert(rowPart, '\r\n|style="text-align: left;"|'..source)
     table.insert(rowPart, '\r\n|style="text-align: left;"|'..type)


     rowTxt = rowTxt..'\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..minqty
     table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..minqty)
     if qty ~= minqty then rowTxt = rowTxt..' - '..qty end
     if qty ~= minqty then table.insert(rowPart, ' - '..qty) end
     local chance = Shared.round(weight / totalWeight * 100, 2, 2)
     local chance = Shared.round(weight / totalWeight * 100, 2, 2)
     if weight >= totalWeight then
     if weight >= totalWeight then
       -- Fraction would be 1/1, so only show the percentage
       -- Fraction would be 1/1, so only show the percentage
       chance = 100
       chance = 100
       rowTxt = rowTxt .. '\r\n|colspan="2" '
       table.insert(rowPart, '\r\n|colspan="2" ')
     else
     else
       rowTxt = rowTxt .. '\r\n|style="text-align: right;" data-sort-value="' .. chance .. '"| ' .. Shared.fraction(weight, totalWeight) .. '\r\n|'
       table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="' .. chance .. '"| ' .. Shared.fraction(weight, totalWeight) .. '\r\n|')
     end
     end
     rowTxt = rowTxt..'style="text-align: right;" data-sort-value="'.. chance .. '"|'..chance..'%'
     table.insert(rowPart, 'style="text-align: right;" data-sort-value="'.. chance .. '"|'..chance..'%')
     return rowTxt
     return table.concat(rowPart)
   end
   end
   local dropRows = {}
   local dropRows = {}
Line 769: Line 765:
   if Shared.tableCount(dropRows) == 0 then return '' end
   if Shared.tableCount(dropRows) == 0 then return '' end


   table.sort(dropRows, function(a, b)  
   table.sort(dropRows, function(a, b)
                         if a.weight / a.totalWeight == b.weight / b.totalWeight then
                         if a.weight / a.totalWeight == b.weight / b.totalWeight then
                           return a.minqty + a.qty > b.minqty + b.qty
                           return a.minqty + a.qty > b.minqty + b.qty
Line 777: Line 773:
                       end)
                       end)
   for i, data in pairs(dropRows) do
   for i, data in pairs(dropRows) do
     result = result..buildRow(data.source, data.type, data.minqty, data.qty, data.weight, data.totalWeight)
     table.insert(resultPart, buildRow(data.source, data.type, data.minqty, data.qty, data.weight, data.totalWeight))
   end
   end


   result = result..'\r\n|}'
   table.insert(resultPart, '\r\n|}')
   return result
   return table.concat(resultPart)
end
end


Line 795: Line 791:


function p._getItemUpgradeTable(item)
function p._getItemUpgradeTable(item)
   local result = ''
   local resultPart = {}
   if item.itemsRequired ~= nil then
   if item.itemsRequired ~= nil then
     --First, get details on all the required materials
     --First, get details on all the required materials
Line 811: Line 807:
       table.insert(materials, Icons.GP(item.trimmedGPCost))
       table.insert(materials, Icons.GP(item.trimmedGPCost))
     end
     end
     result = '{| class="wikitable"\r\n|-\r\n!colspan="2"|[[Upgrading Items|Item Upgrade]]'
     table.insert(resultPart, '{| class="wikitable"\r\n|-\r\n!colspan="2"|[[Upgrading Items|Item Upgrade]]')
     --[[result = result..'\r\n|-\r\n!style="text-align:right;"|Upgrades From\r\n|'
     --[[result = result..'\r\n|-\r\n!style="text-align:right;"|Upgrades From\r\n|'
     result = result..table.concat(upgradeFrom, '<br/>')--]]
     result = result..table.concat(upgradeFrom, '<br/>')--]]
     result = result..'\r\n|-\r\n!style="text-align:right;"|Materials\r\n|'
     table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Materials\r\n|')
     result = result..table.concat(materials, '<br/>')
     table.insert(resultPart, table.concat(materials, '<br/>'))
     result = result..'\r\n|}'
     table.insert(resultPart, '\r\n|}')
   end
   end
   return result
   return table.concat(resultPart)
end
end


Line 844: Line 840:
     end
     end
   end
   end
  --Set up the header
  --Set up the header
   local superheatTable = '{|class="wikitable"\r\n!colspan="2"|Spell'
   local superheatTable = {}
   superheatTable = superheatTable..'!!'..Icons.Icon({'Smithing', type='skill', notext='true'})..' Level'
  table.insert(superheatTable, '{|class="wikitable"\r\n!colspan="2"|Spell')
   superheatTable = superheatTable..'!!'..Icons.Icon({'Magic', type='skill', notext='true'})..' Level'
   table.insert(superheatTable, '!!'..Icons.Icon({'Smithing', type='skill', notext='true'})..' Level')
   superheatTable = superheatTable..'!!'..Icons.Icon({'Magic', type='skill', notext='true'})..' XP'
   table.insert(superheatTable, '!!'..Icons.Icon({'Magic', type='skill', notext='true'})..' Level')
   superheatTable = superheatTable..'!!'..Icons.Icon({item.name, type='item', notext='true'})..' Bars'
   table.insert(superheatTable, '!!'..Icons.Icon({'Magic', type='skill', notext='true'})..' XP')
   superheatTable = superheatTable..'!!Ore!!Runes'
   table.insert(superheatTable, '!!'..Icons.Icon({item.name, type='item', notext='true'})..' Bars')
   table.insert(superheatTable, '!!Ore!!Runes')
   --Loop through all the variants
   --Loop through all the variants
   local spellNames = {'Superheat I', 'Superheat II', 'Superheat III', 'Superheat IV'}
   local spellNames = {'Superheat I', 'Superheat II', 'Superheat III', 'Superheat IV'}
   for i, sName in pairs(spellNames) do
   for i, sName in pairs(spellNames) do
     local spell = Magic.getSpell(sName, 'AltMagic')
     local spell = Magic.getSpell(sName, 'AltMagic')
     local rowTxt = '\r\n|-\r\n|'..Icons.Icon({spell.name, type='spell', notext=true, size=50})
     local rowPart = {}
     rowTxt = rowTxt..'||[['..spell.name..']]||'..item.smithingLevel
    table.insert(rowPart, '\r\n|-\r\n|'..Icons.Icon({spell.name, type='spell', notext=true, size=50}))
     rowTxt = rowTxt..'||'..spell.magicLevelRequired..'||'..spell.magicXP..'||'..spell.convertToQty
     table.insert(rowPart, '||[['..spell.name..']]||'..item.smithingLevel)
     rowTxt = rowTxt..'||'..oreString
     table.insert(rowPart, '||'..spell.magicLevelRequired..'||'..spell.magicXP..'||'..spell.convertToQty)
     if spell.ignoreCoal ~= nil and not spell.ignoreCoal then rowTxt = rowTxt..coalString end
     table.insert(rowPart, '||'..oreString)
     rowTxt = rowTxt..'||style="text-align:center"|'
     if spell.ignoreCoal ~= nil and not spell.ignoreCoal then table.insert(rowPart, coalString) end
     table.insert(rowPart, '||style="text-align:center"|')
     for i, req in pairs(spell.runesRequired) do
     for i, req in pairs(spell.runesRequired) do
       local rune = Items.getItemByID(req.id)
       local rune = Items.getItemByID(req.id)
       if i > 1 then rowTxt = rowTxt..', ' end
       if i > 1 then table.insert(rowPart, ', ') end
       rowTxt = rowTxt..Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})
       table.insert(rowPart, Icons.Icon({rune.name, type='item', notext=true, qty=req.qty}))
     end
     end
     rowTxt = rowTxt.."<br/>'''OR'''<br/>"
     table.insert(rowPart, "<br/>'''OR'''<br/>")
     for i, req in pairs(spell.runesRequiredAlt) do
     for i, req in pairs(spell.runesRequiredAlt) do
       local rune = Items.getItemByID(req.id)
       local rune = Items.getItemByID(req.id)
       if i > 1 then rowTxt = rowTxt..', ' end
       if i > 1 then table.insert(rowPart, ', ') end
       rowTxt = rowTxt..Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})
       table.insert(rowPart, Icons.Icon({rune.name, type='item', notext=true, qty=req.qty}))
     end
     end
     superheatTable = superheatTable..rowTxt
     table.insert(superheatTable, table.concat(rowPart))
   end
   end
   --Add the table end and add the table to the result string
   --Add the table end and add the table to the result string
   superheatTable = superheatTable..'\r\n|}'
   table.insert(superheatTable, '\r\n|}')
   return superheatTable
   return table.concat(superheatTable)
end
end


Line 890: Line 888:


function p._getItemSourceTables(item)
function p._getItemSourceTables(item)
   local result = ''
   local resultPart = {}
   local shopTable = Shop._getItemShopTable(item)
   local shopTable = Shop._getItemShopTable(item)
   if string.len(shopTable) > 0 then
   if string.len(shopTable) > 0 then
     result = result..'===Shop===\r\n'..shopTable
     table.insert(resultPart, '===Shop===\r\n'..shopTable)
   end
   end


   local creationTable = p._getCreationTable(item)
   local creationTable = p._getCreationTable(item)
   if string.len(creationTable) > 0 then  
   if string.len(creationTable) > 0 then
     if string.len(result) > 0 then result = result..'\r\n' end
     if #resultPart > 0 then table.insert(resultPart, '\r\n') end
     result = result..'===Creation===\r\n'..creationTable  
     table.insert(resultPart, '===Creation===\r\n'..creationTable)
   end
   end


   local upgradeTable = p._getItemUpgradeTable(item)
   local upgradeTable = p._getItemUpgradeTable(item)
   if string.len(upgradeTable) > 0 then
   if string.len(upgradeTable) > 0 then
     if string.len(result) > 0 then result = result..'\r\n' end
     if #resultPart > 0 then table.insert(resultPart, '\r\n') end
     if string.len(creationTable) == 0 then result = result..'===Creation===\r\n' end
     if string.len(creationTable) == 0 then table.insert(resultPart, '===Creation===\r\n') end
     result = result..upgradeTable
     table.insert(resultPart, upgradeTable)
   end
   end


   if item.type == 'Bar' then
   if item.type == 'Bar' then
     result = result..'\r\n==='..Icons.Icon({'Alt Magic', type='skill'})..'===\r\n'..p._getItemSuperheatTable(item)
     table.insert(resultPart, '\r\n==='..Icons.Icon({'Alt Magic', type='skill'})..'===\r\n'..p._getItemSuperheatTable(item))
   end
   end


   local lootTable = p._getItemLootSourceTable(item)
   local lootTable = p._getItemLootSourceTable(item)
   if string.len(lootTable) > 0 then
   if string.len(lootTable) > 0 then
     if string.len(result) > 0 then result = result..'\r\n' end
     if #resultPart > 0 then table.insert(resultPart, '\r\n') end
     result = result..'===Loot===\r\n'..lootTable
     table.insert(resultPart, '===Loot===\r\n'..lootTable)
   end
   end
   return result
   return table.concat(resultPart)
end
end


Line 932: Line 930:


function p.getCombatPassiveSlotItems(frame)
function p.getCombatPassiveSlotItems(frame)
   local result = '{| class="wikitable"\r\n'
   local resultPart = {}
   result = result..'|-\r\n'
  table.insert(resultPart, '{| class="wikitable"\r\n')
   result = result..'!colspan="2"|Item\r\n! Passive\r\n'
   table.insert(resultPart, '|-\r\n')
   table.insert(resultPart, '!colspan="2"|Item\r\n! Passive\r\n')


   local itemArray = Items.getItems(function(item) return item.isPassiveItem and true or false end)
   local itemArray = Items.getItems(function(item) return item.validSlots ~= nil and Shared.contains(item.validSlots, 'Passive') end)


   table.sort(itemArray, function(a, b) return a.id < b.id end)
   table.sort(itemArray, function(a, b) return a.id < b.id end)


   for i, item in Shared.skpairs(itemArray) do
   for i, item in Shared.skpairs(itemArray) do
     result = result..'|-\r\n'
     table.insert(resultPart, '|-\r\n')
     result = result..'! '..Icons.Icon({item.name, type='item', notext='true'})..'\r\n! [['..item.name..']]\r\n'
     table.insert(resultPart, '! '..Icons.Icon({item.name, type='item', notext='true'})..'\r\n! [['..item.name..']]\r\n')
     result = result..'| '..item.description..'\r\n'
     table.insert(resultPart, '| '..item.description..'\r\n')
   end
   end
 
  result = result..'|}'


   return result
  table.insert(resultPart, '|}')
 
   return table.concat(resultPart)
end
end


return p
return p