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")

local tArgs = {} local event = ""

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

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

event = tArgs[1]

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 if num and cat=="co" then local tt = mw.text.split(value, "%s*$%s*") tItemByType["coData"][num] = {C={(tt[4] or "")}, G=(tt[6] or "")} 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.getBundle({event, chData, true})) elseif iType == "co" then table.insert(tHead, BUNDLE.getChainOffer({event, chData, true, tItemByType["coData"]})) else local tt = mw.text.split(chData, "%s*$%s*") local requirements = tt[4] or "" if tt[5] then requirements = requirements .. "$" .. tt[5] end if tt[6] then requirements = requirements .. "$" .. tt[6] end if iType == "tok" then table.insert(tHead, CARD({duration=tt[1], name=tt[2], cost=tt[3], requirement=requirements, event=event, small=true})) else table.insert(tHead, CARD({duration=tt[1], name=tt[2], cost=tt[3], requirement=requirements, 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"}, {"bd", "Bundle"}, {"co", "Chain Offer", "Chain Offer"}, }

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