From 504157042ced1fab2fe66a906129ca87fdf91297 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sat, 17 May 2014 20:16:45 +0200 Subject: [PATCH] Fix loading save games (by telling the loaded player about the board they're on) (@nitwit). --- naja/gameboard.py | 4 +++- naja/player.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/naja/gameboard.py b/naja/gameboard.py index ff65c25..934aa3d 100644 --- a/naja/gameboard.py +++ b/naja/gameboard.py @@ -86,7 +86,9 @@ class GameBoard(object): player = Player.import_player(state.pop('player')) board_locations = cls.import_board_locations( state.pop('board_locations')) - return cls(state, player, board_locations) + board = cls(state, player, board_locations) + player.set_gameboard(board) + return board def export(self): data = { diff --git a/naja/player.py b/naja/player.py index 892fa05..58cb824 100644 --- a/naja/player.py +++ b/naja/player.py @@ -70,11 +70,12 @@ class Player(object): self.gameboard = gameboard @classmethod - def import_player(cls, definition): + def import_player(cls, definition, gameboard=None): return cls( definition['bits'], tuple(definition['position']), - definition['movement_mode']) + definition['movement_mode'], + gameboard=gameboard) def export(self): return { -- 2.34.1