diff options
Diffstat (limited to 'bot/exts/evergreen/battleship.py')
| -rw-r--r-- | bot/exts/evergreen/battleship.py | 27 | 
1 files changed, 16 insertions, 11 deletions
| diff --git a/bot/exts/evergreen/battleship.py b/bot/exts/evergreen/battleship.py index 1681434f..27c50bdb 100644 --- a/bot/exts/evergreen/battleship.py +++ b/bot/exts/evergreen/battleship.py @@ -9,6 +9,7 @@ from functools import partial  import discord  from discord.ext import commands +from bot.bot import Bot  from bot.constants import Colours  log = logging.getLogger(__name__) @@ -95,7 +96,7 @@ class Game:      def __init__(          self, -        bot: commands.Bot, +        bot: Bot,          channel: discord.TextChannel,          player1: discord.Member,          player2: discord.Member @@ -237,7 +238,7 @@ class Game:          square = None          turn_message = await self.turn.user.send(              "It's your turn! Type the square you want to fire at. Format it like this: A1\n" -            "Type `surrender` to give up" +            "Type `surrender` to give up."          )          await self.next.user.send("Their turn", delete_after=3.0)          while True: @@ -321,7 +322,7 @@ class Game:  class Battleship(commands.Cog):      """Play the classic game Battleship!""" -    def __init__(self, bot: commands.Bot) -> None: +    def __init__(self, bot: Bot) -> None:          self.bot = bot          self.games: typing.List[Game] = []          self.waiting: typing.List[discord.Member] = [] @@ -378,10 +379,12 @@ class Battleship(commands.Cog):          Make sure you have your DMs open so that the bot can message you.          """          if self.already_playing(ctx.author): -            return await ctx.send("You're already playing a game!") +            await ctx.send("You're already playing a game!") +            return          if ctx.author in self.waiting: -            return await ctx.send("You've already sent out a request for a player 2") +            await ctx.send("You've already sent out a request for a player 2.") +            return          announcement = await ctx.send(              "**Battleship**: A new game is about to start!\n" @@ -401,12 +404,14 @@ class Battleship(commands.Cog):          except asyncio.TimeoutError:              self.waiting.remove(ctx.author)              await announcement.delete() -            return await ctx.send(f"{ctx.author.mention} Seems like there's no one here to play...") +            await ctx.send(f"{ctx.author.mention} Seems like there's no one here to play...") +            return          if str(reaction.emoji) == CROSS_EMOJI:              self.waiting.remove(ctx.author)              await announcement.delete() -            return await ctx.send(f"{ctx.author.mention} Game cancelled.") +            await ctx.send(f"{ctx.author.mention} Game cancelled.") +            return          await announcement.delete()          self.waiting.remove(ctx.author) @@ -425,11 +430,11 @@ class Battleship(commands.Cog):              self.games.remove(game)          except Exception:              # End the game in the event of an unforseen error so the players aren't stuck in a game -            await ctx.send(f"{ctx.author.mention} {user.mention} An error occurred. Game failed") +            await ctx.send(f"{ctx.author.mention} {user.mention} An error occurred. Game failed.")              self.games.remove(game)              raise -    @battleship.command(name="ships", aliases=["boats"]) +    @battleship.command(name="ships", aliases=("boats",))      async def battleship_ships(self, ctx: commands.Context) -> None:          """Lists the ships that are found on the battleship grid."""          embed = discord.Embed(colour=Colours.blue) @@ -438,6 +443,6 @@ class Battleship(commands.Cog):          await ctx.send(embed=embed) -def setup(bot: commands.Bot) -> None: -    """Cog load.""" +def setup(bot: Bot) -> None: +    """Load the Battleship Cog."""      bot.add_cog(Battleship(bot)) | 
