17,105
edits
m (typo) |
(Refactor Slayer tier functions) |
||
Line 417: | Line 417: | ||
function p.getSlayerTierNameByLevel(lvl) | function p.getSlayerTierNameByLevel(lvl) | ||
local tier = p.getSlayerTierByLevel(lvl) | |||
if tier == nil then | |||
return 'N/A' | |||
else | |||
return tier.display | |||
end | end | ||
end | end | ||
function p. | function p.getSlayerTierByID(tierID) | ||
return | if ConstantData.Slayer.Tiers[tierID + 1] == nil then | ||
return nil | |||
else | |||
local result = Shared.clone(ConstantData.Slayer.Tiers[tierID + 1]) | |||
result.id = tierID | |||
return result | |||
end | |||
end | end | ||
function p.getSlayerTier(name) | function p.getSlayerTier(name) | ||
local tierID = ConstantData.slayerTier[name] | |||
if tierID == nil then | |||
return nil | |||
else | |||
return p.getSlayerTierByID(tierID) | |||
end | end | ||
end | end | ||
function p. | function p.getSlayerTierByLevel(level) | ||
for i, tier in ipairs(ConstantData.Slayer.Tiers) do | |||
if tier.minLevel <= level and (tier.maxLevel == nil or tier.maxLevel >= level) then | |||
return p.getSlayerTierByID(i - 1) | |||
end | |||
end | end | ||
end | end | ||