From 9702e1e77ada39d4cd8cf93227539dda7f6c43bd Mon Sep 17 00:00:00 2001 From: c0de Date: Fri, 9 Dec 2022 23:20:20 -0600 Subject: [PATCH] Add reset command / module --- game/help.py | 1 + game/manager.py | 3 ++- game/reset.py | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 game/reset.py diff --git a/game/help.py b/game/help.py index 3bc0f37..90cb28e 100644 --- a/game/help.py +++ b/game/help.py @@ -27,6 +27,7 @@ class HelpManager(BaseGameManager): + " You can also add a batter's guess with: " + "!resolve \n" + "!points - Shows a table of the most recent players, and their scores\n" + + "!reset - Removes all the guesses" + "!help - Shows this message" ) diff --git a/game/manager.py b/game/manager.py index 751d7c4..28210aa 100644 --- a/game/manager.py +++ b/game/manager.py @@ -14,11 +14,12 @@ from game.new_game import NewGameManager from game.end_game import EndGameManager from game.guess import GuessManager from game.points import PointsManager +from game.reset import ResetManager from game.help import HelpManager class GameManager( - NewGameManager, EndGameManager, GuessManager, PointsManager, HelpManager + NewGameManager, EndGameManager, GuessManager, PointsManager, ResetManager, HelpManager ): """ Represents what this bot is able to do on a channel (or DMs) diff --git a/game/reset.py b/game/reset.py new file mode 100644 index 0000000..5c59e67 --- /dev/null +++ b/game/reset.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# Copyright 2022 - c0de +# Licensed under the MIT License (https://opensource.org/licenses/MIT) + +# pylint: disable=missing-module-docstring,too-few-public-methods + +from database.models import GuessModel as Guess +from game.base import BaseGameManager + + +class ResetManager(BaseGameManager): + """Commands that run when a player asks for help""" + + def __init__(self): + super().__init__() + self.commands.append(("reset", self.reset)) + + async def reset(self): + """Reset command purges all guesses""" + Guess.delete().where(True).execute() + + return await self.message.channel.send("ok")