diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2014-06-12 20:50:28 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2014-06-16 15:26:39 (GMT) |
commit | 19123999f8dc9e890e22dcb24925dd5e78ebff9f (patch) | |
tree | 69f61ea7bd87f8f14d868632fe5d42d47baea79f | |
parent | 2304399994e1f29ad87e8df1bbc4c7fd8810a9c4 (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() |