Module:LTETables

-- Lua script to get Limited Time Event Tables --

local p = {}

local util = require("Module:Utility") local CARD = require("Module:Card").main local BUNDLE = require("Module:Bundle").getBundle

local tArgs = {} local event = ""

-- Item Type local tItemByType = { ["ch"] = {}, ["tok"] = {}, ["cos"] = {}, ["ba"] = {}, ["bc"] = {}, ["d"]  = {}, ["pf"] = {}, ["ec"] = {}, ["bs"] = {}, ["bd"] = {}, }

local function processArgs(frame) tArgs = util.getArgs(frame)

event = tArgs[1] or "default"

for arg, value in pairs(tArgs) do		local cat, n = tostring(arg):match('^(%a+)([1-9]%d*)$') local num = tonumber(n) if num and tItemByType[cat] then tItemByType[cat][num] = value end end end

local function iTable(iName, iType) local tHead = {"|-|", iName, "=\n \n===Event ", iName, "===\n"}

local tItems = {} tItems = tItemByType[iType]

for chNo, chData in ipairs(tItems) do		if iType == "bd" then table.insert(tHead, BUNDLE({event:lower, chData})) else local tt = mw.text.split(chData, "%s*$%s*") local quests = tt[4] or "" if tt[5] then quests = quests .. "$" .. tt[5] end if tt[6] then quests = quests .. "$" .. tt[6] end if iType == "tok" then table.insert(tHead, CARD({duration=tt[1], name=tt[2], cost=tt[3], quest=quests, event=event, small=true})) else table.insert(tHead, CARD({duration=tt[1], name=tt[2], cost=tt[3], quest=quests, event=event})) end end table.insert(tHead, '\n') end

table.insert(tHead, ' \n')

return table.concat(tHead) end

function p.getTables(frame) processArgs(frame)

local allTables = {}

local allTypes = { {"ch", "Character"}, {"tok", "Token"}, {"cos", "Costume"}, {"ba", "Attraction"}, {"bc", "Concession"}, {"d", "Decoration"}, {"pf", "Parade Float"}, {"ec", "Enchanted Chest"}, {"bs", "Bonus Shop", "Bonus Shop"}, {"bd", "Bundle"}, }

for _, tt in ipairs(allTypes) do		local tOne = tItemByType[tt[1]] if tOne[1] then local name = tt[2] if tOne[2] then name = tt[3] or (tt[2] .. "s") end table.insert(allTables, iTable(name, tt[1])) end end

return table.concat(allTables) end

return p