Module:ItemInfobox

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 i18n = require('Dev:I18n').loadMessages('Module:ItemInfobox/i18n')

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(i18n:msg("required-parameter-missing", "id")) elseif args.id == "unknown" then return args.name .. categorize(i18n:msg("cat-unknown-identifier-" .. args.kind)) elseif args.id == "none" then return args.name .. categorize(i18n:msg("cat-no-identifier-" .. args.kind)) elseif tonumber(args.id) then if tonumber(args.id) < 0 then return infobox_utils.error_message(i18n:msg("error-negative-parameter", "id")) else return links.link(tostring(roblox_urls.item_from_id(args.id)), args.name, "ext") end else return infobox_utils.error_message(i18n:msg("error-number-parameter", "id")) end end

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

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(i18n:msg("error-number-parameter", "tickets")) 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"] if premium_robux then local premiumPrice = currency._format_robux {amount=premium_robux} toReturn = toReturn .. "( " .. premiumPrice .. "with Roblox Premium) " .. categorize(i18n:msg("cat-discounted-premium-price-" .. args.kind)) 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(i18n:msg("cat-free-" .. args.kind)) end end

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

function p._format_creator(args) local creator = args.creator or args.owner local creator_type = args["creator type"] or "user" if creator_type == "user" then if creator:lower == "roblox" then if kind == "bundle" or kind == "emote" or kind == "face" or kind == "gear" or kind == "head" then -- These are always created by Roblox. return end return "Roblox" end local data = staffData.getRole(creator) local text = infobox_utils.player_link(creator) if args.kind ~= "pants" and args.kind ~= "shirt" and args.kind ~= "model" and mw.title.getCurrentTitle:inNamespace("Catalog") then text = text .. categorize(               (data[1] == "Admin" or data[1] == "Former_Admin")                and i18n:msg("cat-unofficial-" .. args.kind)               or i18n:msg("cat-community-" .. args.kind)           ) end return text elseif creator_type == "group" then return creator .. categorize(i18n:msg("cat-group-created-" .. args.kind)) else return error(i18n:msg("error-invalid-creator-type")) end end

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

function p._format_genres(args) local genres = args.genres if genres == 'none' then return '' else return enumerate_genres {genres = 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 and membership ~= "none" then if membership == "premium" or membership == "p" or membership == "Roblox Premium" then return "Roblox Premium" .. categorize(i18n:msg("cat-premium-" .. args.kind)) else return infobox_utils.error_message(i18n:msg("error-invalid-membership")) 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(i18n:msg("cat-limited-unique-" .. args.kind)) elseif yesno(args.limited) then return categorize(i18n:msg("cat-limited-" .. args.kind)) end end

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

return p