Corrected a couple errors in chess
This commit is contained in:
parent
7ea93f871b
commit
733c2ac009
1 changed files with 5 additions and 3 deletions
|
@ -6,6 +6,7 @@ from .utils import config
|
||||||
import random
|
import random
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
class Chess:
|
class Chess:
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
@ -83,13 +84,12 @@ class Chess:
|
||||||
else:
|
else:
|
||||||
promotion = None
|
promotion = None
|
||||||
if game.move(piece, position.upper(), position):
|
if game.move(piece, position.upper(), position):
|
||||||
return MoveStatus.valid:
|
return MoveStatus.valid
|
||||||
else:
|
else:
|
||||||
return MoveStatus.invalid
|
return MoveStatus.invalid
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return MoveStatus.invalid
|
return MoveStatus.invalid
|
||||||
|
|
||||||
|
|
||||||
def get_game(self, player):
|
def get_game(self, player):
|
||||||
"""Provides the game this player is playing, in this server"""
|
"""Provides the game this player is playing, in this server"""
|
||||||
server_games = self.games.get(player.server.id, [])
|
server_games = self.games.get(player.server.id, [])
|
||||||
|
@ -109,7 +109,7 @@ class Chess:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def start_game(self, player1, player2):
|
def start_game(self, player1, player2):
|
||||||
game = Game(player1, player2):
|
game = Game(player1, player2)
|
||||||
try:
|
try:
|
||||||
self.games[player1.server.id].append(game)
|
self.games[player1.server.id].append(game)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -174,6 +174,8 @@ class Chess:
|
||||||
|
|
||||||
# Start the game
|
# Start the game
|
||||||
game = self.start_game(ctx.message.author, player2)
|
game = self.start_game(ctx.message.author, player2)
|
||||||
|
player1 = game.challengers.get('white')
|
||||||
|
await self.bot.say("{} you have started a chess game with {}\n\n{} will be white this game, and is going first.\nIf you need information about the notation used to play, run {}help chess".format(ctx.message.author.display_name, player2.display_name, ctx.prefix))
|
||||||
|
|
||||||
class MoveStatus(Enum):
|
class MoveStatus(Enum):
|
||||||
invalid = 0
|
invalid = 0
|
||||||
|
|
Loading…
Reference in a new issue