diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2014-06-12 20:50:28 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2014-06-12 20:50:28 (GMT) |
commit | 4d02505175b7f9ffe70c62fa28a6a880383648ca (patch) | |
tree | 1b83a9669697b864f478cc7585f07408d32525f9 | |
parent | 2becc6a8464340afbbe6b0a2acd6309de913cafd (diff) |
If the maze was finished, show a differnt maze the next activiy start
-rwxr-xr-x | activity.py | 3 | ||||
-rw-r--r-- | game.py | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/activity.py b/activity.py index 6bcbaf1..1cf3040 100755 --- a/activity.py +++ b/activity.py @@ -194,7 +194,8 @@ class MazeActivity(activity.Activity): logging.debug('Saving the state of the game...') data = {'seed': self.game.maze.seed, 'width': self.game.maze.width, - 'height': self.game.maze.height, } + 'height': self.game.maze.height, + 'finish_time': self.game.finish_time} logging.debug('Saving data: %s', data) self.metadata['state'] = json.dumps(data) @@ -84,8 +84,12 @@ class MazeGame(Gtk.DrawingArea): 'width': int(9 * self.aspectRatio), 'height': 9} + if 'finish_time' in state and state['finish_time'] is not None: + # the maze was alread played, reset it to start a new one + state['seed'] = int(time.time()) + logging.debug('Starting the game with: %s', state) - self.maze = Maze(**state) + self.maze = Maze(state['seed'], state['width'], state['height']) self._ebook_mode_detector = sensors.EbookModeDetector() self._finish_window = None self.reset() |