diff options
author | 2020-04-13 08:22:30 +0300 | |
---|---|---|
committer | 2020-04-13 08:22:30 +0300 | |
commit | 295001c8a00d0f8bc9b77457c97314ee0aa34745 (patch) | |
tree | 8671a4a2f7c37b6862adee83f5dcd30ba9d7e2b7 /bot/exts/evergreen/minesweeper.py | |
parent | (TicTacToe): Applied `Player.display()` and `AI.display()` to cog and `Game` ... (diff) | |
parent | Merge branch 'master' into tic-tac-toe (diff) |
Merge remote-tracking branch 'origin/tic-tac-toe' into tic-tac-toe
Diffstat (limited to 'bot/exts/evergreen/minesweeper.py')
-rw-r--r-- | bot/exts/evergreen/minesweeper.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/bot/exts/evergreen/minesweeper.py b/bot/exts/evergreen/minesweeper.py index b59cdb14..ae057b30 100644 --- a/bot/exts/evergreen/minesweeper.py +++ b/bot/exts/evergreen/minesweeper.py @@ -7,6 +7,7 @@ import discord from discord.ext import commands from bot.constants import Client +from bot.utils.exceptions import UserNotPlayingError MESSAGE_MAPPING = { 0: ":stop_button:", @@ -176,6 +177,8 @@ class Minesweeper(commands.Cog): @minesweeper_group.command(name="flag") async def flag_command(self, ctx: commands.Context, *coordinates: CoordinateConverter) -> None: """Place multiple flags on the board.""" + if ctx.author.id not in self.games: + raise UserNotPlayingError board: GameBoard = self.games[ctx.author.id].revealed for x, y in coordinates: if board[y][x] == "hidden": @@ -253,6 +256,8 @@ class Minesweeper(commands.Cog): @minesweeper_group.command(name="reveal") async def reveal_command(self, ctx: commands.Context, *coordinates: CoordinateConverter) -> None: """Reveal multiple cells.""" + if ctx.author.id not in self.games: + raise UserNotPlayingError game = self.games[ctx.author.id] revealed: GameBoard = game.revealed board: GameBoard = game.board @@ -269,6 +274,8 @@ class Minesweeper(commands.Cog): @minesweeper_group.command(name="end") async def end_command(self, ctx: commands.Context) -> None: """End your current game.""" + if ctx.author.id not in self.games: + raise UserNotPlayingError game = self.games[ctx.author.id] game.revealed = game.board await self.update_boards(ctx) |