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:MultiItems").getItems

local tOut = {	'{| class="article-table" style="width: 100%; text-align: center; line-height: 1.0;"\n', '! style="text-align: center; width: 14%;"|\n', '! style="text-align: center; width: 20%;"|Collections\n', '! colspan="6"|Attractions\n', '! style="text-align: center; width: 1%;"|Time' }

for k, v in pairs(tArgs) do		if tonumber(k) then

local tRow = {	'\n|-', '\n! style="text-align: center;"|', ' ', "Whole Event", ' ', '\n! style="text-align: center;"|', require('Module:ItemCollection').getCollection({v, 45}), '\n| style="width: 10%;"|', '\n| style="width: 10%;"|', '\n| style="width: 10%;"|', '\n| style="width: 10%;"|', '\n| style="width: 10%;"|', '\n| style="width: 10%;"|', '\n! style="text-align: center;"|', "1h30", ,			,			,			,			,						}

if k == 3 or k == 4 then tRow[4] = 'Chapter ' .. (k - 1) elseif k == 5 then tRow[4] = 'Kingdom Pass' end

local twoline = false

if not tArgs["A"] then for i, att in ipairs(mw.text.split(v, "%s*%$%s*")) do					if i > 6 then twoline = true tRow[16] = '\n|-\n| style="width: 10%;"|' tRow[17] = '\n| style="width: 10%;"|' tRow[18] = '\n| style="width: 10%;"|' tRow[19] = '\n| style="width: 10%;"|' tRow[20] = '\n| style="width: 10%;"|' tRow[21] = '\n| style="width: 10%;"|' tRow[i + 9] = tRow[i + 9] .. ICON({att, "Ba", 45}) .. ' ' .. att .. ' ' else tRow[i + 7] = tRow[i + 7] .. ICON({att, "Ba", 45}) .. ' ' .. att .. ' ' end end end

if twoline == true then tRow[2] = '\n! rowspan="2" style="text-align: center;"|' tRow[6] = '\n! rowspan="2" style="text-align: center;"|' tRow[14] = '\n! rowspan="2" style="text-align: center;"|' end

if k == 3 then tRow[15] = '60m' elseif k == 4 then tRow[15] = '45m' end

table.insert(tOut, table.concat(tRow)) end end

return table.concat(tOut) .. '\n|}' end

return p