Module:ExperienceInfobox

--- Functions for Infobox experience -- local categorization = require("Module:Categorization") local yesno = require('Dev:Yesno') local utils = require("Module:Utils") local gear = require("Module:Gear attribute") local format_genre = require("Module:Genre")._format_genre local infobox_utils = require('Module:InfoboxUtils') local utils = require('Module:Utils') local currency = require('Module:Currency') local item_infobox = require('Module:ItemInfobox')

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

local p = {}

function p._format_allowed_gear(args) local allowed_gear = args["allowed gear"] or args["gear types"] allowed_gear = allowed_gear:lower if allowed_gear == "no gear allowed" or allowed_gear == "none" then return "None" end return gear.enumerate_gear_attributes {gear_attributes = allowed_gear, categorize = false} end

p.format_allowed_gear = utils.make_wrapper_function(p._format_allowed_gear)

function p._format_genre(args) return format_genre { genre = args.genre, ["category suffix"] = "experiences" } end

p.format_genre = utils.make_wrapper_function(p._format_genre)

function p._format_price(args) local price = utils.parse_number(args.price or args.cost) if price then return price ~= 0 and currency._format_robux {amount = price} or error("Refrain from providing a price if the experience is free to play.") end end

p.format_price = utils.make_wrapper_function(p._format_price)

function p._format_creator(args) local creator = args.creator or args.owner if args["creator type"] == "group" or yesno(args["owned by group"]) or yesno(args["group game"]) or yesno(args["group place"]) then return creator .. categorize("Group-created experiences") else return infobox_utils.player_link(creator) .. categorize("Player-created experiences") end end

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

function p._format_month_created(args) local month_created = args['month created'] if not month_created then return end local month, year = args['month created']:match("^(%a+) (%d%d%d%d)$") if month and year then return year > "2005" and month .. ' ' .. year .. categorize(year .. " experiences") or error("Roblox experience creation has only existed since 2006.") else return infobox_utils.error_message('Invalid value for : try something like "October 2015".') end end p.format_month_created = utils.make_wrapper_function(p._format_month_created)

function p._format_visits(args) local visits = args.visits return infobox_utils.format_number(visits, 10000, "Experiences with less than 1000000 visits", 1000000, "SUSPECTED_NCU") end

p.format_visits = utils.make_wrapper_function(p._format_visits)

function p._format_uncopylocked(args) if yesno(args.uncopylocked) then return "Uncopylocked" .. categorize("Uncopylocked experiences") end end

p.format_uncopylocked = utils.make_wrapper_function(p._format_uncopylocked)

local media_list = { {"twitter","External Twitter.png","https://twitter.com/%s"}, {"youtube","External YouTube.png","https://www.youtube.com/%s"}, {"twitch","External Twitch.png","https://www.twitch.tv/%s"}, {"discord","External Discord.png","https://discord.gg/%s"}, {"trello","External Trello.png","https://trello.com/b/%s/"}, {"facebook","External Facebook.png","https://www.facebook.com/%s/"}, {"guilded","External Guilded.png","https://www.guilded.gg/%s/"}, }

function p._format_media(args) local retString = "" for i,v in pairs(media_list) do       if args[v[1]] then retString = retString .. " "       end end if retString ~= "" then retString = retString .. categorize("Pages with social links") end return retString end

p.format_media = utils.make_wrapper_function(p._format_media,true)

return p