From 4d02505175b7f9ffe70c62fa28a6a880383648ca Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Thu, 12 Jun 2014 20:50:28 +0000 Subject: If the maze was finished, show a differnt maze the next activiy start --- 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) diff --git a/game.py b/game.py index 5a2fc95..5ea1d89 100644 --- a/game.py +++ b/game.py @@ -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() -- cgit v0.9.1