Module:Items/UseTables: Difference between revisions

Added Agility Obstacles to the list of things Item Uses considers
(Fixed formatting when calling not as a list)
(Added Agility Obstacles to the list of things Item Uses considers)
Line 4: Line 4:
local ItemData = mw.loadData('Module:Items/data')
local ItemData = mw.loadData('Module:Items/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')
Line 11: Line 11:
local Items = require('Module:Items')
local Items = require('Module:Items')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Agility = require('Module:Skills/Agility')




Line 93: Line 94:
   local canRunecraft = false
   local canRunecraft = false
   local canHerblore = false
   local canHerblore = false
  local canAgile = false
   if item.trimmedItemID ~= nil then
   if item.trimmedItemID ~= nil then
     canUpgrade = true
     canUpgrade = true
Line 143: Line 145:
     end
     end
   end
   end
  --Check if Agility applies here
  canAgile = Shared.tableCount(Agility.getObstaclesForItem(item.id)) > 0
   if canUpgrade then
   if canUpgrade then
     if item.canUpgrade or (item.type == 'Armour' and item.canUpgrade == nil) then
     if item.canUpgrade or (item.type == 'Armour' and item.canUpgrade == nil) then
Line 151: Line 156:
    
    
   --Agility
   --Agility
   if Shared.contains(itemUseArray.Agility, item.name) then
   if canAgile or Shared.contains(itemUseArray.Agility, item.name) then
     table.insert(useArray, chr..Icons.Icon({'Agility', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Agility', type='skill'}))
   end
   end
Line 454: Line 459:
     end
     end
     if row.gp ~= nil then result = result..'<br/>'..Icons.GP(row.gp) end
     if row.gp ~= nil then result = result..'<br/>'..Icons.GP(row.gp) end
  end
  --Agility obstacles are weird and get their own section
  local obstacles = Agility.getObstaclesForItem(item.id)
  for i, obst in Shared.skpairs(obstacles) do
    result = result..'\r\n|-\r\n|'
    result = result..Icons.Icon({"Agility", type="skill", size="50", notext=true})
    result = result..'||[[Agility#Obstacles|'..obst.name..']]'
    result = result..'||'..Icons.Icon({"Agility", type="skill"})
    --Adding the requirements for the Agility Obstacle
    local reqArray = {}
    if obst.category == nil then --nil category means this is a passive pillar
      table.insert(reqArray, Icons._SkillReq('Agility', 99))
    elseif obst.category > 0 then --Otherwise it's category * 10
      table.insert(reqArray, Icons._SkillReq('Agility', obst.category * 10))
    end
    --Then the other skill levels if any are added
    if obst.requirements ~= nil and obst.requirements.skillLevel ~= nil then
      for j, req in Shared.skpairs(obst.requirements.skillLevel) do
        table.insert(reqArray, Icons._SkillReq(Constants.getSkillName(req[1]), req[2]))
      end
    end
    result = result..'||'..table.concat(reqArray, '<br/>')
    --Finally the cost
    local cost = obst.cost
    local costArray = {}
    if cost.gp ~= nil and cost.gp > 0 then
      table.insert(costArray, Icons.GP(cost.gp))
    end
    if cost.slayerCoins ~= nil and cost.slayerCoins > 0 then
      table.insert(costArray, Icons.SC(cost.slayerCoins))
    end
    for j, mat in Shared.skpairs(cost.items) do
      local item = Items.getItemByID(mat[1])
      table.insert(costArray, Icons.Icon({item.name, type="item", qty=mat[2]}))
    end
   
    result = result..'||'..table.concat(costArray, '<br/>')
   end
   end