Module:Card

--[=[

Lua Module for Item Cards

--]=]

local p = {} local util = require("Module:Utility") local storylineData = mw.loadData( 'Module:Storyline/data' ) local EC = require("Module:EC").getEC local CHEST = require("Module:EnchantedChest").getChest local RARITY = require("Module:Rarity").rarity local TOK = require("Module:CharacterToken").getToken

local function costTable(cost, sale, duration, token) local iCost = ' " end

function p.getCost(frame) local tArgs = util.getArgs(frame) return costTable(tArgs[1], nil, tArgs[2]) end

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

local iFile = "" local iLink = "" local iQuest = "" local iCost = "" local span = "" local space = "" local iEvent = (tArgs["event"] or "default"):lower

if tArgs["name"] then local name = tArgs["name"]

local conv = {["ch"] = "cp", ["cos"] = "cp"}

local iName, iDisp = mw.ustring.match(name, "^([^,]-)%s*#%s*(.-)$") if not iName then iName = name end local cData = mw.loadData("Module:ItemCollection/data")

if name:match(" Chests") then iFile = CHEST({name, 100}) iLink = CHEST({name, "L"}) elseif name:match("^XP") then iFile = EC({"XP", nil, nil, "I", 60}) iLink = "Level " .. (iDisp or "0") span = ' ' .. (iDisp or "0") .. ' '		elseif name:match("^EC%-") then iFile = EC({name, nil, nil, nil, 100}) iLink = EC({name, "L"}) elseif cData["Items"][iName] then local fName = iName:lower:gsub("[':%,%.]", ""):gsub(" ", "_") if cData["Items"][iName][2] == "pf" then fName = fName:gsub("_float$", "") else fName = fName:gsub("^([^%(]-)_*%(([^%d]+%d*)%)$", "%1-%2")			end			iFile = ""			iLink =  .. (iDisp or iName) .. 		else			iFile = TOK({name, 100})			if tArgs["event"]:match("^ts") then				iFile = TOK({name, 50})			end			iLink = TOK({name, "L"})		end	end

if tArgs["quest"] then for onequest in mw.text.gsplit(tArgs["quest"], "%s*$%s*") do			local qName, qDisp = mw.ustring.match(onequest, "^([^,]-)%s*#%s*(.-)$") if not qName then qName = onequest end

if qDisp then qDisp = qName .. " Level " .. qDisp else if qName:match("^.+%#Part %d$") then local name, anch = qLink:match("^(.+)%#Part (%d+)$") if name:match("^.+ %(%d%)$") then qDisp = name:match("(.+) %(%d%)$") else qDisp = name end qDisp = qDisp .. ", Pt. " .. anch else if qName:match("^.+ %(%d%)$") then qDisp = qName:match("(.+) %(%d%)$") else qDisp = qName end end end

iQuest = iQuest .. table.concat({space, "", qDisp, ""}) space = " " end iQuest = " " .. iQuest .. " "	elseif tArgs["text"] then iQuest = " " .. tArgs["text"] .. " "	elseif tArgs["reward"] then iQuest = ' "	else		iQuest = "    "	end

if tArgs["cost"] then iCost = costTable(tArgs["cost"], tArgs["sale"], tArgs["duration"]) end

local tOut = {'| class="', iEvent, '" style="width: 190px; min-width: 190px; padding: ', '15px 10px 15px 10px', '; ', 'background-repeat: round;', ' color: white; text-shadow: 1px 2px 3px #030d9d;"|', iFile, " ", iLink, "", iQuest, iCost}

if tArgs["event"]:match("^ts") then tOut[ 2] = iEvent .. TOK({tArgs["name"], "R"}) tOut[ 4] = "5px 10px 15px 10px" tOut[12] = " " tOut[13] = costTable(tArgs["cost"], nil, nil, TOK({tArgs["name"], "C"})) end

if tArgs["name"]:match("^XP") then tOut[12] = span tOut[13] = iQuest end

if storylineData["Colors"][iEvent] and not storylineData["Colors"][iEvent]["I"] then tOut[ 6] = "background: radial-gradient(circle at 50% 60%, #" .. storylineData["Colors"][iEvent][3] .. ", #" .. storylineData["Colors"][iEvent][2] .. " 70%); border-radius: 25px; box-shadow: inset 0 0 7px 2px #08273c, 0 0 7px #666666; border: 4px solid #" .. (storylineData["Colors"][iEvent][5] or storylineData["Colors"][iEvent][4]) .. ";"	end

return table.concat(tOut) end

return p