Toggle bits when cheats are enabled.
authorJeremy Thurgood <firxen@gmail.com>
Fri, 16 May 2014 20:05:24 +0000 (22:05 +0200)
committerJeremy Thurgood <firxen@gmail.com>
Fri, 16 May 2014 20:05:24 +0000 (22:05 +0200)
naja/scenes/game.py

index b50065febe42de6526d315cd7573aeadfbc89a5a..dda5e1eb53f5832bce5eabe4738eb186d321dc95 100644 (file)
@@ -5,14 +5,15 @@ Gameboard scene.
 import pygame.locals as pgl
 
 from naja.constants import KEYS
-from naja.events import SceneChangeEvent
+from naja.events import SceneChangeEvent, finish_event
+from naja.options import options
 from naja.scenes.scene import Scene
+from naja.sound import sound
 from naja.widgets.board import BoardWidget
 from naja.widgets.player_bits import PlayerBitsWidget
 from naja.widgets.game_bits import GameBitsWidget
 from naja.widgets.info_area import InfoAreaWidget
 from naja.widgets.robot import RobotWidget
-from naja.sound import sound
 
 
 class GameScene(Scene):
@@ -32,6 +33,25 @@ class GameScene(Scene):
 
     def handle_scene_event(self, ev):
         from naja.scenes.menu import MenuScene
-        if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
-            SceneChangeEvent.post(MenuScene)
-            return
+        if ev.type == pgl.KEYDOWN:
+            if ev.key in KEYS.QUIT:
+                SceneChangeEvent.post(MenuScene)
+                return
+            if options.cheat_enabled:
+                if ev.key == pgl.K_0:
+                    self.state.player.bits.toggle_bit(0)
+                elif ev.key == pgl.K_1:
+                    self.state.player.bits.toggle_bit(1)
+                elif ev.key == pgl.K_2:
+                    self.state.player.bits.toggle_bit(2)
+                elif ev.key == pgl.K_3:
+                    self.state.player.bits.toggle_bit(3)
+                elif ev.key == pgl.K_4:
+                    self.state.player.bits.toggle_bit(4)
+                elif ev.key == pgl.K_5:
+                    self.state.player.bits.toggle_bit(5)
+                elif ev.key == pgl.K_6:
+                    self.state.player.bits.toggle_bit(6)
+                elif ev.key == pgl.K_7:
+                    self.state.player.bits.toggle_bit(7)
+                return finish_event()