Module:YYSandbox
Appearance
local public = {}
local private = {}
-- Removes leading and trailing spaces from strings
function private.trimWhitespace(str)
local whitespace = { [" "]=true, ["\n"]=true, ["\r"]=true }
local _start = 1
while (whitespace[str:sub(_start, _start)]) do
_start = _start + 1
end
local _end = str:len()
while (whitespace[str:sub(_end, _end)]) do
_end = _end - 1
end
return str:sub(_start, _end)
end
-- Checks if a table has a specific key
function private.hasKey(_table, key)
return _table[key] ~= nil
end
-- Gets a specific item from a table, with a fallback if the table doesn't have that key
function private.getValue(_table, key, fallback)
if private.hasKey(_table, key) then
return _table[key]
else
return fallback
end
end
-- Processes a csv row into a table and returns it
function private.processCsv(csv)
local retval = {}
for arg in csv:gmatch("([^,]+)") do
table.insert(retval, private.trimWhitespace(arg))
end
return retval
end
-- Get the arguments from a frame
function private.parseArgs(frame)
if private.getValue(frame.args, "external_args", false) then
return frame:getParent().args
end
return frame.args
end
-- Converts a difficulty number into a format that handles sorting better for + difficulties
function public.SortableDifficulty(frame)
local args = private.parseArgs(frame)
if private.hasKey(args, 1) == false then
return ''
end
local diff = args[1]
if type(diff) == 'number' then
return diff
end
diff = private.trimWhitespace(diff)
if diff:sub(#diff, #diff) == '+' then
return tonumber(diff:sub(1, #diff - 1) .. '.5')
end
return diff
end
-- Converts a version number into a format that handles sorting better
function public.SortableVersion(frame)
local args = private.parseArgs(frame)
if private.hasKey(args, 1) == false then
return ''
end
local retval = ''
for vpart in args[1]:gmatch('[^.]+') do
while #vpart < 4 do
vpart = '0' .. vpart
end
retval = retval .. vpart
end
return retval
end
local normed_stats = {
0.00000000e+00,
5.83175390e-04,
4.66540312e-03,
1.57457355e-02,
3.73232250e-02,
7.28969237e-02,
1.25965884e-01,
2.00029159e-01,
2.98585800e-01,
4.25134859e-01,
5.74865141e-01,
7.01414200e-01,
7.99970841e-01,
8.74034116e-01,
9.27103076e-01,
9.62676775e-01,
9.84254264e-01,
9.95334597e-01,
9.99416825e-01,
1.00000000e+00
}
-- Generates rows (Template:ExactStatTableRow) for use by Template:ExactStatTable
function public.ExactStatTableRows(frame)
local args = private.parseArgs(frame)
local stat = private.getValue(args, 'stat', false)
local playRating = private.getValue(args, 'playrating', 10)
local trackLostFactor = 0
local rows = '{{YYExactStatTableRow|partner=Arcaea|stat20=50}}'
return 'fkjsdhgfdg'
end
return public