Module:Glolfer
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Glolfer/doc
local pyrandom = require "Module:Pyrandom"
function titlecase(str)
local buf = {}
local inWord = false
for i = 1, #str do
local c = string.sub(str, i, i)
if inWord then
table.insert(buf, string.lower(c))
else
table.insert(buf, string.upper(c))
end
inWord = (string.find(c, '%a') ~= nil)
end
return table.concat(buf)
end
function random_player_emoji(name)
local humanoid = {
"๐ถ","๐ง","๐ง","๐ฆ","๐ฉ","๐ง","๐จ","๐ฉโ๐ฆฑ","๐งโ๐ฆฑ","๐จโ๐ฆฑ","๐ฉโ๐ฆฐ","๐งโ๐ฆฐ","๐จโ๐ฆฐ","๐ฑโโ๏ธ",
"๐ฑ","๐ฑโโ๏ธ","๐ฉโ๐ฆณ","๐งโ๐ฆณ","๐จโ๐ฆณ","๐ฉโ๐ฆฒ","๐งโ๐ฆฒ","๐จโ๐ฆฒ","๐ง","๐ต","๐ง","๐ด","๐ฒ","๐ณโโ๏ธ",
"๐ณ","๐ณโโ๏ธ","๐ง","๐ฎโโ๏ธ","๐ฎ","๐ฎโโ๏ธ","๐ทโโ๏ธ","๐ท","๐ทโโ๏ธ","๐โโ๏ธ","๐","๐โโ๏ธ","๐ต๏ธโโ๏ธ","๐ต๏ธ",
"๐ต๏ธโโ๏ธ","๐ฉโโ๏ธ","๐งโโ๏ธ","๐จโโ๏ธ","๐ฉโ๐พ","๐งโ๐พ","๐จโ๐พ","๐ฉโ๐ณ","๐งโ๐ณ","๐จโ๐ณ","๐ฉโ๐","๐งโ๐","๐จโ๐","๐ฉโ๐ค",
"๐งโ๐ค","๐จโ๐ค","๐ฉโ๐ซ","๐งโ๐ซ","๐จโ๐ซ","๐ฉโ๐ญ","๐งโ๐ญ","๐จโ๐ญ","๐ฉโ๐ป","๐งโ๐ป","๐จโ๐ป","๐ฉโ๐ผ","๐งโ๐ผ","๐จโ๐ผ",
"๐ฉโ๐ง","๐งโ๐ง","๐จโ๐ง","๐ฉโ๐ฌ","๐งโ๐ฌ","๐จโ๐ฌ","๐ฉโ๐จ","๐งโ๐จ","๐จโ๐จ","๐ฉโ๐","๐งโ๐","๐จโ๐","๐ฉโโ๏ธ","๐งโโ๏ธ",
"๐จโโ๏ธ","๐ฉโ๐","๐งโ๐","๐จโ๐","๐ฉโโ๏ธ","๐งโโ๏ธ","๐จโโ๏ธ","๐ฐ","๐๏ธ","๐คต","๐คธ","๐ธ","๐คด","๐ฆธโโ๏ธ","๐ฆธ",
"๐ฆธโโ๏ธ","๐ฆนโโ๏ธ","๐ฆน","๐ฆนโโ๏ธ","๐คถ","๐ด","๐
","๐งโโ๏ธ","๐ง","๐งโโ๏ธ","๐งโโ๏ธ","๐ง","๐งโโ๏ธ","๐งโโ๏ธ","๐ง",
"๐งโโ๏ธ","๐งโโ๏ธ","๐ง","๐งโโ๏ธ","๐งโโ๏ธ","๐ง","๐งโโ๏ธ","๐งโโ๏ธ","๐ง","๐งโโ๏ธ","๐งโโ๏ธ","๐ง","๐งโโ๏ธ","๐ผ","๐คฐ",
"๐คฑ","๐โโ๏ธ","๐","๐โโ๏ธ","๐โโ๏ธ","๐","๐โโ๏ธ","๐
โโ๏ธ","๐
","๐
โโ๏ธ","๐โโ๏ธ","๐","๐โโ๏ธ","๐โโ๏ธ","๐",
"๐โโ๏ธ","๐งโโ๏ธ","๐ง","๐งโโ๏ธ","๐คฆโโ๏ธ","๐คฆ","๐คฆโโ๏ธ","๐คทโโ๏ธ","๐คท","๐คทโโ๏ธ","๐โโ๏ธ","๐","๐โโ๏ธ","๐โโ๏ธ","๐",
"๐โโ๏ธ","๐โโ๏ธ","๐","๐โโ๏ธ","๐โโ๏ธ","๐","๐โโ๏ธ","๐งโโ๏ธ","๐ง","๐งโโ๏ธ","๐
","๐คณ","๐","๐บ","๐ด","๐ฉโ๐ฆฝ",
"๐งโ๐ฆฝ","๐จโ๐ฆฝ","๐ฉโ๐ฆผ","๐งโ๐ฆผ","๐จโ๐ฆผ","๐ถโโ๏ธ","๐ถ","๐ถโโ๏ธ","๐ฉโ๐ฆฏ","๐งโ๐ฆฏ","๐จโ๐ฆฏ","๐งโโ๏ธ","๐ง","๐งโโ๏ธ","๐โโ๏ธ","๐",
"๐โโ๏ธ","๐งโโ๏ธ","๐ง","๐งโโ๏ธ","๐ญ","๐งโ๐คโ๐ง","๐ฌ","๐ซ","๐ฉโโค๏ธโ๐ฉ","๐","๐จโโค๏ธโ๐จ","๐ฉโโค๏ธโ๐จ","๐ฉโโค๏ธโ๐โ๐ฉ","๐","๐จโโค๏ธโ๐โ๐จ","๐ฉโโค๏ธโ๐โ๐จ",
"๐ช","๐จโ๐ฉโ๐ฆ","๐จโ๐ฉโ๐ง","๐จโ๐ฉโ๐งโ๐ฆ","๐จโ๐ฉโ๐ฆโ๐ฆ","๐จโ๐ฉโ๐งโ๐ง","๐จโ๐จโ๐ฆ","๐จโ๐จโ๐ง","๐จโ๐จโ๐งโ๐ฆ","๐จโ๐จโ๐ฆโ๐ฆ","๐จโ๐จโ๐งโ๐ง","๐ฉโ๐ฉโ๐ฆ","๐ฉโ๐ฉโ๐ง","๐ฉโ๐ฉโ๐งโ๐ฆ","๐ฉโ๐ฉโ๐ฆโ๐ฆ","๐ฉโ๐ฉโ๐งโ๐ง",
"๐จโ๐ฆ","๐จโ๐ฆโ๐ฆ","๐จโ๐ง","๐จโ๐งโ๐ฆ","๐จโ๐งโ๐ง","๐ฉโ๐ฆ","๐ฉโ๐ฆโ๐ฆ","๐ฉโ๐ง","๐ฉโ๐งโ๐ฆ","๐ฉโ๐งโ๐ง","๐ฃ","๐ค","๐ฅ"
}
local nonhumanoid={
"๐ถ","๐ฑ","๐ญ","๐น","๐ฐ","๐ฆ","๐ป","๐ผ","๐จ","๐ฏ","๐ฆ","๐ฎ","๐ท","๐ฝ","๐ธ","๐ต",
"๐","๐","๐","๐","๐","๐ง","๐ฆ","๐ค","๐ฃ","๐ฅ","๐ฆ","๐ฆ
","๐ฆ","๐ฆ","๐บ","๐","๐ด","๐ฆ",
"๐","๐","๐ฆ","๐","๐","๐","๐ฆ","๐ฆ","๐ท๏ธ","๐ฆ","๐ข","๐","๐ฆ","๐ฆ","๐ฆ","๐","๐ฆ","๐ฆ",
"๐ฆ","๐ฆ","๐ก","๐ ","๐","๐ฌ","๐ณ","๐","๐ฆ","๐","๐
","๐","๐ฆ","๐ฆ","๐ฆง","๐","๐ฆ","๐ฆ",
"๐ช","๐ซ","๐ฆ","๐ฆ","๐","๐","๐","๐","๐","๐","๐","๐ฆ","๐","๐ฆ","๐","๐ฉ","๐ฆฎ","๐โ๐ฆบ",
"๐","๐","๐ฆ","๐ฆ","๐ฆ","๐ฆข","๐ฆฉ","๐๏ธ","๐","๐ฆ","๐ฆจ","๐ฆก","๐ฆฆ","๐ฆฅ","๐","๐","๐ฟ","๐ฆ",
"๐","๐ฒ","๐ช","๐ซ","๐ช","๐","๐ ","๐บ"
}
local rand = pyrandom.new(titlecase(name))
if rand:random() > 0.5 then
return rand:choice(humanoid)
else
return rand:choice(nonhumanoid)
end
end
function generate_random_stlats_from_name(name)
local rand = pyrandom.new(titlecase(name))
return {
nyoomability = math.max(rand:gauss(0,0.3),1.4),
tofu = rand:random(),
wiggle = rand:random(),
ritualism = rand:random(),
musclitude = rand:random(),
finesse = rand:random(),
needlethreadableness = rand:random(),
left_handedness = rand:gauss(0,0.3),
stance = rand:choice({"Tricky","Flashy","Aggro","Tanky","Twitchy","Powerful",
"Wibble","Wobble","Reverse","Feint","Electric","Spicy","Pomegranate",
"Explosive","Cottagecore","Corecore","Hardcore","Softcore",
"Hand to Hand","Lefty","Pop-Punk","DPS","Repose"}),
fav_tea = rand:choice({"Iced","Boba","White","Green","Oolong",
"Pu'erh","Chai","Milk","Neon","Sweet","Void","Tea?","Caramel",
"Lightspeed","Time-traveling","Bloody","Black","Miso","Concrete",
"Hard-boiled egg","Hot Chocolate","Bubble"}),
estimation = rand:random(),
earliness = rand:random(),
twirliness = rand:random(),
churliness = rand:random(),
aceness = rand:random(),
marbles = rand:randrange(2,4),
unworthiness = rand:random(),
splortsmanship = rand:random(),
tankitude = rand:random(),
pettiness = rand:random(),
owlishness = rand:random(),
disco = rand:random(),
pettability = rand:random(),
softness = rand:random(),
improv = rand:random(),
tentacles = rand:randrange(0,10),
capitalism = -rand:random(),
polkadottedness = 0,
}
end
function generate_random_player_from_name(name)
local player = generate_random_stlats_from_name(name)
player.name = name
player.emoji = random_player_emoji(name)
return player
end
function search_array(a, v)
for i = 1, #a do
if a[i] == v then
return true
end
end
return false
end
function sum(a)
local r = 0
for i = 1, #a do
r = r + a[i]
end
return r
end
function unpredictability(p)
local weights = {p.churliness,p.earliness,p.twirliness}
if search_array({"Aggro","Powerful","Hand to Hand","DPS","Explosive","Hardcore", "Wibble","Electric"}, p.stance) then
weights[1] = weights[1] + 0.5
elseif search_array({"Tanky","Twitchy","Repose","Reverse","Softcore", "Cottagecore","Pomegranate"}, p.stance) then
weights[2] = weights[2] + 0.5
elseif search_array("Feint","Tricky","Pop-Punk","Flashy","Spicy", "Corecore","Wobble","Lefty", p.stance) then
weights[3] = weights[3] + 0.5
end
local chanceOfBiggest = math.max(unpack(weights))/sum(weights)
local minChance = 1/#weights
return 1-(chanceOfBiggest-minChance)/(1-minChance)
end
function driving_rating(p)
return (p.musclitude + p.tofu)*5/2
end
function precision_rating(p)
return (p.needlethreadableness*0.5 + p.finesse + p.estimation*0.2) * 5/(1+0.2+0.5) - math.abs(p.left_handedness)
end
function aerodynamics_rating(p)
return (p.ritualism + p.owlishness + p.softness) * 5/3
end
function self_awareness_rating(p)
return (p.wiggle*0.5 + (p.marbles-2)/2 + unpredictability(p)*0.8) * 5/(0.5+1+0.8) + p.polkadottedness * 5
end
local known_players = {
["Polkadot Patterson"] = {
name="Polkadot Patterson",
stance="Squiddish",
fav_tea= "Iced",
nyoomability = 1.5,
musclitude=1,
finesse=1,
needlethreadableness=1,
polkadottedness=1,
left_handedness= 0,
estimation=1,
twirliness=0.3,
churliness=0.3,
earliness=0.3,
aceness=0.3,
marbles=4,
tofu=1,
wiggle=1,
ritualism=1,
owlishness=1,
disco=0.0,
pettability=0.0,
softness=1,
improv=0.0,
unworthiness=0,
splortsmanship=1,
tankitude=1.0,
pettiness=0.0,
tentacles=4,
capitalism=-0.5,
emoji="๐
",
},
}
function get_player_from_name(name)
name = titlecase(name)
return known_players[name] or generate_random_player_from_name(name)
end
local glolfer = {}
function glolfer.emoji(frame)
local args
if frame.args.name then
args = frame.args
else
args = frame:getParent().args
end
local name = args.name
return random_player_emoji(name)
end
function glolfer.infobox(frame)
local args
if frame.args.name then
args = frame.args
else
args = frame:getParent().args
end
local name = args.name
local p = get_player_from_name(name)
local template_args = {}
for k, v in pairs(args) do
template_args[k] = v
end
for k, v in pairs({
name = name,
signature = p.emoji,
stance = p.stance,
tea = p.fav_tea,
driving = driving_rating(p),
grip = precision_rating(p),
aerodynamics = aerodynamics_rating(p),
["self-awareness"] = self_awareness_rating(p),
}) do
template_args[k] = v
end
return frame:expandTemplate{ title = "GlolferInfo", args = template_args}
end
return glolfer