aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
Diffstat (limited to 'bot')
-rw-r--r--bot/constants.py1
-rw-r--r--bot/resources/halloween/monster.json41
-rw-r--r--bot/seasons/halloween/monsterbio.py56
3 files changed, 98 insertions, 0 deletions
diff --git a/bot/constants.py b/bot/constants.py
index 732431ce..bea595d6 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -74,6 +74,7 @@ class Colours:
soft_green = 0x68c290
soft_red = 0xcd6d6d
yellow = 0xf9f586
+ purple = 0xb734eb
class Emojis:
diff --git a/bot/resources/halloween/monster.json b/bot/resources/halloween/monster.json
new file mode 100644
index 00000000..5958dc9c
--- /dev/null
+++ b/bot/resources/halloween/monster.json
@@ -0,0 +1,41 @@
+{
+ "monster_type": [
+ ["El", "Go", "Ma", "Nya", "Wo", "Hom", "Shar", "Gronn", "Grom", "Blar"],
+ ["gaf", "mot", "phi", "zyme", "qur", "tile", "pim"],
+ ["yam", "ja", "rok", "pym", "el"],
+ ["ya", "tor", "tir", "tyre", "pam"]
+ ],
+ "scientist_first_name": ["Ellis", "Elliot", "Rick", "Laurent", "Morgan", "Sophia", "Oak"],
+ "scientist_last_name": ["E. M.", "E. T.", "Smith", "Schimm", "Schiftner", "Smile", "Tomson", "Thompson", "Huffson", "Argor", "Lephtain", "S. M.", "A. R.", "P. G."],
+ "verb": [
+ "discovered", "created", "found"
+ ],
+ "adjective": [
+ "ferocious", "spectacular", "incredible", "terrifying"
+ ],
+ "physical_adjective": [
+ "springy", "rubbery", "bouncy", "tough", "notched", "chipped"
+ ],
+ "color": [
+ "blue", "green", "teal", "black", "pure white", "obsidian black", "purple", "bright red", "bright yellow"
+ ],
+ "attribute": [
+ "horns", "teeth", "shell", "fur", "bones", "exoskeleton", "spikes"
+ ],
+ "ability": [
+ "breathe fire", "devour dreams", "lift thousand-pound weights", "devour metal", "chew up diamonds", "create diamonds", "create gemstones", "breathe icy cold air", "spit poison", "live forever"
+ ],
+ "ingredients": [
+ "witch's eye", "frog legs", "slime", "true love's kiss", "a lock of golden hair", "the skin of a snake", "a never-melting chunk of ice"
+ ],
+ "time": [
+ "dusk", "dawn", "mid-day", "midnight on a full moon", "midnight on Halloween night", "the time of a solar eclipse", "the time of a lunar eclipse."
+ ],
+ "year": [
+ "1996", "1594", "1330", "1700"
+ ],
+ "biography_text": [
+ {"scientist_first_name": 1, "scientist_last_name": 1, "verb": 1, "adjective": 1, "attribute": 1, "ability": 1, "color": 1, "year": 1, "time": 1, "physical_adjective": 1, "text": "Your name is {monster_name}, a member of the {adjective} species {monster_species}. The first {monster_species} was {verb} by {scientist_first_name} {scientist_last_name} in {year} at {time}. The species {monster_species} is known for its {physical_adjective} {color} {attribute}. It is said to even be able to {ability}!"},
+ {"scientist_first_name": 1, "scientist_last_name": 1, "adjective": 1, "attribute": 1, "physical_adjective": 1, "ingredients": 2, "time": 1, "ability": 1, "verb": 1, "color": 1, "year": 1, "text": "The {monster_species} is an {adjective} species, and you, {monster_name}, are no exception. {monster_species} is famed for its {physical_adjective} {attribute}. Whispers say that when brewed with {ingredients[0]} and {ingredients[1]} at {time}, a foul, {color} brew will be produced, granting it's drinker the ability to {ability}! This species was {verb} by {scientist_first_name} {scientist_last_name} in {year}."}
+ ]
+}
diff --git a/bot/seasons/halloween/monsterbio.py b/bot/seasons/halloween/monsterbio.py
new file mode 100644
index 00000000..bfa8a026
--- /dev/null
+++ b/bot/seasons/halloween/monsterbio.py
@@ -0,0 +1,56 @@
+import json
+import logging
+import random
+from pathlib import Path
+
+import discord
+from discord.ext import commands
+
+from bot.constants import Colours
+
+log = logging.getLogger(__name__)
+
+with open(Path("bot/resources/halloween/monster.json"), "r", encoding="utf8") as f:
+ TEXT_OPTIONS = json.load(f) # Data for a mad-lib style generation of text
+
+
+class MonsterBio(commands.Cog):
+ """A cog that generates a spooky monster biography."""
+
+ def __init__(self, bot: commands.Bot):
+ self.bot = bot
+
+ def generate_name(self, seeded_random: random.Random) -> str:
+ """Generates a name (for either monster species or monster name)."""
+ n_candidate_strings = seeded_random.randint(2, len(TEXT_OPTIONS["monster_type"]))
+ return "".join(seeded_random.choice(TEXT_OPTIONS["monster_type"][i]) for i in range(n_candidate_strings))
+
+ @commands.command(brief="Sends your monster bio!")
+ async def monsterbio(self, ctx: commands.Context) -> None:
+ """Sends a description of a monster."""
+ seeded_random = random.Random(ctx.message.author.id) # Seed a local Random instance rather than the system one
+
+ name = self.generate_name(seeded_random)
+ species = self.generate_name(seeded_random)
+ biography_text = seeded_random.choice(TEXT_OPTIONS["biography_text"])
+ words = {"monster_name": name, "monster_species": species}
+ for key, value in biography_text.items():
+ if key == "text":
+ continue
+
+ options = seeded_random.sample(TEXT_OPTIONS[key], value)
+ words[key] = ' '.join(options)
+
+ embed = discord.Embed(
+ title=f"{name}'s Biography",
+ color=seeded_random.choice([Colours.orange, Colours.purple]),
+ description=biography_text["text"].format_map(words),
+ )
+
+ await ctx.send(embed=embed)
+
+
+def setup(bot: commands.Bot) -> None:
+ """Monster bio Cog load."""
+ bot.add_cog(MonsterBio(bot))
+ log.info("MonsterBio cog loaded.")