Module:ItemInfobox

-- Any major change to the infobox templates or new parameter should be suggested on the talk page first. local categorization = require('Module:Categorization') local yesno = require('Dev:Yesno') local roblox_urls = require('Module:RobloxUrls') local links = require("Dev:Links") local currency = require('Module:Currency') local utils = require("Module:Utils") local infobox_utils = require('Module:InfoboxUtils') local enumerate_genres = require('Module:Genre')._enumerate_genres local staffData = require('Module:RobloxStaff')

local categorize = categorization.categorize_in_namespaces(0, 'Catalog', 'Community')

local p = {}

function p._format_title(args) if args.id == '' or args.id == nil then return infobox_utils.error_message(" parameter missing and is required") elseif args.id == "unknown" then return args.name .. categorize("Items with unknown identifier") elseif tonumber(args.id) then if tonumber(args.id) < 0 then return infobox_utils.error_message(" cannot be negative") else if yesno(args["bundle"]) then return links.link(tostring(roblox_urls.bundle_from_id(args.id)), args.name, "ext") else return links.link(tostring(roblox_urls.item_from_id(args.id)), args.name, "ext") end end else return infobox_utils.error_message(" must be a number") end end

p.format_title = utils.make_wrapper_function(p._format_title, true)

function p._format_13plus(args) if yesno(args['13plus']) then return "" .. categorize("Former 13+ items") end end

p.format_13plus = utils.make_wrapper_function(p._format_13plus)

function p._format_tickets(args) if tonumber(args.tickets) then return "Formerly " .. currency._format_tickets {amount = args.tickets} .. categorize("Items formerly available for tickets") else return infobox_utils.error_message(" must be a number") end end

p.format_tickets = utils.make_wrapper_function(p._format_tickets)

function p._format_robux(args) if yesno(args.limitedu) or yesno(args.limited) then return "Formerly " .. currency._format_robux {amount = args.robux} elseif yesno(args.sale) or yesno(args.buyableforsale) then return "Sale price: " .. currency._format_robux {amount=args.robux} else -- User:Joritochip -- This is a little messy, I will attempt to clean it up later local toReturn = currency._format_robux {amount=args.robux} local premium_robux = args["premium robux"] or args.premiumRobux if premium_robux then local premiumPrice = currency._format_robux {amount=premium_robux} toReturn = toReturn .. "( " .. premiumPrice .. "with Roblox Premium) " .. categorize("Items with discounted Roblox Premium price") end return toReturn end end

p.format_robux = utils.make_wrapper_function(p._format_robux)

function p._format_free(args) if yesno(args.free) then return currency._format_free .. categorize("Free items") end end

p.format_free = utils.make_wrapper_function(p._format_free)

function p._format_creator(args) local creator = args.creator or args.owner if creator:lower ~= "roblox" then local data = staffData.getRole(creator) if not mw.title.getCurrentTitle:inNamespaces("Catalog") then return infobox_utils.player_link(creator) else return infobox_utils.player_link(creator) .. categorize((data[1] == "Admin" or data[1] == "Former_Admin") and "Unofficial items" or "UGC items") end end end

p.format_creator = utils.make_wrapper_function(p._format_creator)

function p._format_genres(args) if args.genres == 'none' then return '' else return enumerate_genres {genres = args.genres, ["category suffix"] = args["category suffix"] or "items"} end end

p.format_genres = utils.make_wrapper_function(p._format_genres)

function p._format_membership(args) local membership = args.membership and args.membership:lower if membership then if membership == "obc" or membership == "outrageous builders club" or membership == "outrageous builder's club" then return "Outrageous Builders Club" .. categorize("Former Outrageous Builders Club items") elseif membership == "tbc" or membership == "turbo builders club" or membership == "turbo builder's club" then return "Turbo Builders Club" .. categorize("Former Turbo Builders Club items") elseif membership == "bc" or membership == "builders club" or membership == "builder's club" then return "Builders Club" .. categorize("Former Builders Club items") elseif membership == "premium" or membership == "p" or membership == "Roblox Premium" then return "Roblox Premium" .. categorize("Roblox Premium items") else return infobox_utils.error_message(" must be 'bc', 'tbc', 'obc', or 'premium'") end end end

p.format_membership = utils.make_wrapper_function(p._format_membership)

function p._categorize_by_limited_status(args) if yesno(args.limitedu) then return categorize("Limited unique items") elseif yesno(args.limited) then return categorize("Limited items") end end

p.categorize_by_limited_status = utils.make_wrapper_function(p._categorize_by_limited_status)

return p