Skip to content

Commit

Permalink
add piece_to_dict again
Browse files Browse the repository at this point in the history
  • Loading branch information
xXUnique31Xx committed Jul 1, 2024
1 parent ffe2c5d commit d664363
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ def save_gamestate(self):
except IOError as e:
GameView.display_message(f"Failed to save game: {e}")

def piece_to_dict(self, piece):

if piece is None:
return {'piece': None, 'symbol': None, 'colour': None, 'moved': None, 'position': None}
return {
'piece': type(piece).__name__,
'colour': piece.colour,
'moved': piece.moved,
'position': piece.position
}

def load_gamestate(self):
"""Load a game state from a file."""
saved_games = self.list_saved_games()
Expand Down

0 comments on commit d664363

Please sign in to comment.