Module:TableturfCard

local p = {}

function p.main(frame) local args = frame:getParent.args local number = args[1] or args["number"] or "??" local name = args[2] or args["name"] or "?" local spaces = args[3] or args["spaces"] or 0 local special = args[4] or args["special"] or 0 local category = args[5] or args["category"] or "Unsorted" local rarity = args[6] or args["rarity"] or "Common" local full_season = args[7] or args["release"] or "Drizzle Season 2022" local sort_value = args[8] or args["sort-value"] or "99_9999" local size = tonumber(args["size"]) or 64

local rarity_colors = { ["Common"] = "#533ada", ["Rare"] = "#927002", ["Fresh"] = "#0B579D", }   local rarity_color = rarity_colors[rarity] local rarity_sorts = { ["Common"] = 0, ["Rare"] = 1, ["Fresh"] = 2, }   local rarity_sort = rarity_sorts[rarity] local season_index, year_index = p.parseSeason(full_season) local release_sort = tonumber((year_index * 4) + season_index) -- version is the sort +1, then specifically for the first season it's 1.1.0, otherwise it's n.0.0. local release_version = (release_sort + 1) .. (release_sort ~= 0 and ".0.0" or ".1.0")

return mw.ustring.format(       "| %s ||  || %s || %d || data-sort-value=\"%d\"|\n" ..        "| data-sort-value=\"%s\"|%s\n" ..        "| data-sort-value=\"%s\"|%s || \n" ..        "| data-sort-value=\"%s\"| (%s])",        number, name, size, name, spaces, special, special,        sort_value, category,        rarity_sort, rarity_color, rarity, name,        release_sort, release_version, release_season    ) end

function p.parseSeason(full_season) -- Define a table to map season names to their corresponding indices local seasons = { "Drizzle", "Chill", "Fresh", "Sizzle" }

-- Extract the season name and year from the input string local season, year = full_season:gmatch("(%a+) Season (%d+)")

-- If the season name is found, determine its index local seasonIndex = 0 if season then for i, name in ipairs(seasons) do           if name == season then seasonIndex = i - 1 -- Adjust index to start from 0 break end end end

-- Return the season index and year as indexes, or nil if not found return seasonIndex, (tonumber(year) or 2022) - 2022 end

return p