From: Jeremy Thurgood Date: Fri, 16 May 2014 21:29:01 +0000 (+0200) Subject: Save and load cheater flag. X-Git-Tag: 0.1~176 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=73ee34a71479a7fd57a7072bf374c8173cefe743;p=naja.git Save and load cheater flag. --- diff --git a/naja/gameboard.py b/naja/gameboard.py index 8a1daa7..74abc12 100644 --- a/naja/gameboard.py +++ b/naja/gameboard.py @@ -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): diff --git a/naja/scenes/win.py b/naja/scenes/win.py index f14034a..c4a09a8 100644 --- a/naja/scenes/win.py +++ b/naja/scenes/win.py @@ -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(