Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2014-06-12 20:50:28 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2014-06-16 15:26:39 (GMT)
commit19123999f8dc9e890e22dcb24925dd5e78ebff9f (patch)
tree69f61ea7bd87f8f14d868632fe5d42d47baea79f
parent2304399994e1f29ad87e8df1bbc4c7fd8810a9c4 (diff)
If the maze was finished, show a differnt maze the next activiy start
-rwxr-xr-xactivity.py3
-rw-r--r--game.py6
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)
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()