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 TOK = require("Module:CharacterToken").getToken

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

local iFile = "" local iLink = "" local iQuest = "" local iCost = "" local space = ""

if tArgs["name"] then local iName, iDisp = mw.ustring.match(tArgs["name"], "^([^,]-)%s*#%s*(.-)$") if not iName then iName = tArgs["name"] end

local conv = {["ch"] = "cp", ["cos"] = "cp"} local cData = mw.loadData("Module:ItemCollection/data") local iData = cData.Items[iName] or ""

if iName:match(" Chests") then iFile = CHEST({iName, 100}) iLink = CHEST({iName, "L"}) elseif iName:match("^EC%-") then iFile = EC({iName, nil, nil, nil, 100}) iLink = EC({iName, "L"}) elseif iData ~= "" then local fName = iName:lower:gsub("[':%,%.]", ""):gsub(" ", "_") if iData[2] == "pf" then fName = fName:gsub("_float$", "") else fName = fName:gsub("^([^%(]-)_*%(([^%d]+%d*)%)$", "%1-%2")			end			iFile = ""			iLink =  .. (iDisp or iName) .. 		else			iFile = TOK({iName, 100})			iLink = TOK({iName, "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 not qDisp then 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 elseif tArgs["token"] then iQuest = TOK({tArgs["token"], "C"}) end

if tArgs["cost"] then local cName, cNumb = mw.ustring.match(tArgs["cost"], "^([^,]-)%s*#%s*(.-)$") if not cName then cNumb = tArgs["cost"] end

if tArgs["sale"] then local ecNumb = cNumb local sNumb = tArgs["sale"] cNumb = sNumb .. '  ' .. ecNumb .. ' (-'			ecNumb = tonumber((string.gsub(ecNumb or "", "[,]", "")))			sNumb = tonumber((string.gsub(sNumb or "", "[,]", "")))			cNumb = cNumb .. math.ceil(100-((sNumb/ecNumb)*100)) .. '%) ' end

if cName and cName:match("^EC") then cName = EC({cName}) iCost = ' "	end

local tOut = {'| style="width: 160px; padding: 15px 35px 15px 35px; background: radial-gradient(circle at 50% 60%, ', "#49d9ea 10%, #21d6ea 15%, #0e7897 45%, #0c4468 65%", '); color: white; text-shadow: 1px 2px 3px #030d9d; border-radius: 20px; border: 4px solid #', "d3e8f7", '; box-shadow: inset 0 0 7px 2px #08273c, 0 0 7px #666666;"|', iFile, " ", iLink, "  ", iQuest, "  ", iCost}

if tArgs["event"] then iEvent = tArgs["event"]:lower if storylineData["Colors"][iEvent] then tOut[2] = "#" .. storylineData["Colors"][iEvent][3] .. ", #" .. storylineData["Colors"][iEvent][2] .. " 70%"			tOut[4] = storylineData["Colors"][iEvent][5] or storylineData["Colors"][iEvent][4] end end

return table.concat(tOut) end

return p