Module:Items/ComparisonTables/Sandbox: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 13: Line 13:


local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'}
local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'}
local function getItemDesc(item)
if item.customDescription ~= nil then
return item.customDescription
elseif item.modifiers ~= nil then
return Modifiers.getModifiersText(item.modifiers, false, false)
else
return ''
end
end


local function getAttackSpeed(item)
local function getAttackSpeed(item)
Line 92: Line 82:
end
end


local function addStatCell(row, item, stat)
--== Helper Functions for getCategoryTable ==--
local statVal = 0
local function createStatCell(row, statVal)
if item.equipmentStats ~= nil then
statVal = item.equipmentStats[stat] or 0
end
local cell = row:tag('td')
local cell = row:tag('td')
if statVal > 0 then
if statVal > 0 then
Line 104: Line 91:
end
end
cell:css('text-align', 'right')
cell:css('text-align', 'right')
cell:wikitext(statVal)
return cell
return cell
end
end
local function addStatCell(row, item, stat)
local statVal = 0
if item.equipmentStats ~= nil then
statVal = item.equipmentStats[stat] or 0
end
return createStatCell(row, statVal)
:wikitext(statVal)
end
local function addDRCell(row, item)
local dr = 0
local icon = nil
-- Grab damage reduction figure
if item.equipmentStats ~= nil then
if item.equipmentStats.damageReduction then
dr, icon = item.equipmentStats.damageReduction, 'Damage Reduction'
elseif item.equipmentStats.resistance then
dr, icon = item.equipmentStats.resistance, 'Abyssal Resistance'
end
end
local cell = createStatCell(row, dr)
-- Add DR icons, if there's any value
if dr ~= 0 then
cell:wikitext(Icons.Icon({icon, size=15, notext='true'}) .. ' ')
end
-- Add DR value
cell:wikitext(dr .. '%')
return cell
end
function p._getCategoryTable(slot)
function p._getCategoryTable(slot)
local iconSize = 20
local iconSize = 20
Line 137: Line 158:
-- TODO: if abyssal switch text
-- TODO: if abyssal switch text
header0:tag('th'):wikitext("DR")
header0:tag('th'):wikitext("DR/AR")
header0:tag('th') -- Empty row above "Equip Req"
header0:tag('th') -- Empty row above "Equip Req"
Line 166: Line 187:
-- Damage reduction
-- Damage reduction
-- TODO: Check if isabyssal
header1:tag('th'):wikitext(Icons.Icon({'Damage Reduction', size=iconSize, notext='true'}))
header1:tag('th'):wikitext(Icons.Icon({'Damage Reduction', size=iconSize, notext='true'}))
--header1:tag('th'):wikitext(Icons.Icon({'Abyssal Resistance', size=iconSize, notext='true'}))
--Level requirements
--Level requirements
header1:tag('th'):wikitext('Equip Req')
header1:tag('th'):wikitext('Equip Req')
Debug.log(itemList)
-- Fill the table with all items
-- Fill the table with all items
for _, item in ipairs(itemList) do
for _, item in ipairs(itemList) do
Line 208: Line 227:
addStatCell(row, item, 'magicDefenceBonus')
addStatCell(row, item, 'magicDefenceBonus')


-- TODO: Switch Abyss
-- Add Damage Reduction / Abyssal Resistance
addStatCell(row, item, 'damageReduction'):wikitext('%') -- resistance
addDRCell(row, item)
-- TODO: Format requirements
-- TODO: Format requirements
2,875

edits