Anonymous

Module:Items/SourceTables: Difference between revisions

From Melvor Idle
Moved getItemShopTable to Module:Shop and tinkered with things to reflect that.
(Slightly tweaked formatting of p.getCombatPassiveSlotItems (also created getBonesTable but ended up putting that in Module:Prayer))
(Moved getItemShopTable to Module:Shop and tinkered with things to reflect that.)
Line 11: Line 11:
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Items = require('Module:Items')
local Items = require('Module:Items')
local Shop = require('Module:Shop')




Line 499: Line 500:


   --Shop items (including special items like gloves that aren't otherwise listed)
   --Shop items (including special items like gloves that aren't otherwise listed)
   if Shared.contains(Constants.Shop.SlayerItems, item.id) or item.buysFor ~= nil or Shared.contains(Items.OtherShopItems, item.name) then
   local shopSources = Shop.getItemSourceArray(item.id)
  if Shared.tableCount(shopSources) > 0 then
     table.insert(lineArray, '[[Shop]]')
     table.insert(lineArray, '[[Shop]]')
   end
   end
Line 692: Line 694:


   return p._getItemLootSourceTable(item)
   return p._getItemLootSourceTable(item)
end
function p._getItemShopTable(item)
  local result = '{| class="wikitable"\r\n|-\r\n!colspan="2"|[[Shop]] Purchase'
  result = result..'\r\n|-\r\n!style="text-align:right;"|Cost\r\n|'
  local cost = {}
  local qty = '1'
  if item.buysFor ~= nil then
    if item.buysFor > 0 then table.insert(cost, Icons.GP(item.buysFor)) end
  elseif Shared.contains(Constants.Shop.SlayerItems, item.id) then
    table.insert(cost, Icons.SC(item.slayerCost))
  elseif Items.GloveTable[item.name] ~= nil then
    table.insert(cost, Icons.GP(Items.GloveTable[item.name].cost))
    qty = ' +'..Shared.formatnum(Items.GloveTable[item.name].charges)..' Charges'
  end
  if item.buysForLeather ~= nil then
    table.insert(cost, Icons.Icon({'Leather', type='item', qty=item.buysForLeather}))
  end
  if item.buysForItems ~= nil then
    for i, row in pairs(item.buysForItems) do
      local mat = Items.getItemByID(row[1])
      table.insert(cost, Icons.Icon({mat.name, type='item', qty=row[2]}))
    end
  end
  if Shared.tableCount(cost) == 0 then
    --If no cost is set, return an empty string
    return ''
  else
    result = result..table.concat(cost, '<br/>')
  end
  --For right now, only have requirements on Skillcapes
  result = result..'\r\n|-\r\n!style="text-align:right;"|Requirements\r\n|'
  if item.name == 'Cape of Completion' then
    result = result..'100% Completion Log'
  elseif item.name == 'Max Skillcape' then
    result = result..'Level 99 in all [[Skills]]'
  elseif Shared.contains(item.name, 'Skillcape') then
    local skillName = Shared.splitString(item.name)[1]
    result = result..Icons._SkillReq(skillName, 99)
  else
    result = result..'None'
  end
  result = result..'\r\n|-\r\n!style="text-align:right;"|Quantity\r\n|'..qty
  result = result..'\r\n|}'
  return result
end
function p.getItemShopTable(frame)
  local itemName = frame.args ~= nil and frame.args[1] or frame
  local item = Items.getItem(itemName)
  if item == nil then
    return "ERROR: No item named "..itemName.." exists in the data module"
  end
  return p._getItemShopTable(item)
end
end


Line 848: Line 793:
function p._getItemSourceTables(item)
function p._getItemSourceTables(item)
   local result = ''
   local result = ''
   local shopTable = p._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
     result = result..'===Shop===\r\n'..shopTable