diff options
author | 2020-11-19 18:45:43 -0800 | |
---|---|---|
committer | 2020-11-19 18:45:43 -0800 | |
commit | 935ed4da80441ceaa4ad9ca80130abc3e27ee2ad (patch) | |
tree | e7e2e07694424417917da7ef95d9f90ae1c8c1a4 | |
parent | Update workflow status badges in readme (diff) |
feature/add wonder twins command
This commit implements a wonder twins inspired command. This is a purely fun command that uses real transformations from the show to make random new transformations. The yaml is all hand transcribed from the actual show.
-rw-r--r-- | bot/exts/evergreen/wonder_twins.py | 49 | ||||
-rw-r--r-- | bot/resources/evergreen/wonder_twins.yaml | 99 |
2 files changed, 148 insertions, 0 deletions
diff --git a/bot/exts/evergreen/wonder_twins.py b/bot/exts/evergreen/wonder_twins.py new file mode 100644 index 00000000..475ddcb7 --- /dev/null +++ b/bot/exts/evergreen/wonder_twins.py @@ -0,0 +1,49 @@ +import random +from pathlib import Path + +import yaml +from discord.ext.commands import Bot, Cog, Context, command + +with open(Path.cwd() / "bot" / "resources" / "evergreen" / "wonder_twins.yaml", "r", encoding="utf-8") as f: + info = yaml.load(f, Loader=yaml.FullLoader) + WATER_TYPES, OBJECTS, ADJECTIVES = info["water_types"], info["objects"], info["adjectives"] + + +class WonderTwins(Cog): + """Cog for a Wonder Twins inspired command.""" + + def __init__(self, bot: Bot): + self.bot = bot + + @staticmethod + def append_onto(phrase: str, insert_word: str) -> str: + """Appends one word onto the end of another phrase, used to format the use of 'an' or 'a'.""" + if insert_word[-1] == "s": + phrase = phrase.split() + del phrase[0] + phrase = " ".join(phrase) + + insert_word = insert_word.split()[-1] + return " ".join([phrase, insert_word]) + + def format_phrase(self) -> str: + """Creates a transformation phrase from available words.""" + adjective = random.choice((None, random.choice(ADJECTIVES))) + object_name = random.choice(OBJECTS) + water_type = random.choice(WATER_TYPES) + + words = [object_name, water_type] + if adjective: + new_object = self.append_onto(adjective, object_name) + words[0] = new_object + return f"{words[0]} of {words[1]}" + + @command(name="formof", aliases=["wondertwins", "wondertwin", "fo"]) + async def form_of(self, ctx: Context) -> None: + """Command to send a Wonder Twins inspired phrase to the user invoking the command.""" + await ctx.send(f"Form of {self.format_phrase()}") + + +def setup(bot: Bot) -> None: + """Load the WonderTwins cog.""" + bot.add_cog(WonderTwins(bot)) diff --git a/bot/resources/evergreen/wonder_twins.yaml b/bot/resources/evergreen/wonder_twins.yaml new file mode 100644 index 00000000..05e8d749 --- /dev/null +++ b/bot/resources/evergreen/wonder_twins.yaml @@ -0,0 +1,99 @@ +water_types: + - ice + - water + - steam + - snow + +objects: + - a bucket + - a spear + - a wall + - a lake + - a ladder + - a boat + - a vial + - a ski slope + - a hand + - a ramp + - clippers + - a bridge + - a dam + - a glacier + - a crowbar + - stilts + - a pole + - a hook + - a wave + - a cage + - a basket + - bolt cutters + - a trapeze + - a puddle + - a toboggan + - a gale + - a cloud + - a unicycle + - a spout + - a sheet + - a gelatin dessert + - a saw + - a geyser + - a jet + - a ball + - handcuffs + - a door + - a row + - a gondola + - a sled + - a rocket + - a swing + - a blizzard + - a saddle + - cubes + - a horse + - a knight + - a rocket pack + - a slick + - a drill + - a shield + - a crane + - a reflector + - a bowling ball + - a turret + - a catapault + - a blanket + - balls + - a faucet + - shears + - a thunder cloud + - a net + - a yoyo + - a block + - a straight-jacket + - a slingshot + - a jack + - a car + - a club + - a vault + - a storm + - a wrench + - an anchor + - a beast + +adjectives: + - a large + - a giant + - a massive + - a small + - a tiny + - a super cool + - a frozen + - a minuscule + - a minute + - a microscopic + - a very small + - a little + - a huge + - an enourmous + - a gigantic + - a great |