17,105
edits
(_getItemStat: Don't waste time iterating over equipRequirements if the specified skill was not found) |
(Implement _processEquipmentLevelReqs()) |
||
Line 117: | Line 117: | ||
else | else | ||
out[k] = out[k] + v | out[k] = out[k] + v | ||
end | |||
end | |||
end | |||
return out | |||
end | |||
-- Input: equipRequirements property of an item | |||
-- Output: Table in the format { ["Attack"] = 80, ... } | |||
function p._processEquipmentLevelReqs(equipReqs) | |||
local out = {} | |||
if type(equipReqs) == 'table' then | |||
for i, req in pairs(equipReqs) do | |||
if req.type == 'Level' then | |||
for j, levelReq in pairs(req.levels) do | |||
local skillName = Constants.getSkillName(levelReq.skill) | |||
if skillName ~= nil then out[skillName] = levelReq.level end | |||
end | |||
end | end | ||
end | end | ||
Line 138: | Line 155: | ||
elseif string.find(StatName, '^(.+)LevelRequired$') ~= nil then | elseif string.find(StatName, '^(.+)LevelRequired$') ~= nil then | ||
local skillName = Shared.titleCase(string.match(StatName, '^(.+)LevelRequired$')) | local skillName = Shared.titleCase(string.match(StatName, '^(.+)LevelRequired$')) | ||
if skillName ~= nil then | |||
local levelReqs = p._processEquipmentLevelReqs(item.equipRequirements) | |||
result = levelReqs[skillName] | |||
end | end | ||
elseif StatName == 'attackType' then | elseif StatName == 'attackType' then |