Module:Misc

-- Simple text parsing that do not fit in other modules

local getArgs = require('Module:Arguments').getArgs local mergeArgsSyntax = require('Module:Arguments').mergeArgsSyntax local loader = require('Module:Loader')

local string, table, yesno = loader.require('String', 'Table', 'Yesno')

local p = {}

local pet_order = { Lion = { y = 0, s = 0 }, Monkey = { y = 0, s = 1 }, Elephant = { y = 1, s = 0 }, Giraffe = { y = 1, s = 1 }, ['Blue Whale'] = { y = 2, s = 0 }, Tiger = { y = 2, s = 1 }, } local pet_year_cycle = 3

function p.tzYearCycle( frame ) local args = getArgs(frame) return mw.getCurrentFrame:preprocess(p._tzYearCycle(args[1])) end

function p._tzYearCycle(name) local order = pet_order[name] local currYear = 1 + math.floor((os.time(os.date("!*t")) - 1560275700) / 446400) local increment = ((order.y + pet_year_cycle) - (currYear % pet_year_cycle)) % pet_year_cycle return (''):format(order.s == 0 and 'Summer' or 'Winter', currYear + increment) end

function p.sprayInkTooltip(frame) local args = getArgs(frame) local inklist = mergeArgsSyntax({ args.inklist or args[1] }) local inkstring = '' inklist = table.map(inklist, function (v)		local num, item = v:match('%s*(%d+)x?%s+(.*)%s*')		if num and item then			return ('&7 %s: &c%s%%'):format(item, num)		end	end) return table.concat(inklist, '/') end

function p.dashline(frame) local args = getArgs(frame) return string.rep('&#45;', tonumber(args[1]) or 53) -- 53 seems to be the default number of dashes in a game message end

return p