aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/minesweeper.py
diff options
context:
space:
mode:
authorGravatar Mark <[email protected]>2020-04-16 14:59:59 -0700
committerGravatar GitHub <[email protected]>2020-04-16 14:59:59 -0700
commit394d681630b6cfbccb404eb5110ac94b7c0e41d4 (patch)
treeadfeac6f64ed5ffc2f4e728d29bce4501199924c /bot/exts/evergreen/minesweeper.py
parentTransition towards `wait_until_guild_available` use (diff)
parentMerge pull request #396 from ks129/keyerrors-fix (diff)
Merge branch 'master' into wait-until-guild-ready
Diffstat (limited to 'bot/exts/evergreen/minesweeper.py')
-rw-r--r--bot/exts/evergreen/minesweeper.py7
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)