Module:ActivityList

--[==[-- -- Temporary Lua script to get Activity Lists -- --]==]

local p = {}

local util = require("Module:Utility") local COLL = require("Module:ItemCollection") local ACT = require("Module:Activity-2").main local actData = mw.loadData( 'Module:ActivityList/data' ) local actDataEC = mw.loadData( 'Module:ActivityList/dataEC' )

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

local GoTo = {["S"] = ""} local tOut = {	'{| class="article-table sortable" style="text-align: center; width: 100%; line-height: 1.5;"\n', '! style="text-align: center; width: 10%;"|Collection\n', '! style="text-align: center; width: 10%;"|Character\n', '! class="unsortable"|Activity\n', '! style="text-align: center; width: 10%;"|+\n', '! style="text-align: center; width: 1%;" class="unsortable"|Time\n', '! style="text-align: center; width: ', (tArgs[1]=="ANIM" and '5%;"|Location\n' or '1%;"|Wished?\n'),			(tArgs[1] and "" or "|- class=\"sorttop\" style=\"border: 3px #3f51b5 dotted;padding: 5px;\"|\n| colspan=\"7\"|Select the duration of the activities you want to see: 60m · 2h · 4h · 6h · 8h · 10h · 12h · 16h · 18h · 24h  "),		}	for item, data in pairs(actData) do		if tArgs[1] and tArgs[1] == "ANIM" and data[9] then			local collname = COLL.getCollection({data[1], "N"})

if not GoTo[collname] then GoTo["S"] = GoTo["S"] .. collname .. "$"               		GoTo[collname] = true end

local tAct = {	'\n|- id="', collname, '"|', '\n| data-sort-value="', COLL.getCollection({data[1], "D"}), '"|', "', COLL.getCollection({data[1], "D"}), "", '\n| id="', data[1], "-", data[5], '"|', data[1], " Level ", data[2], " ", '\n| style="text-align: left;"|', data[5], " ", data[9], " ", '\n|', (data[3]~="" and (" " .. data[3] .. " ''Lvl " .. data[4] .. "'' ") or ""), '\n| data-sort-value="', (data[6]=="60m" and "1h" or data[6]), '"|', data[6], '\n| ', data[10], ' ', }

table.insert(tOut, table.concat(tAct)) elseif (tArgs[1] and data[6] == tArgs[1]) or (tArgs[1] and data[8] == tArgs[1]) then local collname = COLL.getCollection({data[1], "N"})

if not GoTo[collname] then GoTo["S"] = GoTo["S"] .. collname .. "$"               		GoTo[collname] = true end

local tAct = {	'\n|- id="', collname, '"|', '\n| data-sort-value="', COLL.getCollection({data[1], "D"}), '"|', "', COLL.getCollection({data[1], "D"}), "", '\n|', data[1], " Level ", data[2], " ", '\n| style="text-align: left;"|', data[5], '', '\n|', (data[3]~="" and (" " .. data[3] .. " ''Lvl " .. data[4] .. "'' ") or ""), '\n| data-sort-value="', (data[6]=="60m" and "1h" or data[6]), '"|', data[6], '\n|', data[8], }

if data[7] ~= "" then local sep = "" local rOut = "" local requirements = mw.text.split(data[7], "%s*%$%s*") for idx = #requirements, 1, -1 do					local reqname, reqlvl = mw.ustring.match(requirements[idx], "^(.-)%s*#%s*([%d%,]*)$") if not reqname then reqname = requirements[idx] reqlvl = nil end if reqlvl and reqlvl == "" then reqlvl = nil end rOut = " " .. reqname .. "" .. (reqlvl and (" (Ench. Lvl. " .. reqlvl .. ")") or "") .. sep .. rOut if sep == "" then sep = " &" else sep = "," end end tAct[19] = " ''*" .. rOut .. "'' "			end

table.insert(tOut, table.concat(tAct)) elseif not tArgs[1] then local collname = COLL.getCollection({data[1], "N"})

if not GoTo[collname] then GoTo["S"] = GoTo["S"] .. collname .. "$"               		GoTo[collname] = true end

local tAct = {	'\n|- class="mw-collapsible mw-collapsed" id="mw-customcollapsible-', data[6], '"|', "\n|', COLL.getCollection({data[1], "D"}), "", '\n|', data[1], " Level ", data[2], " ", '\n| style="text-align: left;"|', data[5], '', '\n|', (data[3]~="" and (" " .. data[3] .. " ''Lvl " .. data[4] .. "'' ") or ""), '\n| data-sort-value="', (data[6]=="60m" and "1h" or data[6]), '"|', data[6], '\n|', data[8], }

if data[7] ~= "" then local sep = "" local rOut = "" local requirements = mw.text.split(data[7], "%s*%$%s*") for idx = #requirements, 1, -1 do					local reqname, reqlvl = mw.ustring.match(requirements[idx], "^(.-)%s*#%s*([%d%,]*)$") if not reqname then reqname = requirements[idx] reqlvl = nil end if reqlvl and reqlvl == "" then reqlvl = nil end rOut = " " .. reqname .. "" .. (reqlvl and (" (Ench. Lvl. " .. reqlvl .. ")") or "") .. sep .. rOut if sep == "" then sep = " &" else sep = "," end end tAct[16] = " ''*" .. rOut .. "'' "			end

table.insert(tOut, table.concat(tAct)) end end return (tArgs[1] and COLL.getCollection({GoTo["S"], "A"}) or "") .. "\n" .. table.concat(tOut) .. "\n|}" end

function p.getCharacterActivities(character) if not character or character == "" then return "" end local tOut = { '\n|-| Activities=', '{| class="article-table act2 sortable" style="width: 100%; text-align: center;"', '! style="text-align: center;" width="1"|Lvl', '! width="100%" class="unsortable"|Activity', '! style="text-align: center;" width="1" class="unsortable"|+', '! width="5%" data-sort-type="number"|Time', '! width="20%" class="unsortable"|Rewards', '! width="20%"|Tokens' }	local tOut2 = {} local activities = {}

for _, data in pairs(actData) do		if data[1] == character or data[3] == character then local durNumb, durHMS = string.match(data[6], "^([%d%?]+)([hms])$") local durNumb = tonumber(durNumb) if durNumb then if durHMS == "h" then durNumb = durNumb * 3600 elseif durHMS == "m" then durNumb = durNumb * 60 end else durNumb = 99900 end

if data[7] ~= "" then durNumb = durNumb + 1 end

if data[3] ~= "" then table.insert(activities, {durNumb + 2, ("")}) else table.insert(activities, {durNumb, ("")}) end end end

table.sort(activities, function(a,b) return a[1] < b[1] end)

for _, template in pairs(activities) do		table.insert(tOut, template[2]) end

table.insert(tOut, "|}")

for _, ecdata in pairs(actDataEC) do		for item in mw.text.gsplit(ecdata[2], "%s*%$%s*") do			if item == character then table.insert(tOut2, ("")) end end end

if table.concat(tOut2) ~= "" then table.insert(tOut2, 1, '\n|-| Event Activities=') table.insert(tOut2, 2, '{| class="article-table act2" style="width: 100%; text-align: center;"') table.insert(tOut2, 3, '! style="text-align: center;" width="1"|Lvl') table.insert(tOut2, 4, '! width="100%" class="unsortable"|Activity') table.insert(tOut2, 5, '! style="text-align: center;" width="1" class="unsortable"|+') table.insert(tOut2, 6, '! width="5%" data-sort-type="number"|Time') table.insert(tOut2, 7, '! width="20%" class="unsortable"|Rewards') table.insert(tOut2, "|}") table.insert(tOut, table.concat(tOut2, "\n")) end return table.concat(tOut, "\n") end

return p