aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/minesweeper.py
diff options
context:
space:
mode:
authorGravatar ToxicKidz <[email protected]>2021-05-05 13:46:08 -0400
committerGravatar ToxicKidz <[email protected]>2021-05-05 13:46:08 -0400
commit888f83170bce384315a0a5c47b87b7ffbfb5d8ea (patch)
treeb5b05078abe529ecaa3e9c644b3cf445490fef03 /bot/exts/evergreen/minesweeper.py
parentchore: Don't have defaults for typing.Optional[...] in commands (diff)
chore: Add all of the converters into bot/utils/converters.py
Diffstat (limited to 'bot/exts/evergreen/minesweeper.py')
-rw-r--r--bot/exts/evergreen/minesweeper.py28
1 files changed, 1 insertions, 27 deletions
diff --git a/bot/exts/evergreen/minesweeper.py b/bot/exts/evergreen/minesweeper.py
index bd28d365..7a31dfde 100644
--- a/bot/exts/evergreen/minesweeper.py
+++ b/bot/exts/evergreen/minesweeper.py
@@ -8,6 +8,7 @@ from discord.ext import commands
from bot.bot import Bot
from bot.constants import Client
+from bot.utils.converters import CoordinateConverter
from bot.utils.exceptions import UserNotPlayingError
from bot.utils.extensions import invoke_help_command
@@ -32,33 +33,6 @@ MESSAGE_MAPPING = {
log = logging.getLogger(__name__)
-class CoordinateConverter(commands.Converter):
- """Converter for Coordinates."""
-
- async def convert(self, ctx: commands.Context, coordinate: str) -> typing.Tuple[int, int]:
- """Take in a coordinate string and turn it into an (x, y) tuple."""
- if not 2 <= len(coordinate) <= 3:
- raise commands.BadArgument("Invalid co-ordinate provided.")
-
- coordinate = coordinate.lower()
- if coordinate[0].isalpha():
- digit = coordinate[1:]
- letter = coordinate[0]
- else:
- digit = coordinate[:-1]
- letter = coordinate[-1]
-
- if not digit.isdigit():
- raise commands.BadArgument
-
- x = ord(letter) - ord("a")
- y = int(digit) - 1
-
- if (not 0 <= x <= 9) or (not 0 <= y <= 9):
- raise commands.BadArgument
- return x, y
-
-
GameBoard = typing.List[typing.List[typing.Union[str, int]]]