Anonymous

Module:Items/ComparisonTables: Difference between revisions

From Melvor Idle
_getCategoryTable: Fix skill cape classification for Superior Cape of Completion
(Added ability to sort category tables by name and also added ability to get skillcape and non-skillcape tables)
(_getCategoryTable: Fix skill cape classification for Superior Cape of Completion)
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local p = {}
local p = {}
local ItemData = mw.loadData('Module:Items/data')


local Constants = require('Module:Constants')
local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local GameData = require('Module:GameData')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Items = require('Module:Items')
local Items = require('Module:Items')
Line 11: Line 10:


local styleOverrides = {
local styleOverrides = {
Melee = {'Slayer Helmet (Basic)', 'Slayer Platebody (Basic)', 'Paladin Gloves', 'Desert Wrappings', 'Almighty Lute', 'Candy Cane', 'Bob's Rake'},
Melee = {'Slayer Helmet (Basic)', 'Slayer Platebody (Basic)', 'Paladin Gloves', 'Desert Wrappings', 'Almighty Lute', 'Candy Cane', 'Bob's Rake', "Knight's Defender", "Ward of Flame Platebody"},
Ranged = {'Slayer Cowl (Basic)', 'Slayer Leather Body (Basic)', 'Ice Arrows'},
Ranged = {'Slayer Cowl (Basic)', 'Slayer Leather Body (Basic)', 'Ice Arrows'},
Magic = {'Slayer Wizard Hat (Basic)', 'Slayer Wizard Robes (Basic)', 'Enchanted Shield', 'Elementalist Gloves'},
Magic = {'Slayer Wizard Hat (Basic)', 'Slayer Wizard Robes (Basic)', 'Enchanted Shield', 'Elementalist Gloves', 'Frostspark Boots', 'Freezing Touch Body', 'Lightning Boots'},
None = {},
None = {},
NotMelee = {'Frostspark Boots', 'Freezing Touch Body', 'Lightning Boots'},
NotRanged = {},
NotMagic = {'Torrential Blast Crossbow', 'Spectral Ice Sword', 'Lightning Strike 1H Sword', 'FrostSpark 1H Sword'}
}
}


Line 25: Line 27:
local statColumns = {'stabAttackBonus', 'slashAttackBonus','blockAttackBonus','rangedAttackBonus', 'magicAttackBonus', 'meleeStrengthBonus', 'rangedStrengthBonus', 'magicDamageBonus', 'meleeDefenceBonus', 'rangedDefenceBonus', 'magicDefenceBonus', 'damageReduction', 'attackLevelRequired', 'defenceLevelRequired', 'rangedLevelRequired', 'magicLevelRequired'}
local statColumns = {'stabAttackBonus', 'slashAttackBonus','blockAttackBonus','rangedAttackBonus', 'magicAttackBonus', 'meleeStrengthBonus', 'rangedStrengthBonus', 'magicDamageBonus', 'meleeDefenceBonus', 'rangedDefenceBonus', 'magicDefenceBonus', 'damageReduction', 'attackLevelRequired', 'defenceLevelRequired', 'rangedLevelRequired', 'magicLevelRequired'}


if(Shared.tableCount(itemList) == 0) then
if Shared.tableIsEmpty(itemList) then
return 'ERROR: you must select at least one item to get stats for[[Category:Pages with script errors]]'
return 'ERROR: you must select at least one item to get stats for[[Category:Pages with script errors]]'
end
end
Line 74: Line 76:
end
end
if attBonusCols > 0 then
if attBonusCols > 0 then
table.insert(resultPart, '\r\n!colspan="'..attBonusCols..'"style="padding:0 0.5em 0 0.5em;"|Attack Bonus')
table.insert(resultPart, '\r\n!colspan="'..attBonusCols..'"|Attack Bonus')
end
end
if strBonusCols > 0 then
if strBonusCols > 0 then
table.insert(resultPart, '\r\n!colspan="'..strBonusCols..'"style="padding:0 0.5em 0 0.5em;"|Str. Bonus')
table.insert(resultPart, '\r\n!colspan="'..strBonusCols..'"|Str. Bonus')
end
end
if Shared.contains(statColumns, 'magicDamageBonus') then
if Shared.contains(statColumns, 'magicDamageBonus') then
table.insert(resultPart, '\r\n!colspan="1"style="padding:0 0.5em 0 0.5em;"|% Dmg Bonus')
table.insert(resultPart, '\r\n!colspan="1"|% Dmg Bonus')
end
end
if defBonusCols > 0 then
if defBonusCols > 0 then
table.insert(resultPart, '\r\n!colspan="'..defBonusCols..'"style="padding:0 0.5em 0 0.5em;"|Defence Bonus')
table.insert(resultPart, '\r\n!colspan="'..defBonusCols..'"|Defence Bonus')
end
end
if Shared.contains(statColumns, 'damageReduction') then
if Shared.contains(statColumns, 'damageReduction') then
table.insert(resultPart, '\r\n!colspan="1"style="padding:0 0.5em 0 0.5em;"|DR')
table.insert(resultPart, '\r\n!colspan="1"|DR')
end
end
if lvlReqCols > 0 then
if lvlReqCols > 0 then
table.insert(resultPart, '\r\n!colspan="'..lvlReqCols..'"style="padding:0 0.5em 0 0.5em;"|Lvl Req')
table.insert(resultPart, '\r\n!colspan="'..lvlReqCols..'"|Lvl Req')
end
end
if includeModifiers and includeDescription then
if includeModifiers and includeDescription then
Line 98: Line 100:
--One header row down, one to go
--One header row down, one to go
table.insert(resultPart, '\r\n|-class="headerRow-1"')
table.insert(resultPart, '\r\n|-class="headerRow-1"')
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Item')
table.insert(resultPart, '\r\n!Item')
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Name')
table.insert(resultPart, '\r\n!Name')
--Weapons have Attack Speed here
--Weapons have Attack Speed here
if isWeaponType then
if isWeaponType then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Attack Speed')
table.insert(resultPart, '\r\n!Attack Speed')
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Two Handed?')
table.insert(resultPart, '\r\n!Two Handed?')
end
end
--Attack bonuses
--Attack bonuses
if Shared.contains(statColumns, 'slashAttackBonus') then
if Shared.contains(statColumns, 'slashAttackBonus') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Attack', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Attack', type='skill', notext='true'}))
end
end
if Shared.contains(statColumns, 'stabAttackBonus') then
if Shared.contains(statColumns, 'stabAttackBonus') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Strength', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Strength', type='skill', notext='true'}))
end
end
if Shared.contains(statColumns, 'blockAttackBonus') then
if Shared.contains(statColumns, 'blockAttackBonus') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Defence', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Defence', type='skill', notext='true'}))
end
end
if Shared.contains(statColumns, 'rangedAttackBonus') then
if Shared.contains(statColumns, 'rangedAttackBonus') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Ranged', type='skill', notext='true'}))
end
end
if Shared.contains(statColumns, 'magicAttackBonus') then
if Shared.contains(statColumns, 'magicAttackBonus') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Magic', type='skill', notext='true'}))
end
end
--Strength bonuses
--Strength bonuses
if Shared.contains(statColumns, 'meleeStrengthBonus') then
if Shared.contains(statColumns, 'meleeStrengthBonus') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Strength', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Strength', type='skill', notext='true'}))
end
end
if Shared.contains(statColumns, 'rangedStrengthBonus') then
if Shared.contains(statColumns, 'rangedStrengthBonus') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Ranged', type='skill', notext='true'}))
end
end
if Shared.contains(statColumns, 'magicDamageBonus') then
if Shared.contains(statColumns, 'magicDamageBonus') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Magic', type='skill', notext='true'}))
end
end
--Defence bonuses
--Defence bonuses
if Shared.contains(statColumns, 'meleeDefenceBonus') then
if Shared.contains(statColumns, 'meleeDefenceBonus') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Defence', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Defence', type='skill', notext='true'}))
end
end
if Shared.contains(statColumns, 'rangedDefenceBonus') then
if Shared.contains(statColumns, 'rangedDefenceBonus') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Ranged', type='skill', notext='true'}))
end
end
if Shared.contains(statColumns, 'magicDefenceBonus') then
if Shared.contains(statColumns, 'magicDefenceBonus') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Magic', type='skill', notext='true'}))
end
end
if Shared.contains(statColumns, 'damageReduction') then
if Shared.contains(statColumns, 'damageReduction') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Defence', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Defence', type='skill', notext='true'}))
end
end
--Level requirements
--Level requirements
if Shared.contains(statColumns, 'attackLevelRequired') then
if Shared.contains(statColumns, 'attackLevelRequired') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Attack', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Attack', type='skill', notext='true'}))
end
end
if Shared.contains(statColumns, 'defenceLevelRequired') then
if Shared.contains(statColumns, 'defenceLevelRequired') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Defence', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Defence', type='skill', notext='true'}))
end
end
if Shared.contains(statColumns, 'rangedLevelRequired') then
if Shared.contains(statColumns, 'rangedLevelRequired') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Ranged', type='skill', notext='true'}))
end
end
if Shared.contains(statColumns, 'magicLevelRequired') then
if Shared.contains(statColumns, 'magicLevelRequired') then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'}))
table.insert(resultPart, '\r\n!'..Icons.Icon({'Magic', type='skill', notext='true'}))
end
end
--If includeModifiers is set to 'true', add the Modifiers column
--If includeModifiers is set to 'true', add the Modifiers column
if includeModifiers then
if includeModifiers then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Modifiers')
table.insert(resultPart, '\r\n!Modifiers')
end
end
--If includeDescription is set to 'true', add the Description column
--If includeDescription is set to 'true', add the Description column
if includeDescription then
if includeDescription then
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Description')
table.insert(resultPart, '\r\n!Description')
end
end


if sortByName then
if sortByName then
table.sort(itemList, function(a, b) return a.name < b.name end)
table.sort(itemList, function(a, b) return a.name < b.name end)
else
table.sort(itemList, function(a, b) return a.id < b.id end)
end
end
for i, item in pairs(itemList) do
for i, item in ipairs(itemList) do
if isWeaponType then
if isWeaponType then
--Building rows for weapons
--Building rows for weapons
local atkSpeed = Items._getItemStat(item, 'attackSpeed', true)
local atkSpeed = Items._getItemStat(item, 'attackSpeed', true)
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: centre;"|'..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;"|'..Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '\r\n|' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '\r\n| data-sort-value="' .. atkSpeed .. '" style ="text-align: right;padding: 0 0.5em 0 0;" |'..Shared.round(atkSpeed / 1000, 3, 1) .. 's')
table.insert(resultPart, '\r\n| data-sort-value="' .. atkSpeed .. '" style="text-align:right;" |'..Shared.round(atkSpeed / 1000, 3, 1) .. 's')
--That's the first list out of the way, now for 2-Handed
--That's the first list out of the way, now for 2-Handed
table.insert(resultPart, '\r\n| style ="text-align: right;"|')
table.insert(resultPart, '\r\n| style="text-align: right;"|')
table.insert(resultPart, Items._getItemStat(item, 'isTwoHanded') and 'Yes' or 'No')
table.insert(resultPart, Items._getItemStat(item, 'isTwoHanded') and 'Yes' or 'No')
for j, statName in pairs(statColumns) do
for j, statName in pairs(statColumns) do
local statValue = Items._getItemStat(item, statName, true)
local statValue = Items._getItemStat(item, statName, true)
table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;')
table.insert(resultPart, '\r\n| style="text-align:right;" class="')
if string.find(statName, '^(.+)LevelRequired$') == nil then
if string.find(statName, '^(.+)LevelRequired$') == nil then
if statValue > 0 then
if statValue > 0 then
table.insert(resultPart, 'background-color:lightgreen;')
table.insert(resultPart, 'table-positive')
elseif statValue < 0 then
elseif statValue < 0 then
table.insert(resultPart, 'background-color:lightpink;')
table.insert(resultPart, 'table-negative')
end
end
end
end
Line 197: Line 197:
--If requested, add the item Modifiers
--If requested, add the item Modifiers
if includeModifiers then
if includeModifiers then
table.insert(resultPart, '\r\n|style="text-align:left;padding:0 0.5em 0 0.5em;"|')
table.insert(resultPart, '\r\n|')
table.insert(resultPart, Constants.getModifiersText(item.modifiers, true))
local txtLines = {}
local modTxt = Constants.getModifiersText(item.modifiers, true)
if modTxt ~= '' then
table.insert(txtLines, modTxt)
end
--For items with a special attack, show the details
if item.specialAttacks ~= nil and not Shared.tableIsEmpty(item.specialAttacks) then
table.insert(txtLines, "'''Special Attack:'''")
for i, spAttID in ipairs(item.specialAttacks) do
local spAtt = GameData.getEntityByID('attacks', spAttID)
table.insert(txtLines, spAtt.defaultChance .. '% chance for ' .. spAtt.name .. ':')
table.insert(txtLines, spAtt.description)
end
end
table.insert(resultPart, table.concat(txtLines, '<br/>'))
end
end
--If requested, add description
--If requested, add description
if includeDescription then
if includeDescription then
table.insert(resultPart, '\r\n|style="text-align:left;padding:0 0.5em 0 0.5em;"|')
table.insert(resultPart, '\r\n| ')
table.insert(resultPart, item.description ~= nil and item.description or '')
table.insert(resultPart, Constants.getDescription(item.customDescription, item.modifiers) or '')
end
end
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|'..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;"|'..Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '\r\n|' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true}))
for j, statName in pairs(statColumns) do
for j, statName in pairs(statColumns) do
local statValue = Items._getItemStat(item, statName, true)
local statValue = Items._getItemStat(item, statName, true)
table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;')
table.insert(resultPart, '\r\n|style="text-align:right;" class="')
if statValue > 0 then
if statValue > 0 then
table.insert(resultPart, 'background-color:lightgreen;')
table.insert(resultPart, 'table-positive')
elseif statValue < 0 then
elseif statValue < 0 then
table.insert(resultPart, 'background-color:lightpink;')
table.insert(resultPart, 'table-negative')
end
end
table.insert(resultPart, '"|'..Shared.formatnum(statValue))
table.insert(resultPart, '"|'..Shared.formatnum(statValue))
Line 223: Line 237:
--If requested, add the item Modifiers
--If requested, add the item Modifiers
if includeModifiers then
if includeModifiers then
table.insert(resultPart, '\r\n|style="text-align:left;padding:0 0.5em 0 0.5em;"|')
table.insert(resultPart, '\r\n| ')
table.insert(resultPart, Constants.getModifiersText(item.modifiers, true))
local txtLines = {}
local modTxt = Constants.getModifiersText(item.modifiers, true)
if modTxt ~= '' then
table.insert(txtLines, modTxt)
end
--For items with a special attack, show the details
if item.specialAttacks ~= nil and not Shared.tableIsEmpty(item.specialAttacks) then
table.insert(txtLines, "'''Special Attack:'''")
for i, spAttID in ipairs(item.specialAttacks) do
local spAtt = GameData.getEntityByID('attacks', spAttID)
table.insert(txtLines, spAtt.defaultChance .. '% chance for ' .. spAtt.name .. ':')
table.insert(txtLines, spAtt.description)
end
end
table.insert(resultPart, table.concat(txtLines, '<br/>'))
end
end
--If requested, add description
--If requested, add description
if includeDescription then
if includeDescription then
table.insert(resultPart, '\r\n|style="text-align:left;padding:0 0.5em 0 0.5em;"|')
table.insert(resultPart, '\r\n| ')
table.insert(resultPart, item.description ~= nil and item.description or '')
table.insert(resultPart, Constants.getDescription(item.customDescription, item.modifiers) or '')
end
end
end
end
Line 237: Line 265:


return table.concat(resultPart)
return table.concat(resultPart)
end
function p.getEquipmentTable(frame)
local args = frame.args ~= nil and frame.args or frame
local type = args.type
local tier = args.tier
local slot = args.slot
local ammoTypeStr = args.ammoType
local category = args.category ~= nil and args.category or 'Combat'
--Find out what Ammo Type we're working with
local ammoType = nil
if ammoTypeStr ~= nil then
if ammoTypeStr == "Arrows" then
ammoType = 0
elseif ammoTypeStr == 'Bolts' then
ammoType = 1
elseif ammoTypeStr == 'Javelins' then
ammoType = 2
elseif ammoTypeStr == 'Throwing Knives' then
ammoType = 3
end
end
local isWeaponType = Shared.contains(weaponTypes, type)
--Now we need to figure out which items are in this list
local itemList = {}
for i, itemBase in pairs(ItemData.Items) do
local item = Shared.clone(itemBase)
item.id = i - 1
local listItem = false
if isWeaponType then
listItem = item.type == type and item.category == category
if ammoType ~= nil then listItem = listItem and item.ammoTypeRequired == ammoType end
else
--Now for handling armour
if type == "Armour" or type == "Melee" then
listItem = Items._getItemStat(item, 'defenceLevelRequired') ~= nil or (item.category == 'Combat' and item.type == 'Armour')
elseif type == "Ranged Armour" or type == "Ranged" then
listItem = Items._getItemStat(item, 'rangedLevelRequired') ~= nil or (item.category == 'Combat' and item.type == 'Ranged Armour')
elseif type == "Magic Armour" or type == "Magic" then
listItem = Items._getItemStat(item, 'magicLevelRequired') or (item.category == 'Combat' and item.type == 'Magic Armour')
else
listItem = item.type == type and item.category ~= 'Combat'
end
if ammoType ~= nil then listItem = listItem and item.ammoType == ammoType end
if slot ~= nil then listItem = listItem and Shared.contains(item.validSlots, slot) end
end
if listItem then
table.insert(itemList, item)
end
end
local result = p._getEquipmentTable(itemList).."[[Category:getEquipmentTable]]"
return result
end
end


Line 302: Line 273:


local itemList = Items.getItems(function(item)
local itemList = Items.getItems(function(item)
-- Exclude Golbin raid exclusives for now, such that they don't
-- pollute various equipment tables
if item.golbinRaidExclusive ~= nil and item.golbinRaidExclusive then
return false
end
local isMatch = true
local isMatch = true
if style == 'Melee' then
if style == 'Melee' then
if (Items._getItemStat(item, 'defenceLevelRequired') == nil and Items._getItemStat(item, 'attackLevelRequired') == nil) and not Shared.contains(styleOverrides.Melee, item.name) then isMatch = false end
if ((Items._getItemStat(item, 'defenceLevelRequired') == nil and Items._getItemStat(item, 'attackLevelRequired') == nil) and not Shared.contains(styleOverrides.Melee, item.name)) or Shared.contains(styleOverrides.NotMelee, item.name) then isMatch = false end
elseif style == 'Ranged' then
elseif style == 'Ranged' then
if Items._getItemStat(item, 'rangedLevelRequired') == nil and not Shared.contains(styleOverrides.Ranged, item.name) then isMatch = false end
if (Items._getItemStat(item, 'rangedLevelRequired') == nil and not Shared.contains(styleOverrides.Ranged, item.name)) or Shared.contains(styleOverrides.NotRanged, item.name)  then isMatch = false end
elseif style == 'Magic' then
elseif style == 'Magic' then
if Items._getItemStat(item, 'magicLevelRequired') == nil and not Shared.contains(styleOverrides.Magic, item.name) then isMatch = false end
if (Items._getItemStat(item, 'magicLevelRequired') == nil and not Shared.contains(styleOverrides.Magic, item.name)) or Shared.contains(styleOverrides.NotMagic, item.name) then isMatch = false end
elseif style == 'None' then
elseif style == 'None' then
if (Items._getItemStat(item, 'defenceLevelRequired') ~= nil or Items._getItemStat(item, 'rangedLevelRequired') ~= nil or Items._getItemStat(item, 'magicLevelRequired') ~= nil or
if (Items._getItemStat(item, 'defenceLevelRequired') ~= nil or Items._getItemStat(item, 'rangedLevelRequired') ~= nil or Items._getItemStat(item, 'magicLevelRequired') ~= nil or
Shared.contains(styleOverrides.Melee, item.name) or Shared.contains(styleOverrides.Ranged, item.name) or Shared.contains(styleOverrides.Magic, item.name)) and
Shared.contains(styleOverrides.Melee, item.name) or Shared.contains(styleOverrides.Ranged, item.name) or Shared.contains(styleOverrides.Magic, item.name)) and
not Shared.contains(styleOverrides.None, item.name) then
not Shared.contains(styleOverrides.None, item.name) then
isMatch = false
isMatch = false
end
end
Line 320: Line 296:
if isMatch and other ~= nil then
if isMatch and other ~= nil then
if slot == 'Cape' then
if slot == 'Cape' then
if other == 'Skillcape' then
-- TODO Would be more reliable if based on items appearing within the relevant shop categories instead
if not Shared.contains(item.name, 'Skillcape') then
local isSkillcape = Shared.contains(item.name, 'Skillcape') or Shared.contains(item.name, 'Cape of Completion')
isMatch = false
if other == 'Skillcapes' then
end
isMatch = isSkillcape
elseif other == 'No Skillcapes' then
elseif other == 'No Skillcapes' then
if Shared.contains(item.name, 'Skillcape') then
isMatch = not isSkillcape
isMatch = false
end
end
end
end
end
if slot == 'Weapon' then --For quiver slot or weapon slot, 'other' is the ammo type
if slot == 'Weapon' then --For quiver slot or weapon slot, 'other' is the ammo type
if other == 'Arrows' then
isMatch = other == item.ammoTypeRequired
if item.ammoTypeRequired ~= 0 then isMatch = false end
elseif other == 'Bolts' then
if item.ammoTypeRequired ~= 1 then isMatch = false end
end
elseif slot == 'Quiver' then
elseif slot == 'Quiver' then
if other == 'Arrows' then
if other == 'Thrown' and Shared.contains({'Javelins', 'ThrowingKnives'}, item.ammoType) then
if item.ammoType ~= 0 then isMatch = false end
isMatch = true
elseif other == 'Bolts' then
else
if item.ammoType ~= 1 then isMatch = false end
isMatch = other == item.ammoType
elseif other == 'Javelins' then
if item.ammoType ~= 2 then isMatch = false end
elseif other == 'Throwing Knives' then
if item.ammoType ~= 3 then isMatch = false end
elseif other == 'Thrown' then
if item.ammoType ~= 2 and item.ammoType ~= 3 then isMatch = false end
end
end
end
end
Line 422: Line 386:
end
end
end)
end)
table.sort(itemList, function(a, b) return a.id < b.id end)


local resultPart = {}
local resultPart = {}
Line 434: Line 397:
table.insert(resultPart, '\r\n|-')
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, '\r\n|data-sort-value="'..item.name..'"|'..Icons.Icon({item.name, type='item', size=50, notext=true}))
table.insert(resultPart, '||'..Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '||' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..lootValue..'"|'..lootValue..'%')
table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..lootValue..'"|'..lootValue..'%')
table.insert(resultPart, '||'..item.description)
table.insert(resultPart, '||'..(Constants.getDescription(item.customDescription, item.modifiers) or ''))
end
end


Line 489: Line 452:
function p.getItemUpgradeTable(frame)
function p.getItemUpgradeTable(frame)
local category = frame.args ~= nil and frame.args[1] or frame
local category = frame.args ~= nil and frame.args[1] or frame
local itemArray = {}
local upgradeArray = {}
local isEquipment = false
local isEquipment = false


if string.upper(category) == 'POTION' then
if string.upper(category) == 'POTION' then
itemArray = Items.getItems(function(item) return Shared.contains(item.name, 'Potion') and item.itemsRequired ~= nil end)
upgradeArray = GameData.getEntities('itemUpgrades',
function(upgrade) return Shared.contains(upgrade.upgradedItemID, 'Potion') end
)
elseif string.upper(category) == 'OTHER' then
elseif string.upper(category) == 'OTHER' then
itemArray = Items.getItems(function(item)
upgradeArray = GameData.getEntities('itemUpgrades',
return not Shared.contains(item.name, 'Potion') and item.itemsRequired ~= nil and item.validSlots == nil
function(upgrade)
end)
if not Shared.contains(upgrade.upgradedItemID, 'Potion') then
local item = Items.getItemByID(upgrade.upgradedItemID)
if item ~= nil then
return item.validSlots == nil or Shared.tableIsEmpty(item.validSlots)
end
end
return false
end
)
else
else
if Constants.getEquipmentSlotID(category) == nil then
if Constants.getEquipmentSlotID(category) == nil then
Line 503: Line 476:
end
end
isEquipment = true
isEquipment = true
itemArray = Items.getItems(function(item)
upgradeArray = GameData.getEntities('itemUpgrades',
return item.itemsRequired ~= nil and Shared.contains(item.validSlots, category)
function(upgrade)
end)
local item = Items.getItemByID(upgrade.upgradedItemID)
if item ~= nil then
return item.validSlots ~= nil and Shared.contains(item.validSlots, category)
end
return false
end
)
end
end
table.sort(itemArray, function(a, b) return a.id < b.id end)


local resultPart = {}
local resultPart = {}
Line 515: Line 493:
if isEquipment then table.insert(resultPart, '!!Stat Change') end
if isEquipment then table.insert(resultPart, '!!Stat Change') end


for i, item in Shared.skpairs(itemArray) do
for i, upgrade in ipairs(upgradeArray) do
local item = Items.getItemByID(upgrade.upgradedItemID)
table.insert(resultPart, '\r\n|-')
table.insert(resultPart, '\r\n|-')
table.insert(resultPart, '\r\n|'..Icons.Icon({item.name, type='item', size='50', notext=true}))
table.insert(resultPart, '\r\n|'..Icons.Icon({item.name, type='item', size='50', notext=true}))
table.insert(resultPart, '||'..Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '||' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true}))


local matArray = {}
local matArray = {}
local statChangeString = ''
local statChangeString = ''
for i, row in Shared.skpairs(item.itemsRequired) do
for i, itemCost in ipairs(upgrade.itemCosts) do
local mat = Items.getItemByID(row[1])
local mat = Items.getItemByID(itemCost.id)
table.insert(matArray, Icons.Icon({mat.name, type='item', qty=row[2]}))
if mat ~= nil then
 
table.insert(matArray, Icons.Icon({mat.name, type='item', qty=itemCost.quantity}))
if item.validSlots ~= nil and mat.validSlots ~= nil and statChangeString == '' then
if isEquipment and item.validSlots ~= nil and mat.validSlots ~= nil and statChangeString == '' then
statChangeString = p.getStatChangeString(item, mat)
statChangeString = p.getStatChangeString(item, mat)
end
end
end
end
end
if item.trimmedGPCost ~= nil and item.trimmedGPCost > 0 then
if upgrade.gpCost ~= nil and upgrade.gpCost > 0 then
table.insert(matArray, Icons.GP(item.trimmedGPCost))
table.insert(matArray, Icons.GP(upgrade.gpCost))
end
if upgrade.scCost ~= nil and upgrade.scCost > 0 then
table.insert(matArray, Icons.SC(upgrade.scCost))
end
end
table.insert(resultPart, '||'..table.concat(matArray, '<br/>'))
table.insert(resultPart, '||'..table.concat(matArray, '<br/>'))