Fix code style issues with Black
This commit is contained in:
@@ -5,13 +5,13 @@ import discord
|
||||
# Defines a custom button that contains the logic of the game.
|
||||
# The ['TicTacToe'] bit is for type hinting purposes to tell your IDE or linter
|
||||
# what the type of `self.view` is. It is not required.
|
||||
class TicTacToeButton(discord.ui.Button['TicTacToe']):
|
||||
class TicTacToeButton(discord.ui.Button["TicTacToe"]):
|
||||
def __init__(self, x: int, y: int):
|
||||
# A label is required, but we don't need one so a zero-width space is used
|
||||
# The row parameter tells the View which row to place the button under.
|
||||
# A View can only contain up to 5 rows -- each row can only have 5 buttons.
|
||||
# Since a Tic Tac Toe grid is 3x3 that means we have 3 rows and 3 columns.
|
||||
super().__init__(style=discord.ButtonStyle.secondary, label='\u200b', row=y)
|
||||
super().__init__(style=discord.ButtonStyle.secondary, label="\u200b", row=y)
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
@@ -26,14 +26,14 @@ class TicTacToeButton(discord.ui.Button['TicTacToe']):
|
||||
|
||||
if view.current_player == view.X:
|
||||
self.style = discord.ButtonStyle.danger
|
||||
self.label = 'X'
|
||||
self.label = "X"
|
||||
self.disabled = True
|
||||
view.board[self.y][self.x] = view.X
|
||||
view.current_player = view.O
|
||||
content = "It is now O's turn"
|
||||
else:
|
||||
self.style = discord.ButtonStyle.success
|
||||
self.label = 'O'
|
||||
self.label = "O"
|
||||
self.disabled = True
|
||||
view.board[self.y][self.x] = view.O
|
||||
view.current_player = view.X
|
||||
@@ -42,9 +42,9 @@ class TicTacToeButton(discord.ui.Button['TicTacToe']):
|
||||
winner = view.check_board_winner()
|
||||
if winner is not None:
|
||||
if winner == view.X:
|
||||
content = 'X won!'
|
||||
content = "X won!"
|
||||
elif winner == view.O:
|
||||
content = 'O won!'
|
||||
content = "O won!"
|
||||
else:
|
||||
content = "It's a tie!"
|
||||
|
||||
@@ -121,13 +121,12 @@ class TicTacToe(discord.ui.View):
|
||||
class TicTacToeBot(commands.Bot):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
command_prefix=commands.when_mentioned_or('$'),
|
||||
intents=discord.Intents(guilds=True, messages=True)
|
||||
command_prefix=commands.when_mentioned_or("$"), intents=discord.Intents(guilds=True, messages=True)
|
||||
)
|
||||
|
||||
async def on_ready(self):
|
||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||
print('------')
|
||||
print(f"Logged in as {self.user} (ID: {self.user.id})")
|
||||
print("------")
|
||||
|
||||
|
||||
bot = TicTacToeBot()
|
||||
@@ -136,7 +135,7 @@ bot = TicTacToeBot()
|
||||
@bot.command()
|
||||
async def tic(ctx: commands.Context):
|
||||
"""Starts a tic-tac-toe game with yourself."""
|
||||
await ctx.send('Tic Tac Toe: X goes first', view=TicTacToe())
|
||||
await ctx.send("Tic Tac Toe: X goes first", view=TicTacToe())
|
||||
|
||||
|
||||
bot.run('token')
|
||||
bot.run("token")
|
||||
|
Reference in New Issue
Block a user