Module:LU

--[[ Lua script to get Character Level Ups Tables

getLU: get Character Level Ups Table based on input parameters Parameters: event = Event Name / IP Short Name (optional) --]]

local p = {}

local util = require("Module:Utility") local ACT = require("Module:ActivityList").getCharacterActivities local COLL = require("Module:ItemCollection").getCollection local LTE = require("Module:LTEvent").getLTE local EC = require("Module:EC").getEC local oneItem = require("Module:MultiItems").getOneItem

local lu   = {} local pagename = ""

local function luItems(inStr) local tOut = {} local tIn = mw.text.split(inStr, "%s*%$%s*") for idx = 1, #tIn do		table.insert(tOut, tIn[idx]) end

return tOut end

local function luTable(tableData, tableNo) local time = {"Instant", "36s", "6m", "35m", "60m", "2h", "4h", "8h", "16h", "24h"} local gems = {"", "1", "1", "1", "2", "2", "3", "3", "3", "5"} local xp  = {"", "10", "12", "14", "17", "20", "23", "26", "29", "30"} local title = "" local tabName = "" local eName = "" local eType = ""

local prevToken = {} local collection = COLL({pagename, "S"}) local token = {("IP-" .. collection:upper), (pagename .. ",2"), (pagename .. ",3"), "EC-Magic"}

if tableNo and lu[tableNo]["name"] then eName = lu[tableNo]["name"][1] eType = lu[tableNo]["name"][2] or "N" if LTE({eName, eType}) == "Unknown Event 0001" then title = '! colspan="7" style="text-align: center;"|' .. eName .. '\n|-\n' tabName = " (First Release)" else title = '! colspan="7" style="text-align: center;"|' .. LTE({eName, eType}) .. '\n|-\n' if eType == "T" then token[4] = "EC-TTC" else token[4] = "EC-" .. eName end tabName = LTE({eName:lower, eType, "K"}) tabName = " (" .. tabName .. " Event)" end end

local tOut = { '\n|-| Level Ups', tabName, '=\n', '{| class="article-table" style="width: 100%; text-align: center; line-height: 1.0;"\n', title, '! style="width: 10%; text-align: center;"|Level\n', '! style="text-align: center;" colspan="4"|Requirements\n', '! style="width: 5%; text-align: center;"|Time\n', '! style="width: 10%; text-align: center;"|Rewards\n' }

for luNo, luData in ipairs(tableData) do local tRow = {'|-\n', '| nowrap|', ("Level " .. luNo), '\n', "", "", "", "", '|', (luData[5] or time[luNo]), '\n', '| nowrap|', EC({"Gems"}), (luData[6] or gems[luNo]), ', ', EC({"XP"}), (luData[7] or xp[luNo]), '\n', }

if luNo == 2 and eName ~= "" and eType == "N" then tRow[10] = "6s" end

for idx = 1, 4 do			local item = mw.text.split((luData[idx] or ""), "%s*#%s*") if luNo == 1 and not luData[idx + 1] then tRow[3] = "Welcome" tRow[5] = '| colspan="4"|' if item[2] then tRow[7] = oneItem(item[1], item[2], 30, true) else tRow[7] = item[1] end tRow[8] = '\n' tRow[13] = "" tRow[14] = "" tRow[15] = "" tRow[16] = "" tRow[17] = "" break else if not item[2] then tRow[4 + idx] = '| style="width: 15%;"|' .. oneItem(token[idx], item[1], 30, token[idx] ~= prevToken[idx]) .. '\n' prevToken[idx] = (item[1]=="" and "" or token[idx]) else tRow[4 + idx] = '| style="width: 15%;"|' .. oneItem(item[1], item[2], 30, item[1] ~= prevToken[idx]) .. '\n' token[idx]    = item[1] prevToken[idx] = item[1] end end end table.insert(tOut, table.concat(tRow)) end

table.insert(tOut, '|}\n')

return table.concat(tOut) end

function p.getLU(frame) local tArgs = util.getArgs(frame)

pagename = tArgs["name"] or mw.title.getCurrentTitle.text

local onetable = {}

lu[1] =

for arg, value in pairs(tArgs) do		local cat, t, n = tostring(arg):match('^(%a+)([1-9]-)_?([1-9]%d*)$') local num = tonumber(n) local tNo = tonumber(t) or 1 if num then if cat == "lu" then if not lu[tNo] then lu[tNo] = {} end lu[tNo][num] = luItems(value, pagename) elseif cat == "luN" then if not lu[num] then lu[num] = {} end lu[num]["name"] = mw.text.split(value, "%s*%$%s*") elseif cat == "luA" then onetable = {num, tonumber(value)} end end end

if table.concat(onetable) ~= "" then lu[onetable[2]] = lu[onetable[1]] lu[onetable[1]] = nil end

local allTables = {}

if lu[1] then for tNo, tData in ipairs(lu) do			table.insert(allTables, luTable(tData, tNo)) end table.insert(allTables, 2, ACT(pagename)) end

return frame:preprocess(table.concat(allTables)) end

return p