Skip to content

Commit

Permalink
fix load_gamestate bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xXUnique31Xx committed Jul 2, 2024
1 parent 9fbde95 commit ebb1d59
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,33 +222,38 @@ def load_gamestate(self):
self.board.currently_playing = GameSave['currently_playing']
self.board.show_symbols = GameSave['show_symbols']
self.load_game = True
self.player_black = ComputerPlayer('Black', self.board, self.view, 'White', self)
self.player_white = HumanPlayer('White', self.view, self)


if 'Ai' in GameSave:
self.ai = True
self.player_black = ComputerPlayer('Black', self.board, self.view, 'White', self)
else:
self.ai = False
self.player_black = HumanPlayer('Black', self.view, self)

for i in range(64):
# If the piece is None, the position is empty
if GameSave['board_state'][str(i)]['piece'] == 'None': # Moved wird nicht übernommen
self.board.board_state[i] = None
else:
# If the piece is not None, create a new piece object
if GameSave['board_state'][str(i)]['piece'] == 'Rooks':
if GameSave['board_state'][str(i)]['piece'] == 'Rook':
self.board.board_state[i] = Rook(GameSave['board_state'][str(i)]['colour'],
i, self.board)
if GameSave['board_state'][str(i)]['piece'] == 'Knights':
if GameSave['board_state'][str(i)]['piece'] == 'Knight':
self.board.board_state[i] = Knight(GameSave['board_state'][str(i)]['colour'],
i, self.board)
if GameSave['board_state'][str(i)]['piece'] == 'Bishops':
if GameSave['board_state'][str(i)]['piece'] == 'Bishop':
self.board.board_state[i] = Bishop(GameSave['board_state'][str(i)]['colour'],
i, self.board)
if GameSave['board_state'][str(i)]['piece'] == 'Queens':
if GameSave['board_state'][str(i)]['piece'] == 'Queen':
self.board.board_state[i] = Queen(GameSave['board_state'][str(i)]['colour'],
i, self.board)
if GameSave['board_state'][str(i)]['piece'] == 'Kings':
if GameSave['board_state'][str(i)]['piece'] == 'King':
self.board.board_state[i] = King(GameSave['board_state'][str(i)]['colour'],
i, self.board)
if GameSave['board_state'][str(i)]['piece'] == 'Pawns':
if GameSave['board_state'][str(i)]['piece'] == 'Pawn':
self.board.board_state[i] = Pawn(GameSave['board_state'][str(i)]['colour'],
i, self.board)

Expand Down

0 comments on commit ebb1d59

Please sign in to comment.