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.json2
-rw-r--r--bot/seasons/halloween/monster.py31
3 files changed, 13 insertions, 21 deletions
diff --git a/bot/constants.py b/bot/constants.py
index 0d4321c8..749af1d0 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -72,6 +72,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
index f68ae840..5958dc9c 100644
--- a/bot/resources/halloween/monster.json
+++ b/bot/resources/halloween/monster.json
@@ -34,7 +34,7 @@
"year": [
"1996", "1594", "1330", "1700"
],
- "format": [
+ "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/monster.py b/bot/seasons/halloween/monster.py
index a068d02c..a54c7088 100644
--- a/bot/seasons/halloween/monster.py
+++ b/bot/seasons/halloween/monster.py
@@ -5,46 +5,37 @@ from pathlib import Path
import discord
from discord.ext import commands
+from constants import Colour
log = logging.getLogger(__name__)
with open(Path("bot/resources/halloween/monster.json"), "r", encoding="utf8") as f:
- data = json.load(f)
-
-PUMPKIN_ORANGE = discord.Color(0xFF7518)
-OTHER_PURPLE = discord.Color(0xB734EB)
-
+ 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
- self.channel = None
+ def generate_name(length):
+ return "".join([random.choice(TEXT_OPTIONS["monster_type"][i]) for i in range(length)])
@commands.command(brief="Sends your monster bio!")
async def monsterbio(self, ctx: commands.Context) -> None:
"""Sends a description of a monster."""
random.seed(ctx.message.author.id)
- name_length = random.randint(2, len(data["monster_type"]))
- species_length = random.randint(2, len(data["monster_type"]))
- name = species = ""
- for i in range(name_length):
- name += random.choice(data["monster_type"][i])
- for i in range(species_length):
- species += random.choice(data["monster_type"][i])
- format = random.choice(data["format"])
+ name = self.generate_name(random.randint(2, len(TEXT_OPTIONS["monster_type"])))
+ species = selfgenerate_name(random.randint(2, len(TEXT_OPTIONS["monster_type"])))
+ biography_text = random.choice(TEXT_OPTIONS["biography_text"])
words = {"monster_name": name, "monster_species": species}
- for key, value in format.items():
+ for key, value in biography_text.items():
if key == "text":
continue
if value > 1:
- words[key] = random.sample(data[key], value)
+ words[key] = random.sample(TEXT_OPTIONS[key], value)
else:
- words[key] = random.choice(data[key])
+ words[key] = random.choice(TEXT_OPTIONS[key])
embed = discord.Embed(
title=f"{name}'s Biography",
- color=random.choice([PUMPKIN_ORANGE, OTHER_PURPLE]), description=format["text"].format(**words)
+ color=random.choice([Colours.orange, Colours.purple]), description=biography_text["text"].format(**words)
)
await ctx.send(embed=embed)