4,951
edits
Falterfire (talk | contribs) (Improvements to the getItemSources code to account for more things. Probably not everything quite yet, but getting there) |
Falterfire (talk | contribs) (Tweaks to the getEquipmentTable code) |
||
Line 384: | Line 384: | ||
local ammoTypeStr = args.ammoType | local ammoTypeStr = args.ammoType | ||
local category = args.category ~= nil and args.category or 'Combat' | local category = args.category ~= nil and args.category or 'Combat' | ||
--Find out what Ammo Type we're working with | --Find out what Ammo Type we're working with | ||
Line 410: | Line 408: | ||
--Getting some lists set up here that will be used later | --Getting some lists set up here that will be used later | ||
--First, the list of columns used by both weapons & | --First, the list of columns used by both weapons & armour | ||
local statColumns = {'slashAttackBonus', 'stabAttackBonus','blockAttackBonus','rangedAttackBonus', 'magicAttackBonus', 'strengthBonus', 'rangedStrengthBonus', 'magicDamageBonus', 'defenceBonus', 'rangedDefenceBonus', 'magicDefenceBonus'} | local statColumns = {'slashAttackBonus', 'stabAttackBonus','blockAttackBonus','rangedAttackBonus', 'magicAttackBonus', 'strengthBonus', 'rangedStrengthBonus', 'magicDamageBonus', 'defenceBonus', 'rangedDefenceBonus', 'magicDefenceBonus'} | ||
--Then the lists for just weapons/just | --Then the lists for just weapons/just armour | ||
local weaponStatColumns = {'attackLevelRequired', 'rangedLevelRequired', 'magicLevelRequired'} | local weaponStatColumns = {'attackLevelRequired', 'rangedLevelRequired', 'magicLevelRequired'} | ||
local | local armourStatColumns = {'damageReduction', 'defenceLevelRequired', 'rangedLevelRequired', 'magicLevelRequired'} | ||
--Then the list of weapon types | --Then the list of weapon types | ||
local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'} | local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'} | ||
Line 436: | Line 434: | ||
result = result..'\r\n!colspan="1"|' | result = result..'\r\n!colspan="1"|' | ||
else | else | ||
--Only | --Only armour pieces have DR right now, so ignore that column for weapons | ||
result = result..'\r\n!colspan="1"style="padding:0 0.5em 0 0.5em;"|Damage Reduction' | result = result..'\r\n!colspan="1"style="padding:0 0.5em 0 0.5em;"|Damage Reduction' | ||
end | end | ||
Line 463: | Line 461: | ||
result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'}) | result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'}) | ||
result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'}) | result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'}) | ||
--Damage Reduction/Defence Req for | --Damage Reduction/Defence Req for armour, 2-handed/Attack Req for weapons | ||
if isWeaponType then | if isWeaponType then | ||
result = result..'\r\n!style="padding:0 1em 0 0.5em;"|Two Handed?' | result = result..'\r\n!style="padding:0 1em 0 0.5em;"|Two Handed?' | ||
Line 478: | Line 476: | ||
--And with all the header out of the way, finally time to actually build the table itself. | --And with all the header out of the way, finally time to actually build the table itself. | ||
local itemList = {} | |||
for i, itemBase in pairs(ItemData) do | for i, itemBase in pairs(ItemData) do | ||
local item = Shared.clone(itemBase) | local item = Shared.clone(itemBase) | ||
Line 483: | Line 482: | ||
local listItem = false | local listItem = false | ||
if isWeaponType then | if isWeaponType then | ||
listItem = item.type == type and item.category == category | |||
if ammoType ~= nil then listItem = listItem and item.ammoTypeRequired == ammoType end | if ammoType ~= nil then listItem = listItem and item.ammoTypeRequired == ammoType end | ||
if | else | ||
--Now for handling armour | |||
if type == "Armour" or type == "Melee" then | |||
listItem = item.defenceLevelRequired ~= nil or (item.category == 'Combat' and item.type == 'Armour') | |||
elseif type == "Ranged Armour" or type == "Ranged" then | |||
listItem = item.rangedLevelRequired ~= nil or (item.category == 'Combat' and item.type == 'Ranged Armour') | |||
elseif type == "Magic Armour" or type == "Magic" then | |||
listItem = item.magicLevelRequired ~= nil or (item.category == 'Combat' and item.type == 'Magic Armour') | |||
else | |||
listItem = item.type == type and item.category ~= 'Combat' | |||
end | end | ||
if ammoType ~= nil then listItem = listItem and item.ammoType == ammoType end | if ammoType ~= nil then listItem = listItem and item.ammoType == ammoType end | ||
if slot ~= nil then listItem = listItem and item.equipmentSlot == slot end | if slot ~= nil then listItem = listItem and item.equipmentSlot == slot end | ||
end | |||
if listItem then | |||
table.insert(itemList, item) | |||
end | |||
end | |||
if | table.sort(itemList, function(a, b) return a.id < b.id end) | ||
result = result..'\r\n|-' | for i, item in pairs(itemList) do | ||
result = result..'\r\n|style ="text-align: left;padding: 0 0 0 0;"|'..Icons.Icon({item.name, type='item', size=50, notext=true}) | if isWeaponType then | ||
--Building rows for weapons | |||
result = result..'\r\n|-' | |||
local statValue = p._getItemStat(item, statName, true) | result = result..'\r\n|style ="text-align: left;padding: 0 0 0 0;"|'..Icons.Icon({item.name, type='item', size=50, notext=true}) | ||
result = result..'\r\n|style ="text-align: left;padding: 0 0.5em 0 0.5em;"|[['..item.name..']]' | |||
result = result..'\r\n| style ="text-align: right;padding: 0 0.5em 0 0;" |'..Shared.formatnum(item.attackSpeed) | |||
for j, statName in pairs(statColumns) do | |||
local statValue = p._getItemStat(item, statName, true) | |||
result = result..'\r\n| style ="text-align: right;padding: 0 0.5em 0 0;' | |||
if statValue > 0 then | |||
result = result..'background-color:lightgreen;' | |||
elseif statValue < 0 then | |||
result = result..'background-color:lightpink;' | |||
end | |||
result = result..'"|'..Shared.formatnum(statValue) | |||
if statName == 'magicDamageBonus' or statName == 'damageReduction' then result = result..'%' end | |||
end | |||
--That's the first list out of the way, now for 2-Handed | |||
result = result..'\r\n| style ="text-align: right;"|' | |||
if item.isTwoHanded then result = result..'Yes' else result = result..'No' end | |||
--Now the weapon exclusive columns | |||
for j, statName in pairs(weaponStatColumns) do | |||
local statValue = p._getItemStat(item, statName, true) | |||
result = result..'\r\n| style ="text-align: right;padding: 0 0.5em 0 0;' | |||
result = result..'"|'..Shared.formatnum(statValue) | |||
if statName == 'magicDamageBonus' or statName == 'damageReduction' then result = result..'%' end | |||
end | |||
--Finally, the Sources | |||
result = result..'\r\n| style ="text-align: right;white-space: nowrap;padding: 0 0.5em 0 0.5em;" |' | |||
result = result..p._getItemSources(item) | |||
else | |||
--Building rows for armour | |||
result = result..'\r\n|-' | |||
result = result..'\r\n|style ="text-align: left;padding: 0 0 0 0;"|'..Icons.Icon({item.name, type='item', size=50, notext=true}) | |||
result = result..'\r\n|style ="text-align: left;padding: 0 0.5em 0 0.5em;"|[['..item.name..']]' | |||
for j, statName in pairs(statColumns) do | |||
local statValue = p._getItemStat(item, statName, true) | |||
result = result..'\r\n| style ="text-align: right;padding: 0 0.5em 0 0;' | |||
if statValue > 0 then | |||
result = result..'background-color:lightgreen;' | |||
elseif statValue < 0 then | |||
result = result..'background-color:lightpink;' | |||
end | |||
result = result..'"|'..Shared.formatnum(statValue) | |||
if statName == 'magicDamageBonus' or statName == 'damageReduction' then result = result..'%' end | |||
end | |||
--That's the first list out of the way, now for armour specific things | |||
for j, statName in pairs(armourStatColumns) do | |||
local statValue = p._getItemStat(item, statName, true) | |||
result = result..'\r\n| style ="text-align: right;padding: 0 0.5em 0 0;' | |||
if j == 1 then | |||
if statValue > 0 then | if statValue > 0 then | ||
result = result..'background-color:lightgreen;' | result = result..'background-color:lightgreen;' | ||
Line 533: | Line 561: | ||
result = result..'background-color:lightpink;' | result = result..'background-color:lightpink;' | ||
end | end | ||
end | end | ||
result = result..'"|'..Shared.formatnum(statValue) | |||
result = result..' | if statName == 'magicDamageBonus' or statName == 'damageReduction' then result = result..'%' end | ||
result = result.. | |||
end | end | ||
--Finally, the Sources | |||
result = result..'\r\n| style ="text-align: right;white-space: nowrap;padding: 0 0.5em 0 0.5em;" |' | |||
result = result..p._getItemSources(item) | |||
end | end | ||
end | end |