Module:Float

--[==[-- -- Lua script to get Float Information -- float: get Float data based on input parameters 1 = Float Name 3 = Event Name / IP Short Name

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

local p = {}

---[=[ For testing remove 1 '-' from start of line local floatData = mw.loadData('Module:Float/data') --[==[]=] local floatData = { ["The Little Mermaid"] = { ["A"] = "500", ["R"] = { ["magic"] = {"250", 5, "500", "IP-TLM$Sebastian,2$Scuttle,2$King Triton,2$Ursula,2"}, ["tlm"] = {"450", 5, ""}, }	}, } --]==]

local EC = require("Module:EC").getEC local TOK = require("Module:CharacterToken").getToken local lte = require("Module:LTEvent").getLTE local util = require("Module:Utility")

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

local floatName = tArgs[1] or "" local event = tArgs[2] or "" local outType = tArgs[3] or "D"

floatName = floatName:gsub("^%s*(.-)%s*$", "%1") or '' if floatName == "" then floatName = mw.title.getCurrentTitle.text else floatName = mw.text.decode(floatName, false) end floatName = floatName:gsub("%s*Float$", "")

event = event:lower:gsub("^%s*(.-)%s*$", "%1") or ''

if not outType:match("^[D]$") then outType = "" end

local data = {}

if floatData[floatName] then data = floatData[floatName] else data = { ["A"] = "?", ["R"] = { ["magic"] = {"?", "?", "?", "?"}, }		}		floatName = "Unknown" end

local reward = ""

if event ~= "" and data["R"][event] then reward = event else reward = "magic" -- current event (no magic entry yet) -- pick the first reward key (should be for current event) if not data["R"]["magic"] then for k, v in pairs(data["R"]) do				reward = k				break end end end

local tFunc = { -- Default (token rewards table row) ["D"] = function local tRet = {"|-\n| style=\"text-align: center;\"|", "", "\n|", "", "",									"", "", "", "", "", "", "\n|\n| nowrap|", "", "\n| nowrap|", "", "", " (+ ", "", "", "", 									"", "", ")", "", ""					}					tRet[ 2] = " " tRet[ 6] = floatName tRet[ 7] = " Float" if data["R"][reward][1] ~= "" then tRet[13] = "2h (+ 6h)" tRet[15] = EC({reward}) tRet[16] = data["R"][reward][1] tRet[18] = EC({"Gems"}) tRet[19] = data["R"][reward][2] if data["R"][reward][3] ~= "" then tRet[20] = ", " tRet[21] = EC({reward}) tRet[22] = data["R"][reward][3] end if event == "" and data["R"][reward][4] then tRet[24] = "\n| nowrap|" tRet[25] = TOK({data["R"][reward][4], "", "B"}) end else tRet[17] = "" tRet[23] = "" end return table.concat(tRet) end, }	return tFunc[outType] end

function p.getFloatinfo(frame) local tArgs = util.getArgs(frame) local coll = require("Module:ItemCollection") local fName = tArgs[1] or mw.title.getCurrentTitle.text fName = fName:gsub("^%s*(.-)%s*$", "%1") or '' local VL = mw.ext.VariablesLua

if tArgs[1] then VL.vardefine("premium", coll.getPremium({fName})) VL.vardefine("limited", coll.getPremium({fName})) else VL.vardefine("premium", coll.getPremium({})) VL.vardefine("limited", coll.getPremium({})) end VL.vardefine("collection", coll.getCollection({fName, "T"}))

fName = fName:gsub("%s*Float$", "") VL.vardefine("file", ("pf-" .. fName:lower:gsub(" ", "_")) .. ".png")

local data = {}

if floatData[fName] then data = floatData[fName] else data = { ["A"] = "?", ["R"] = { ["magic"] = {"?", "?", "?", "?"}, }		}	end

VL.vardefine("assigncost", (EC({"Magic"}) .. data["A"]))

local reward = "magic" if not data["R"]["magic"] then for k, v in pairs(data["R"]) do			reward = k			break end end

VL.vardefine("rewards")

VL.vardefine("rewards", (EC({reward}) .. data["R"][reward][1])) VL.vardefine("chancerewards", (EC({"Gems"}) .. data["R"][reward][2] .. ", " .. EC({reward}) .. data["R"][reward][3])) VL.vardefine("tokens", TOK({(data["R"][reward][4] or ""), "I"}))

local retText = "" local space = ""

for k, v in pairs(data["R"]) do		if k ~= "magic" then local tRow = {	space, EC({"Gems"}), v[2], ", ", EC({k}), v[3], " (", lte({k, nil, "K"}), " Event) " }			retText = retText .. table.concat(tRow) space = " " end end VL.vardefine("eventrewards", retText) VL.vardefine("eventchancerewards", "") VL.vardefine("eventtokens", "")

return "" end

return p