17,105
edits
mNo edit summary |
m (Revert to previous revision) |
||
Line 30: | Line 30: | ||
end | end | ||
local | local isWeaponType = itemList[1].validSlots ~= nil and Shared.contains(itemList[1].validSlots, 'Weapon') and Shared.contains(weaponTypes, itemList[1].type) | ||
--Now that we have a preliminary list, let's figure out which columns are irrelevant (IE are zero for all items in the selection) | --Now that we have a preliminary list, let's figure out which columns are irrelevant (IE are zero for all items in the selection) | ||
local ignoreColumns = Shared.clone(statColumns) | local ignoreColumns = Shared.clone(statColumns) | ||
for i, | for i, item in pairs(itemList) do | ||
local ndx = 1 | local ndx = 1 | ||
while Shared.tableCount(ignoreColumns) >= ndx do | while Shared.tableCount(ignoreColumns) >= ndx do | ||
if Items._getItemStat( | if Items._getItemStat(item, ignoreColumns[ndx], true) ~= 0 then | ||
table.remove(ignoreColumns, ndx) | table.remove(ignoreColumns, ndx) | ||
else | else | ||
Line 173: | Line 171: | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Sources') | table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Sources') | ||
table.sort(itemList, function(a, b) return a < b end) | table.sort(itemList, function(a, b) return a.id < b.id end) | ||
for i, | for i, item in pairs(itemList) do | ||
if isWeaponType then | if isWeaponType then | ||
--Building rows for weapons | --Building rows for weapons | ||
table.insert(resultPart, '\r\n|-') | table.insert(resultPart, '\r\n|-') | ||
table.insert(resultPart, '\r\n|style="text-align: left;"|'..Icons.Icon({item.name, type='item', size=50, notext=true})) | 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: left;"|[['..item.name..']]') | table.insert(resultPart, '\r\n|style ="text-align: left;padding: 0 0.5em 0 0.5em;"|[['..item.name..']]') | ||
table.insert(resultPart, '\r\n| style="text-align: right;" |'..Shared.formatnum(Items._getItemStat(item, 'attackSpeed', true))) | table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;" |'..Shared.formatnum(Items._getItemStat(item, 'attackSpeed', true))) | ||
--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;"|') | ||
Line 187: | Line 184: | ||
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;') | table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;') | ||
if string.find(statName, '^(.+)LevelRequired$') == nil then | if string.find(statName, '^(.+)LevelRequired$') == nil then | ||
if statValue > 0 then | if statValue > 0 then | ||
Line 200: | 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;white-space:nowrap;"|') | table.insert(resultPart, '\r\n|style="text-align:left;white-space:nowrap;padding:0 0.5em 0 0.5em;"|') | ||
table.insert(resultPart, Constants.getModifiersText(item.modifiers, true)) | table.insert(resultPart, Constants.getModifiersText(item.modifiers, true)) | ||
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;"|') | table.insert(resultPart, '\r\n|style="text-align:left;padding:0 0.5em 0 0.5em;"|') | ||
table.insert(resultPart, item.description ~= nil and item.description or '') | table.insert(resultPart, item.description ~= nil and item.description or '') | ||
end | end | ||
--Finally, the Sources | --Finally, the Sources | ||
table.insert(resultPart, '\r\n| style="text-align: right;" |') | table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0.5em;" |') | ||
table.insert(resultPart, ItemSourceTables._getItemSources(item)) | table.insert(resultPart, ItemSourceTables._getItemSources(item)) | ||
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;"|'..Icons.Icon({item.name, type='item', size=50, notext=true})) | 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: left;"|[['..item.name..']]') | table.insert(resultPart, '\r\n|style ="text-align: left;padding: 0 0.5em 0 0.5em;"|[['..item.name..']]') | ||
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;') | table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;') | ||
if statValue > 0 then | if statValue > 0 then | ||
table.insert(resultPart, 'background-color:lightgreen;') | table.insert(resultPart, 'background-color:lightgreen;') | ||
Line 229: | Line 226: | ||
--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;white-space:nowrap;"|') | table.insert(resultPart, '\r\n|style="text-align:left;white-space:nowrap;padding:0 0.5em 0 0.5em;"|') | ||
table.insert(resultPart, Constants.getModifiersText(item.modifiers, true)) | table.insert(resultPart, Constants.getModifiersText(item.modifiers, true)) | ||
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;"|') | table.insert(resultPart, '\r\n|style="text-align:left;padding:0 0.5em 0 0.5em;"|') | ||
table.insert(resultPart, item.description ~= nil and item.description or '') | table.insert(resultPart, item.description ~= nil and item.description or '') | ||
end | end | ||
--Finally, the Sources | --Finally, the Sources | ||
table.insert(resultPart, '\r\n| style ="text-align: right;" |') | table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0.5em;" |') | ||
table.insert(resultPart, ItemSourceTables._getItemSources(item)) | table.insert(resultPart, ItemSourceTables._getItemSources(item)) | ||
end | end | ||
Line 273: | Line 270: | ||
--Now we need to figure out which items are in this list | --Now we need to figure out which items are in this list | ||
local itemList = {} | local itemList = {} | ||
for i, | for i, itemBase in pairs(ItemData.Items) do | ||
local item = Shared.clone(itemBase) | |||
item.id = i - 1 | |||
local listItem = false | local listItem = false | ||
if isWeaponType then | if isWeaponType then | ||
Line 293: | Line 292: | ||
end | end | ||
if listItem then | if listItem then | ||
table.insert(itemList, item | table.insert(itemList, item) | ||
end | end | ||
end | end | ||
Line 306: | Line 305: | ||
local itemList = Items.getItems(function(item) | local itemList = Items.getItems(function(item) | ||
local isMatch = | local isMatch = true | ||
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 | |||
elseif style == 'Ranged' then | |||
if Items._getItemStat(item, 'rangedLevelRequired') == nil and not Shared.contains(styleOverrides.Ranged, item.name) then isMatch = false end | |||
elseif style == 'Magic' then | |||
if Items._getItemStat(item, 'magicLevelRequired') == nil and not Shared.contains(styleOverrides.Magic, item.name) then isMatch = false end | |||
elseif style == 'None' then | |||
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 | |||
not Shared.contains(styleOverrides.None, item.name) then | |||
isMatch = false | |||
end | end | ||
end | |||
if slot == nil or not Shared.contains(item.validSlots, slot) then isMatch = false end | |||
if isMatch and other ~= nil then | |||
if slot == 'Weapon' then --For quiver slot or weapon slot, 'other' is the ammo type | |||
if other == 'Arrows' then | |||
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 | |||
if other == 'Arrows' then | |||
if item.ammoType ~= 0 then isMatch = false end | |||
elseif other == 'Bolts' then | |||
if item.ammoType ~= 1 then isMatch = false end | |||
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 347: | Line 344: | ||
return isMatch | return isMatch | ||
end | end) | ||
return p._getEquipmentTable(itemList, includeModifiers, includeDescription) | return p._getEquipmentTable(itemList, includeModifiers, includeDescription) | ||
Line 381: | Line 378: | ||
hasErr = true | hasErr = true | ||
else | else | ||
table.insert(itemList, nextItem | table.insert(itemList, nextItem) | ||
end | end | ||
end | end | ||
Line 476: | Line 473: | ||
--Unfortunately just gonna have to manually check all the changes I think... | --Unfortunately just gonna have to manually check all the changes I think... | ||
local statList = { | |||
-- {'statName', 'statDescription'} | |||
{'stabAttackBonus', '{V} '..Icons.Icon({'Melee', notext=true})..' Stab Bonus'}, | |||
{'slashAttackBonus', '{V} '..Icons.Icon({'Melee', notext=true})..' Slash Bonus'}, | |||
{'blockAttackBonus', '{V} '..Icons.Icon({'Melee', notext=true})..' Block Bonus'}, | |||
{'meleeStrengthBonus', '{V} '..Icons.Icon({'Strength', type='skill', notext=true})..' Strength Bonus'}, | |||
{'rangedStrengthBonus', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Strength Bonus'}, | |||
{'magicStrengthBonus', '{V}% '..Icons.Icon({'Magic', type='skill', notext=true})..' Damage Bonus'}, | |||
{'meleeDefenceBonus', '{V} '..Icons.Icon({'Defence', type='skill', notext=true})..' Defence Bonus'}, | |||
{'rangedDefenceBonus', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Defence Bonus'}, | |||
{'magicDefenceBonus', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Defence Bonus'}, | |||
{'damageReduction', '{V}% Damage Reduction'}, | |||
{'increasedSlayerXP', '{V}% '..Icons.Icon({'Slayer', type='skill', notext=true})..' Bonus XP'}, | |||
{'attackLevelRequired', '{V} '..Icons.Icon({'Attack', type='skill', notext=true})..' Level Required'}, | |||
{'defenceLevelRequired', '{V} '..Icons.Icon({'Defence', type='skill', notext=true})..' Level Required'}, | |||
{'rangedLevelRequired', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Level Required'}, | |||
{'magicLevelRequired', '{V} '..Icons.Icon({'Magic', type='skill', notext=true})..' Level Required'}, | |||
} | |||
for i, stat in ipairs(statList) do | |||
if stat[1] == 'increasedSlayerXP' then | |||
getSpecificStatString(Items._getItemModifier(item1, stat[1], 'Slayer'), Items._getItemModifier(item2, stat[1], 'Slayer'), stat[2]) | |||
else | |||
getSpecificStatString(Items._getItemStat(item1, stat[1]), Items._getItemStat(item2, stat[1]), stat[2]) | |||
end | |||
end | |||
return table.concat(changeArray, '<br/>') | return table.concat(changeArray, '<br/>') | ||
Line 553: | Line 556: | ||
table.insert(resultPart, '\r\n|}') | table.insert(resultPart, '\r\n|}') | ||
return table.concat(resultPart) | return table.concat(resultPart) | ||
end | end | ||
return p | return p |