4,951
edits
Falterfire (talk | contribs) (Fixed formatting when calling not as a list) |
Falterfire (talk | contribs) ((Hopefully) fixed issue with items not including Agility Obstacles as a use if no other uses existed) |
||
(3 intermediate revisions by the same user not shown) | |||
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 = 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') | |||
local Shop = require('Module:Shop') | |||
Line 93: | Line 95: | ||
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 146: | ||
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 157: | ||
--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 167: | Line 173: | ||
end | end | ||
--Firemaking | --Firemaking | ||
if item. | if SkillData.Firemaking[item.id + 1] ~= nil or Shared.contains(itemUseArray.Firemaking, item.name) then | ||
table.insert(useArray, chr..Icons.Icon({'Firemaking', type='skill'})) | table.insert(useArray, chr..Icons.Icon({'Firemaking', type='skill'})) | ||
end | end | ||
Line 213: | Line 219: | ||
--Other odds and ends: | --Other odds and ends: | ||
--Mastery Tokens are tied to 'Mastery' | --Mastery Tokens are tied to 'Mastery' | ||
if item.type == 'Token' then | if item.type == 'Token' then | ||
Line 238: | Line 245: | ||
if item.name == 'Charge Stone of Rhaelyx' then | if item.name == 'Charge Stone of Rhaelyx' then | ||
table.insert(useArray, chr..'Powering '..Icons.Icon({'Crown of Rhaelyx', type='item'})) | table.insert(useArray, chr..'Powering '..Icons.Icon({'Crown of Rhaelyx', type='item'})) | ||
end | |||
--Some items are needed to make shop purchases | |||
local shopArray = Shop.getItemCostArray(item.id) | |||
if Shared.tableCount(shopArray) > 0 then | |||
table.insert(useArray, chr..Icons.Icon({'Shop'})) | |||
end | end | ||
Line 278: | Line 291: | ||
end | end | ||
table.insert(useArray, {item = item2, qty = 1, mats = mat, skill = 'Upgrade', req = rowReq, xp = xp, gp = item2.trimmedGPCost}) | table.insert(useArray, {item = item2, qty = 1, mats = mat, skill = 'Upgrade', req = rowReq, xp = xp, gp = item2.trimmedGPCost}) | ||
break | break | ||
end | end | ||
Line 393: | Line 390: | ||
local qty = 1 | local qty = 1 | ||
table.insert(useArray, {item = item2, qty = qty, mats = mat, skill = 'Cooking', req = rowReq, xp = xp}) | table.insert(useArray, {item = item2, qty = qty, mats = mat, skill = 'Cooking', req = rowReq, xp = xp}) | ||
end | |||
--Handle shop purchases using Module:Shop | |||
local shopUses = Shop.getItemCostArray(item.id) | |||
for i, purchase in Shared.skpairs(shopUses) do | |||
local rowReq = Shop.getRequirementString(purchase.unlockRequirements) | |||
local iconType = (purchase.contains.items ~= nil and Shared.tableCount(purchase.contains.items) > 0) and 'item' or 'upgrade' | |||
table.insert(useArray, {item = {name = purchase.name}, qty = 1, mats = purchase.cost.items, skill = 'Shop', req = rowReq, xp = 'N/A', gp = purchase.cost.gp, type = iconType}) | |||
end | end | ||
Line 408: | Line 413: | ||
return a.item.name < b.item.name | return a.item.name < b.item.name | ||
end end) | end end) | ||
local obstacles = Agility.getObstaclesForItem(item.id) | |||
local spellUseTable = p._getSpellUseTable(item) | local spellUseTable = p._getSpellUseTable(item) | ||
local result = '' | local result = '' | ||
if Shared.tableCount(useArray) == 0 then | if Shared.tableCount(useArray) == 0 and Shared.tableCount(obstacles) == 0 then | ||
if string.len(spellUseTable) > 0 then | if string.len(spellUseTable) > 0 then | ||
return '==Uses==\r\n==='..Icons.Icon({'Magic', type='skill', size='30'})..'===\r\n'..spellUseTable | return '==Uses==\r\n==='..Icons.Icon({'Magic', type='skill', size='30'})..'===\r\n'..spellUseTable | ||
Line 422: | Line 429: | ||
for i, row in pairs(useArray) do | for i, row in pairs(useArray) do | ||
local qty = row.qty ~= nil and row.qty or 1 | local qty = row.qty ~= nil and row.qty or 1 | ||
local iconType = row.type ~= nil and row.type or 'item' | |||
result = result..'\r\n|-\r\n|data-sort-value="'..row.item.name..'"|' | result = result..'\r\n|-\r\n|data-sort-value="'..row.item.name..'"|' | ||
result = result..Icons.Icon({row.item.name, type= | result = result..Icons.Icon({row.item.name, type=iconType, notext=true, size=50})..'||' | ||
if qty > 1 then result = result.."'''"..qty.."x''' " end | if qty > 1 then result = result.."'''"..qty.."x''' " end | ||
result = result..'[['..row.item.name..']]' | result = result..'[['..row.item.name..']]' | ||
Line 429: | Line 437: | ||
result = result..'||data-sort-value="Upgrade"|[[Upgrading Items|Upgrade]]' | result = result..'||data-sort-value="Upgrade"|[[Upgrading Items|Upgrade]]' | ||
elseif row.skill == 'Shop' then | elseif row.skill == 'Shop' then | ||
result = result..'||data-sort-value="Shop"| | result = result..'||data-sort-value="Shop"|'..Icons.Icon({'Shop'}) | ||
else | else | ||
result = result..'||data-sort-value="'..row.skill..'"|'..Icons.Icon({row.skill, type='skill'}) | result = result..'||data-sort-value="'..row.skill..'"|'..Icons.Icon({row.skill, type='skill'}) | ||
Line 454: | Line 462: | ||
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 | |||
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/>') | |||
--Just including 'N/A' for XP since it doesn't really apply for Agility Obstacles | |||
result = result..'||N/A' | |||
--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 | ||