892
edits
(Refactor Slayer tier functions) |
(further rework of slayer) |
||
Line 329: | Line 329: | ||
[4] = 'Very Hard', | [4] = 'Very Hard', | ||
[5] = 'Elite', | [5] = 'Elite', | ||
[6] = 'Insane'} | [6] = 'Insane' | ||
} | |||
function p.getTriangleAttribute(attribute, attackerStyle, targetStyle, mode) | function p.getTriangleAttribute(attribute, attackerStyle, targetStyle, mode) | ||
Line 412: | Line 413: | ||
end | end | ||
function p. | --- Slayer functions | ||
-- | |||
function p.getSlayerTierByID(tierID) -- returns a full table | |||
if not type(tier) == 'number' then | |||
return nil | |||
return | elseif ConstantData.Slayer.Tiers[tierID + 1] == nil then | ||
return nil | return nil | ||
else | else | ||
Line 435: | Line 428: | ||
end | end | ||
function p. | function p.getSlayerTierByLevel(level) -- returns a full table | ||
if not type(level) == 'number' or tier < 0 then | |||
return "ERROR: Invalid Slayer level [[Category:Pages with script errors]]" | |||
end | |||
for i, tier in ipairs(ConstantData.Slayer.Tiers) do | |||
if tier.minLevel <= level then | |||
-- is tier.maxLevel == nil really necessary? | |||
if (tier.maxLevel == nil) or (tier.maxLevel >= level) then | |||
return p.getSlayerTierByID(i - 1) | |||
end | |||
end | |||
end | |||
end | |||
function p.getSlayerTierByName(name) -- returns a full table | |||
local tierID = ConstantData.slayerTier[name] | local tierID = ConstantData.slayerTier[name] | ||
if tierID == nil then | if tierID == nil then | ||
Line 444: | Line 452: | ||
end | end | ||
function p. | -- | ||
-- the following function just return subsets of the slayer functions above | |||
-- | |||
function p.getSlayerTierName(tier, fallback) -- consider replacing with comment | |||
local tier = p.getSlayerTierByID(tier).display | |||
if tier ~= nil then | |||
return tier.display | |||
else | |||
return fallback or "ERROR: Invalid Slayer tier [[Category:Pages with script errors]]" | |||
end | |||
end | |||
function p.getSlayerTierNameByLevel(lvl, fallback) | |||
local tier = p.getSlayerTierByLevel(lvl) | |||
if tier ~= nil then | |||
return tier.display | |||
else | |||
return fallback or "ERROR: Invalid Slayer tier [[Category:Pages with script errors]]" | |||
end | end | ||
end | end | ||
function p.getSlayerTier(name) -- consider removing this function (may break other pages) | |||
return p.getSlayerTierIdByName(name) | |||
end | |||
-- | |||
--- End of slayer functions | |||
--Turns a modifier name like 'increasedMeleeAccuracyBonus' into several pieces of data: | --Turns a modifier name like 'increasedMeleeAccuracyBonus' into several pieces of data: |
edits