Add scaffolding for puzzle levels (no actual puzzle support yet).
authorSimon Cross <hodgestar@gmail.com>
Fri, 16 May 2014 20:21:46 +0000 (22:21 +0200)
committerSimon Cross <hodgestar@gmail.com>
Fri, 16 May 2014 20:21:56 +0000 (22:21 +0200)
data/location_decks/test_puzzle.yaml [new file with mode: 0644]
naja/gamestate.py
naja/scenes/new_game.py

diff --git a/data/location_decks/test_puzzle.yaml b/data/location_decks/test_puzzle.yaml
new file mode 100644 (file)
index 0000000..60b8149
--- /dev/null
@@ -0,0 +1,131 @@
+description: "Test Puzzle"
+puzzle: true
+
+# This field is ignored, but it's a useful place to put some action definitions
+# we can reference later.
+_action_definitions:
+  # No-colour actions.
+  - &SET-BITS-DEFAULT
+    action_class: 'LoseHealthOrMSBAndSetBits'
+    required_bits: []
+  - &GAIN-HEALTH-DEFAULT
+    action_class: 'GainHealthAndClearBitsOrMSB'
+    required_bits: []
+  - &TOGGLE-BITS-DEFAULT
+    action_class: 'ToggleBits'
+    required_bits: []
+  - &BAD-DEFAULT
+    action_class: 'LoseHealthOrMSB'
+    required_bits: []
+
+  # One-colour actions.
+  - &SET-BITS-R
+    action_class: 'SetBits'
+    required_bits: [RED]
+  - &SET-BITS-G
+    action_class: 'SetBits'
+    required_bits: [GREEN]
+  - &SET-BITS-B
+    action_class: 'SetBits'
+    required_bits: [BLUE]
+
+  - &SHIFT-N
+    action_class: 'ShiftLocations'
+    required_bits: [BLUE]
+    data: {'direction': NORTH}
+  - &SHIFT-S
+    action_class: 'ShiftLocations'
+    required_bits: [BLUE]
+    data: {'direction': SOUTH}
+  - &SHIFT-E
+    action_class: 'ShiftLocations'
+    required_bits: [GREEN]
+    data: {'direction': EAST}
+  - &SHIFT-W
+    action_class: 'ShiftLocations'
+    required_bits: [GREEN]
+    data: {'direction': WEST}
+
+  - &ROT-CW
+    action_class: 'RotateLocations'
+    required_bits: [RED]
+    data: {'rot_direction': CLOCKWISE}
+  - &ROT-CCW
+    action_class: 'RotateLocations'
+    required_bits: [RED]
+    data: {'rot_direction': ANTICLOCKWISE}
+
+  # Two-colour actions.
+  - &KNIGHT-MOVE
+    action_class: 'AllowChessMove'
+    required_bits: [RED, GREEN]
+    data: {'chesspiece': KNIGHT}
+  - &CASTLE-MOVE
+    action_class: 'AllowChessMove'
+    required_bits: [RED, BLUE]
+    data: {'chesspiece': CASTLE}
+  - &BISHOP-MOVE
+    action_class: 'AllowChessMove'
+    required_bits: [GREEN, BLUE]
+    data: {'chesspiece': BISHOP}
+
+  - &HEAL-RG
+    action_class: 'GainHealth'
+    required_bits: [RED, GREEN]
+  - &HEAL-RB
+    action_class: 'GainHealth'
+    required_bits: [RED, BLUE]
+
+  # Three-colour actions.
+  - &ACQUIRE-WIN-TOKEN
+    action_class: 'AcquireWinToken'
+    required_bits: [RED, GREEN, BLUE]
+
+  # Test actions
+  - &TEST-WIN
+    action_class: 'AcquireWinToken'
+    required_bits: []
+  - &TEST-NULL
+    action_class: 'DoNothing'
+    required_bits: []
+
+# This field is ignored, but it's a useful place to put some card definitions
+# we can reference later.
+_card_definitions:
+  - &TEST-WIN-CARD
+    actions:
+      - *TEST-WIN
+  - &TEST-BORING
+    actions:
+      - *TEST-NULL
+
+cards:
+  - *TEST-WIN-CARD
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-WIN-CARD
+
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-BORING
+
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-BORING
+
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-BORING
+
+  - *TEST-WIN-CARD
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-BORING
+  - *TEST-WIN-CARD
index 134fba3bad70649c1ed39b6bc08c1c2b535839d0..c3bc0ce96b75c27bd14bbe49b3daad3c20ee0ef9 100644 (file)
@@ -22,8 +22,8 @@ class GameState(object):
         self.gameboard = gameboard
 
     @classmethod
-    def new(cls, **kw):
-        locations_deck = load_location_deck('standard')
+    def new(cls, deck='standard', **kw):
+        locations_deck = load_location_deck(deck)
         return cls(GameBoard.new_game(locations_deck['cards'], **kw))
 
     @classmethod
index 32584eb9be17338e743fb0fbccfe677ad7ba7929..dca7c67eb9c3ca908d512251bb855fed067d5eba 100644 (file)
@@ -34,6 +34,10 @@ class NewGameScene(Scene):
         hard.add_callback('click', self.hard_game)
         selector.add(hard)
 
+        puzzle = TextWidget((200, 300), 'Puzzle', fontsize=32, colour='white')
+        puzzle.add_callback('click', self.puzzle_game)
+        selector.add(puzzle)
+
     def easy_game(self, event):
         self.start_game(GameState.new(max_health=5, wins_required=3))
 
@@ -43,6 +47,10 @@ class NewGameScene(Scene):
     def hard_game(self, event):
         self.start_game(GameState.new(max_health=3, wins_required=5))
 
+    def puzzle_game(self, event):
+        self.start_game(GameState.new(
+            deck='test_puzzle', max_health=4, wins_required=4))
+
     def start_game(self, state):
         from naja.scenes.game import GameScene
         LoadGameEvent.post(state=state)