Fix loading save games (by telling the loaded player about the board they're on)...
authorSimon Cross <hodgestar@gmail.com>
Sat, 17 May 2014 18:16:45 +0000 (20:16 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sat, 17 May 2014 18:31:09 +0000 (20:31 +0200)
naja/gameboard.py
naja/player.py

index ff65c2517e4d63c1a77ce46c1a21ec25661ec50f..934aa3d15b1d308cb12d59d37e6e5d1645a0deae 100644 (file)
@@ -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 = {
index 892fa05b32f88c117a59f98d6025a7b0821a5469..58cb8245e6c5f0f3b466f25bf2d007dba2e544ef 100644 (file)
@@ -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 {