Module:ALU

--[==[-- -- Lua script to get Attraction Enchantments -- getEnchantments: get Enchantment Level data based on input parameters name    = Building Name (PAGENAME by default) tokens  = Tokens (format "Character,Token") separate tokens with dollar sign "$" one token per enchantment level event   = Event Name / IP Short Name (optional) cost    = Building Cost (Legendary Chests by default) (optional) building = Building Time (Instant by default) relic   = if relic token different from the collection (optional) ip      = if collection token different from the collection (optional)

Unknown is returned if building is not in data. --]==]

local p = {}

local enchData = mw.loadData('Module:ALU/data') local attrData = mw.loadData('Module:Building/data') local itemData = mw.loadData( 'Module:ItemCollection/data' )

local EC = require("Module:EC").getEC local TOK = require("Module:CharacterToken").getToken local CHEST = require("Module:ECR").getITEM local COLL = require("Module:ItemCollection").getCollection local LTE = require("Module:LTEvent").getLTE local util = require("Module:Utility")

function p.getALU(frame) local tArgs = util.getArgs(frame) local event = tArgs["event"] if event then event = event:lower:gsub("^%s*(.-)%s*$", "%1") or '' end local pagename = tArgs["name"] or mw.title.getCurrentTitle.text if attrData[pagename] then attData = attrData[pagename] else return "Unknown Building" end local tOut = {} local tokens = {} local tRet = {} if tArgs["tokens"] then local reward = "magic" if event and event ~= "" and attData["R"][event] then reward = event elseif not attData["R"][reward] then for k, v in pairs(attData["R"]) do				reward = k				break end end local numb = 0

table.insert(tOut, '{| class="article-table" style="width: 100%; text-align: center; line-height: 1.0;"\n') if reward ~= "magic" then table.insert(tOut, '|-\n! colspan="8" style="text-align: center;"|') table.insert(tOut, LTE({reward, "N"})) table.insert(tOut, '\n|-\n') end table.insert(tOut, '! width="15%"|Enchantment\n! colspan="4"|Requirements\n! width="10%"|Time\n! colspan="2" width="17%"|Rewards (Every ')		table.insert(tOut, attData["R"][reward][1])		table.insert(tOut, ') \n')

for item in mw.text.gsplit(tArgs["tokens"], "%s*%/%s*") do      			table.insert(tokens, {numb, item}) numb = numb + 1 if numb == 6 then break end end if numb > 1 then table.insert(tokens, {numb, "two chances"}) end table.sort(tokens, function(a,b) return a[1] < b[1] end) for _, item in ipairs(tokens) do tRet = {"|-\n|", "Level " .. item[1], "\n| nowrap|", "", "", "\n| nowrap|", "", "", "\n| nowrap|", "", "", "\n| nowrap|", "", "", "\n|", "", '\n| style="width: 15%;"|', "", "", "\n| nowrap|", "", "", "", "\n" }			if item[1] == 0 then tRet[ 2] = "Building" tRet[ 3] = "\n| colspan=\"4\" style=\"text-align: center;\"|" if tArgs["cost"] then tRet[ 6] = tArgs["cost"] else tRet[ 6] = CHEST({"L"}) end tRet[ 9] = "" tRet[12] = "" tRet[16] = tArgs["building"] or "Instant" tRet[19] = TOK({item[2], "P-25"}) tRet[22] = EC({reward}) tRet[23] = attData["R"][reward][3] else local coll = COLL({pagename, "S"}) local tData = enchData["Requirements"][tostring(item[1])] local rItem = TOK({"Relic " .. (tArgs["relic"] or coll), "R"}):gsub(" relic", "") tRet[ 4] = TOK({"Blueprint " .. tData[1]}) tRet[ 5] = tData[2] tRet[ 7] = TOK({("Relic " .. (tArgs["relic"] or coll))}) tRet[ 8] = enchData["Requirements"][rItem][item[1]] tRet[10] = TOK({("IP-" .. (tArgs["ip"] or coll))}) tRet[11] = tData[3] tRet[13] = EC({"Magic"}) tRet[14] = tData[4] tRet[16] = tData[5] if item[1] ~= 5 then tRet[18] = "+" end tRet[19] = TOK({item[2], "P-25"}) if reward == "magic" then tRet[21] = "+" tRet[22] = EC({reward}) local durNumb = attData["R"]["magic"][1] or "?h" local mData = enchData["Magic Rewards"][durNumb][tostring(item[1])] if itemData["Items"][pagename] then local cData = itemData["Items"][pagename] if cData[4] and cData[4] == true then if cData[3] and cData[3] == true then tRet[23] = mData[2] else if cData[1] and cData[1] < 1170 then tRet[23] = mData[1] else tRet[23] = mData[2] end end elseif cData[3] and cData[3] == true then tRet[23] = mData[2] else tRet[23] = mData[1] end end end end table.insert(tOut, table.concat(tRet)) end end return table.concat(tOut) .. "|}" end

return p