Module:RaritySort

From HighSpell Wiki
Revision as of 17:09, 15 May 2025 by Ryan (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:RaritySort/doc

local p = {}

function p.getSortValue(rarity)
    if type(rarity) ~= "string" then
        return 99 -- Default fallback for nil or non-string
    end

    local r = rarity:lower()

    if r == "always" then
        return 1
    elseif r:match("^1/%d+") then
        return 2
    elseif r == "rare" then
        return 3
    elseif r == "never" then
        return 4
    else
        return 99 -- Unknown or fallback
    end
end

return p