🔀 Small bug fix
🐛 small change in order of operations
This commit is contained in:
@ -167,14 +167,13 @@ class ConnectFour():
|
|||||||
log_message = "They started a game"
|
log_message = "They started a game"
|
||||||
|
|
||||||
self.bot.log(log_message)
|
self.bot.log(log_message)
|
||||||
|
await ctx.send(send_message)
|
||||||
|
|
||||||
# Sets the whole game in motion
|
# Sets the whole game in motion
|
||||||
if started_game:
|
if started_game:
|
||||||
boards_path = "gwendolyn/resources/games/connect_four_boards/"
|
boards_path = "gwendolyn/resources/games/connect_four_boards/"
|
||||||
file_path = f"{boards_path}board{ctx.channel_id}.png"
|
file_path = f"{boards_path}board{ctx.channel_id}.png"
|
||||||
image_message = await ctx.send(
|
image_message = await ctx.send(file=discord.File(file_path))
|
||||||
send_message, file=discord.File(file_path)
|
|
||||||
)
|
|
||||||
|
|
||||||
board_string = self._encode_board_string(board)
|
board_string = self._encode_board_string(board)
|
||||||
if gwendolyn_turn:
|
if gwendolyn_turn:
|
||||||
@ -229,8 +228,6 @@ class ConnectFour():
|
|||||||
await image_message.edit(
|
await image_message.edit(
|
||||||
components=action_rows
|
components=action_rows
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
await ctx.send(send_message)
|
|
||||||
|
|
||||||
async def place_piece(self, ctx: ComponentContext, board_string: str,
|
async def place_piece(self, ctx: ComponentContext, board_string: str,
|
||||||
column: int, players: list[int], difficulty: int,
|
column: int, players: list[int], difficulty: int,
|
||||||
@ -242,6 +239,8 @@ class ConnectFour():
|
|||||||
column: int
|
column: int
|
||||||
The column the player is placing the piece in.
|
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
|
player_number = players.index(placer)+1
|
||||||
user_name = self.get_name(f"#{placer}")
|
user_name = self.get_name(f"#{placer}")
|
||||||
@ -286,6 +285,7 @@ class ConnectFour():
|
|||||||
placed_piece = True
|
placed_piece = True
|
||||||
|
|
||||||
self.bot.log(log_message)
|
self.bot.log(log_message)
|
||||||
|
await ctx.channel.send(send_message)
|
||||||
|
|
||||||
if placed_piece:
|
if placed_piece:
|
||||||
channel = str(ctx.channel)
|
channel = str(ctx.channel)
|
||||||
@ -295,8 +295,7 @@ class ConnectFour():
|
|||||||
|
|
||||||
boards_path = "gwendolyn/resources/games/connect_four_boards/"
|
boards_path = "gwendolyn/resources/games/connect_four_boards/"
|
||||||
file_path = boards_path + f"board{channel}.png"
|
file_path = boards_path + f"board{channel}.png"
|
||||||
image_message = await ctx.channel.send(
|
image_message = await ctx.channel.send(file=discord.File(file_path))
|
||||||
send_message, file=discord.File(file_path))
|
|
||||||
|
|
||||||
if game_won:
|
if game_won:
|
||||||
self._end_game(winner, players, difficulty)
|
self._end_game(winner, players, difficulty)
|
||||||
@ -355,11 +354,7 @@ class ConnectFour():
|
|||||||
await image_message.edit(
|
await image_message.edit(
|
||||||
components=action_rows
|
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,
|
async def surrender(self, ctx: ComponentContext, players: list,
|
||||||
difficulty: int, message_id: int):
|
difficulty: int, message_id: int):
|
||||||
|
@ -92,11 +92,11 @@ class Hangman():
|
|||||||
send_message = f"{ctx.author.display_name} started a game of hangman."
|
send_message = f"{ctx.author.display_name} started a game of hangman."
|
||||||
|
|
||||||
self.bot.log("Game started")
|
self.bot.log("Game started")
|
||||||
|
await ctx.send(send_message)
|
||||||
|
|
||||||
boards_path = "gwendolyn/resources/games/hangman_boards/"
|
boards_path = "gwendolyn/resources/games/hangman_boards/"
|
||||||
file_path = f"{boards_path}hangman_board{game_id}.png"
|
file_path = f"{boards_path}hangman_board{game_id}.png"
|
||||||
image_message = await ctx.send(
|
image_message = await ctx.channel.send(
|
||||||
send_message,
|
|
||||||
file=discord.File(file_path)
|
file=discord.File(file_path)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -165,6 +165,10 @@ class Hangman():
|
|||||||
The context of the command.
|
The context of the command.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
for msg_id in messages:
|
||||||
|
msg = await ctx.channel.fetch_message(msg_id)
|
||||||
|
await msg.delete()
|
||||||
|
|
||||||
self.bot.log("Deleting old messages")
|
self.bot.log("Deleting old messages")
|
||||||
|
|
||||||
await ctx.channel.send("Hangman game stopped")
|
await ctx.channel.send("Hangman game stopped")
|
||||||
@ -172,10 +176,6 @@ class Hangman():
|
|||||||
file_path = f"{boards_path}hangman_board{game_id}.png"
|
file_path = f"{boards_path}hangman_board{game_id}.png"
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
|
|
||||||
for msg_id in messages:
|
|
||||||
msg = await ctx.channel.fetch_message(msg_id)
|
|
||||||
await msg.delete()
|
|
||||||
|
|
||||||
async def guess(self, ctx: ComponentContext, guess: str, word: str,
|
async def guess(self, ctx: ComponentContext, guess: str, word: str,
|
||||||
guessed_letters: str, game_id: str, *messages: list[str]):
|
guessed_letters: str, game_id: str, *messages: list[str]):
|
||||||
"""
|
"""
|
||||||
@ -190,6 +190,9 @@ class Hangman():
|
|||||||
guess: str
|
guess: str
|
||||||
The guess.
|
The guess.
|
||||||
"""
|
"""
|
||||||
|
for msg_id in messages:
|
||||||
|
msg = await ctx.channel.fetch_message(msg_id)
|
||||||
|
await msg.delete()
|
||||||
|
|
||||||
misses = 0
|
misses = 0
|
||||||
guessed_letters += guess
|
guessed_letters += guess
|
||||||
@ -228,10 +231,10 @@ class Hangman():
|
|||||||
|
|
||||||
|
|
||||||
if remaining_letters != []:
|
if remaining_letters != []:
|
||||||
|
await ctx.channel.send(send_message)
|
||||||
boards_path = "gwendolyn/resources/games/hangman_boards/"
|
boards_path = "gwendolyn/resources/games/hangman_boards/"
|
||||||
file_path = f"{boards_path}hangman_board{game_id}.png"
|
file_path = f"{boards_path}hangman_board{game_id}.png"
|
||||||
image_message = await ctx.channel.send(
|
image_message = await ctx.channel.send(
|
||||||
send_message,
|
|
||||||
file=discord.File(file_path)
|
file=discord.File(file_path)
|
||||||
)
|
)
|
||||||
blank_message_one = await ctx.channel.send("_ _")
|
blank_message_one = await ctx.channel.send("_ _")
|
||||||
@ -291,11 +294,6 @@ class Hangman():
|
|||||||
|
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
|
|
||||||
for msg_id in messages:
|
|
||||||
msg = await ctx.channel.fetch_message(msg_id)
|
|
||||||
await msg.delete()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user