🐛 small change in order of operations

This commit is contained in:
NikolajDanger
2021-08-19 19:59:46 +02:00
parent b8a2f6022e
commit e0eab627fe
2 changed files with 16 additions and 23 deletions

View File

@ -167,14 +167,13 @@ class ConnectFour():
log_message = "They started a game"
self.bot.log(log_message)
await ctx.send(send_message)
# Sets the whole game in motion
if started_game:
boards_path = "gwendolyn/resources/games/connect_four_boards/"
file_path = f"{boards_path}board{ctx.channel_id}.png"
image_message = await ctx.send(
send_message, file=discord.File(file_path)
)
image_message = await ctx.send(file=discord.File(file_path))
board_string = self._encode_board_string(board)
if gwendolyn_turn:
@ -229,8 +228,6 @@ class ConnectFour():
await image_message.edit(
components=action_rows
)
else:
await ctx.send(send_message)
async def place_piece(self, ctx: ComponentContext, board_string: str,
column: int, players: list[int], difficulty: int,
@ -242,6 +239,8 @@ class ConnectFour():
column: int
The column the player is placing the piece in.
"""
old_message = await ctx.channel.fetch_message(message_id)
await old_message.delete()
player_number = players.index(placer)+1
user_name = self.get_name(f"#{placer}")
@ -286,6 +285,7 @@ class ConnectFour():
placed_piece = True
self.bot.log(log_message)
await ctx.channel.send(send_message)
if placed_piece:
channel = str(ctx.channel)
@ -295,8 +295,7 @@ class ConnectFour():
boards_path = "gwendolyn/resources/games/connect_four_boards/"
file_path = boards_path + f"board{channel}.png"
image_message = await ctx.channel.send(
send_message, file=discord.File(file_path))
image_message = await ctx.channel.send(file=discord.File(file_path))
if game_won:
self._end_game(winner, players, difficulty)
@ -355,11 +354,7 @@ class ConnectFour():
await image_message.edit(
components=action_rows
)
else:
await ctx.channel.send(send_message)
old_message = await ctx.channel.fetch_message(message_id)
await old_message.delete()
async def surrender(self, ctx: ComponentContext, players: list,
difficulty: int, message_id: int):