diff options
author | 2020-04-13 08:14:42 +0300 | |
---|---|---|
committer | 2020-04-13 08:14:42 +0300 | |
commit | ddec3a15ffa37b775bc483910baefb4e0aba2f88 (patch) | |
tree | f425736e4506eea7438326a6b56daba906cfceca /bot/exts/evergreen/tic_tac_toe.py | |
parent | (TicTacToe): Setting winning as priority in AI instead blocking opponent. (diff) |
(TicTacToe): Created new helper functions `display` to `Player` and `AI` class to avoid `if` checks in strings.
Diffstat (limited to 'bot/exts/evergreen/tic_tac_toe.py')
-rw-r--r-- | bot/exts/evergreen/tic_tac_toe.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bot/exts/evergreen/tic_tac_toe.py b/bot/exts/evergreen/tic_tac_toe.py index 72eb2090..8d0c384b 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.""" |