aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/evergreen/tic_tac_toe.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/bot/exts/evergreen/tic_tac_toe.py b/bot/exts/evergreen/tic_tac_toe.py
index 72eb2090..435c7af3 100644
--- a/bot/exts/evergreen/tic_tac_toe.py
+++ b/bot/exts/evergreen/tic_tac_toe.py
@@ -44,6 +44,10 @@ class Player:
else:
return False, list(Emojis.number_emojis.keys())[list(Emojis.number_emojis.values()).index(react.emoji)]
+ async def display(self) -> str:
+ """Return mention of user."""
+ return self.user.mention
+
class AI:
"""Tic Tac Toe AI class for against computer gaming."""
@@ -90,6 +94,10 @@ class AI:
open_edges = [i for i in possible_moves if i in (2, 4, 6, 8)]
return False, random.choice(open_edges)
+ def display(self) -> str:
+ """Return `AI` as user name."""
+ return "AI"
+
class Game:
"""Class that contains information and functions about Tic Tac Toe game."""
@@ -229,8 +237,7 @@ class Game:
self.winner = self.current
self.loser = self.next
await self.ctx.send(
- f":tada: {self.current.user.mention if isinstance(self.current, Player) else 'AI'} "
- f"is won this game! :tada:"
+ f":tada: {self.current.display()} is won this game! :tada:"
)
await board.clear_reactions()
break
@@ -309,13 +316,11 @@ class TicTacToe(Cog):
if game.over and not game.canceled:
if game.draw:
log_games.append(
- f"**#{i+1}**: {game.players[0].user.mention} vs "
- f"{game.players[1].user.mention if isinstance(game.players[1], Player) else 'AI'} (draw)"
+ f"**#{i+1}**: {game.players[0].display()} vs {game.players[1].display()} (draw)"
)
else:
log_games.append(
- f"**#{i+1}**: {game.winner.user.mention if isinstance(game.winner, Player) else 'AI'} :trophy: "
- f"vs {game.loser.user.mention if isinstance(game.loser, Player) else 'AI'}"
+ f"**#{i+1}**: {game.winner.display()} :trophy: vs {game.loser.display()}"
)
await LinePaginator.paginate(
log_games,
@@ -331,8 +336,7 @@ class TicTacToe(Cog):
return
game = self.games[game_id - 1]
await ctx.send(
- f"{game.winner.user if isinstance(game.winner, Player) else 'AI'} "
- f":trophy: vs {game.loser.user if isinstance(game.winner, Player) else 'AI'}"
+ f"{game.winner.display()} :trophy: vs {game.loser.display()}"
)
await game.send_board(ctx.channel)