Skip to content

Commit

Permalink
Merge pull request #7 from younishd/feature/board_orientation
Browse files Browse the repository at this point in the history
Display correct POV (i.e. board orientation)
  • Loading branch information
Cqsi committed May 24, 2020
2 parents 2654bb6 + 22b2a5e commit 987bd78
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions lichs/Game.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run(self):
self.handle_chat_line(event)

def handle_state_change(self, game_state):

# big spaghetti code alert, if anyone comes up with a better way to this method please submit your code

global chess_board
Expand All @@ -41,13 +41,13 @@ def handle_state_change(self, game_state):
os._exit(0)

else:
if (len(game_state["moves"].split())-1)%2==self.isWhite:
if (len(game_state["moves"].split())-1)%2==self.isWhite:

print(self.color + " moved.")
print()

chess_board.push_uci(game_state["moves"].split()[-1])
print(chess_board)
self.display_board()
print()

self.check_mate(chess_board)
Expand All @@ -67,8 +67,8 @@ def handle_state_change(self, game_state):
print("You can't make that move. Try again!")
continue
break
print(chess_board)

self.display_board()
self.check_mate(chess_board)
print()
print(self.color + "'s turn...")
Expand All @@ -77,12 +77,12 @@ def handle_state_change(self, game_state):
def handle_draw_state(self, game_state):
# TODO Write this method
pass

def white_first_move(self):

global chess_board

print(chess_board)
self.display_board()
while(True):
try:
move = input("Make your move: ")
Expand All @@ -96,8 +96,8 @@ def white_first_move(self):
print("You can't make that move. Try again!")
continue
break
print(chess_board)

self.display_board()
print()
print(self.color + "'s turn...")

Expand All @@ -117,4 +117,12 @@ def check_mate(self, chess_board):
print("The game ended in a stalemate (draw)!")

print("Thanks for playing!")
os._exit(0)
os._exit(0)

def display_board(self):
global chess_board

if self.isWhite:
print(chess_board)
else:
print(chess_board.transform(chess.flip_vertical).transform(chess.flip_horizontal))

0 comments on commit 987bd78

Please sign in to comment.