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 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 table.insert(tHead, CARD({duration=tt[1], name=tt[2], cost=tt[3], quest=quests, event=event})) 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

function p.getTTCTable(frame) local tArgs = util.getArgs(frame) local ICON = require("Module:CharacterAvatar").getAvatar

local tOut = '{| class="article-table" style="width: 100%; text-align: center; line-height: 1.0;"\n! style="width: 20%;"|Collections\n! colspan="7"|Characters\n'

for k, v in pairs(tArgs) do		if tonumber(k) then tOut = tOut .. '|-\n|' if k == 5 then --				tOut = tOut .. '\n' tOut = tOut .. "Featured Character\n" else tOut = tOut .. require('Module:ItemCollection').getCollection({v}) .. '\n' end if not tArgs["C"] then local characters = {} local tCh = {'|\n', '|\n', '|\n', '|\n', '|\n', '|\n', '|\n'} for ch in mw.text.gsplit(v, "%s*$%s*") do					table.insert(characters, ch) end table.sort(characters, function(a,b) return a < b end) for i, character in ipairs(characters) do tCh[i] = '| style="width: 5%;"|' .. ICON({character}) .. ' ' .. character .. ' \n' end tOut = tOut .. table.concat(tCh) end end end

return tOut .. '|}' end

return p