Save and load cheater flag.
authorJeremy Thurgood <firxen@gmail.com>
Fri, 16 May 2014 21:29:01 +0000 (23:29 +0200)
committerJeremy Thurgood <firxen@gmail.com>
Fri, 16 May 2014 21:29:01 +0000 (23:29 +0200)
naja/gameboard.py
naja/scenes/win.py

index 8a1daa7673b28d34dc1c264f5c5d0c3b3b3d5325..74abc12e5e82d763faf8f7dfb20df36745356fd4 100644 (file)
@@ -23,6 +23,7 @@ class GameBoard(object):
         self.player = player
         self.board_locations = board_locations
         self.player_mode = state.get('player_mode', EXAMINE)
+        self.has_cheated = state.get('cheater', options.cheat_enabled)
 
     @classmethod
     def new_game(cls, deck,
@@ -54,7 +55,7 @@ class GameBoard(object):
         return cls(state, player, board_locations)
 
     def export(self):
-        return {
+        data = {
             'max_health': self.max_health,
             'health': self.health,
             'wins_required': self.wins_required,
@@ -65,6 +66,9 @@ class GameBoard(object):
             'board_locations': self.export_board_locations(),
             'player_mode': self.player_mode,
         }
+        if self.has_cheated:
+            data['cheater'] = True
+        return data
 
     @classmethod
     def import_locations(cls, locations_definition):
index f14034a822ba5279aee6e0284f07ad9829af423c..c4a09a8727013c5c706ca6354e2f0fe7f4fce789 100644 (file)
@@ -6,7 +6,6 @@ import pygame.locals as pgl
 
 from naja.constants import KEYS, PALETTE
 from naja.events import QuitGameEvent
-from naja.options import options
 from naja.scenes.scene import Scene
 from naja.widgets.text import TextWidget, TextBoxWidget
 
@@ -19,7 +18,7 @@ class WinScene(Scene):
     def __init__(self, state):
         super(WinScene, self).__init__(state)
         self.add(TextWidget((50, 50), 'You won!', colour=PALETTE.WHITE))
-        if options.cheat_enabled:
+        if self.state.gameboard.has_cheated:
             self.add(TextWidget(
                 (50 + 64, 50), 'CHEATER!', colour=PALETTE.ORANGE))
         self.add(TextBoxWidget(