Editing
Module:RarityHandler
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} -- Clean: trim and strip leading ~ local function clean(rarity) if not rarity or type(rarity) ~= "string" then return nil end rarity = mw.text.trim(rarity) if rarity:sub(1, 1) == "~" then rarity = rarity:sub(2) end return rarity end function p.getSortValue(frame) local rarity = frame.args[1] if not rarity or type(rarity) ~= "string" then return 999999999 end -- Trim whitespace and strip leading ~ rarity = mw.text.trim(rarity) if rarity:sub(1, 1) == "~" then rarity = rarity:sub(2) end -- Normalize lowercase local lowered = rarity:lower() -- Handle special values if lowered == "1" or lowered == "always" then return 1 elseif lowered == "rare" then return 999999998 elseif lowered == "never" then return 0 end -- Match and convert fractional chance like "1/2.5", "1/128" local num = lowered:match("^1/(%d+%.?%d*)$") if num then local n = tonumber(num) if n then return n end end -- Unknown or badly formatted return 999999999 end -- For class logic: cleaned string, lowercase function p.getCleanValue(frame) local rarity = clean(frame.args[1]) if not rarity then return "Unknown" end if rarity == "1" then return "Always" end return rarity end -- For display function p.normalizeDisplay(frame) local original = frame.args[1] if not original or type(original) ~= "string" then return "Unknown" end local trimmed = mw.text.trim(original) local hasTilde = trimmed:sub(1, 1) == "~" local cleaned = hasTilde and trimmed:sub(2) or trimmed if cleaned == "1" then return "Always" end return hasTilde and ("~" .. cleaned) or cleaned end return p
Summary:
Please note that all contributions to HighSpell Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
HighSpell Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:RarityHandler/doc
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit
View history
More
Purge cache
Search
Discord
Discord
Navigation
Main page
Recent changes
Random page
HighSpell
Bestiary
Quests
Skills
Shops
Game Maps
Overworld
Underground
Community
Policies
Tools
What links here
Related changes
Special pages
Page information
Cargo data