Start of standard deck.
authorJeremy Thurgood <firxen@gmail.com>
Fri, 16 May 2014 13:28:06 +0000 (15:28 +0200)
committerJeremy Thurgood <firxen@gmail.com>
Fri, 16 May 2014 13:28:06 +0000 (15:28 +0200)
data/location_decks/standard.yaml [new file with mode: 0644]
data/location_decks/test.yaml
naja/actions.py
naja/gamestate.py

diff --git a/data/location_decks/standard.yaml b/data/location_decks/standard.yaml
new file mode 100644 (file)
index 0000000..ef8ecf9
--- /dev/null
@@ -0,0 +1,143 @@
+description: "Standard location deck."
+
+# This field is ignored, but it's a useful place to put some action definitions
+# we can reference later.
+_standard_actions:
+  # 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}
+
+  # 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]
+
+# This field is ignored, but it's a useful place to put some action definitions
+# we can reference later.
+_standard_cards:
+  - &WIN-CARD
+    actions:
+      - *ACQUIRE-WIN-TOKEN
+
+  - &KNIGHT-AND-SET
+    actions:
+      - *BAD-DEFAULT
+      - *SET-BITS-B
+      - *KNIGHT-MOVE
+  - &CASTLE-AND-SET
+    actions:
+      - *BAD-DEFAULT
+      - *SET-BITS-G
+      - *CASTLE-MOVE
+  - &BISHOP-AND-SET
+    actions:
+      - *BAD-DEFAULT
+      - *SET-BITS-R
+      - *BISHOP-MOVE
+
+  - &TOGGLE-RG-R
+    bits: [RED, GREEN]  # Colour-blind robot!
+    actions:
+      - action_class: 'ToggleBits'
+        required_bits: [RED]
+      - action_class: 'SetBits'
+        required_bits: [GREEN, BLUE]
+  - &TOGGLE-RG-G
+    bits: [RED, GREEN]  # Colour-blind robot!
+    actions:
+      - action_class: 'ToggleBits'
+        required_bits: [GREEN]
+      - action_class: 'SetBits'
+        required_bits: [RED, BLUE]
+
+  - &SHIFT-N-AND-HEAL
+    actions:
+      - *TOGGLE-BITS-DEFAULT
+      - *SHIFT-N
+      - *HEAL-RG
+  - &SHIFT-S-AND-HEAL
+    actions:
+      - *TOGGLE-BITS-DEFAULT
+      - *SHIFT-S
+      - *HEAL-RG
+  - &SHIFT-E-AND-HEAL
+    actions:
+      - *TOGGLE-BITS-DEFAULT
+      - *SHIFT-E
+      - *HEAL-RB
+  - &SHIFT-W-AND-HEAL
+    actions:
+      - *TOGGLE-BITS-DEFAULT
+      - *SHIFT-W
+      - *HEAL-RB
+
+cards:
+  - *WIN-CARD
+  - *KNIGHT-AND-SET
+  - *CASTLE-AND-SET
+  - *BISHOP-AND-SET
+  - *TOGGLE-RG-R
+  - *TOGGLE-RG-G
+  - *SHIFT-N-AND-HEAL
+  - *SHIFT-S-AND-HEAL
+  - *SHIFT-E-AND-HEAL
+  - *SHIFT-W-AND-HEAL
index 3c650320faf3563956cd98f6d971995840f2b378..d88978d41e94b1ed1d6d23c867ffbd350df9ff18 100644 (file)
@@ -3,22 +3,22 @@ description: "Test location deck."
 # This field is ignored, but it's a useful place to put some action definitions
 # we can reference later.
 _standard_actions:
-  set_bits_default: &SET-BITS-DEFAULT
+  - &SET-BITS-DEFAULT
     action_class: 'LoseHealthOrMSBAndSetBits'
     required_bits: []
-  gain_health_default: &GAIN-HEALTH-DEFAULT
+  - &GAIN-HEALTH-DEFAULT
     action_class: 'GainHealthAndClearBitsOrMSB'
     required_bits: []
-  bad_default: &BAD-DEFAULT
+  - &BAD-DEFAULT
     action_class: 'LoseHealthOrMSB'
     required_bits: []
-  toggle_bits_c: &TOGGLE-BITS-C
+  - &TOGGLE-BITS-C
     action_class: 'ToggleBits'
     required_bits: [BLUE]
-  set_bits_ym: &SET-BITS-YM
+  - &SET-BITS-YM
     action_class: 'SetBits'
     required_bits: [RED, GREEN]
-  acquire_win_token: &ACQUIRE-WIN-TOKEN
+  - &ACQUIRE-WIN-TOKEN
     action_class: 'AcquireWinToken'
     required_bits: [RED, GREEN, BLUE]
 
index cf916b9280126f879baf157444806432645702c2..0626b34d6d1eb40b62af76c7796f19eb59920c21 100644 (file)
@@ -113,6 +113,14 @@ class AcquireWinToken(LocationAction):
         ]))
 
 
+class GainHealth(LocationAction):
+    TEXT = "Gain {HEALTH}."
+    GLYPHS = (ACTION_GLYPHS.HEAL,)
+
+    def perform_action(self, board, location):
+        board.gain_health()
+
+
 class GainHealthAndClearBitsOrMSB(LocationAction):
     TEXT = "Gain {HEALTH}, then clear %(location_bits)s or {MSB}."
     GLYPHS = (ACTION_GLYPHS.HEAL,)
index c8bbbc7acc67c54ec1d5827c3e3ddcb70be3bfd7..a2ed6e0d70225dc0f50d1a6e70eeca52d5372766 100644 (file)
@@ -21,7 +21,8 @@ class GameState(object):
     def __init__(self):
         # This is a very simple deck to allow testing more drawing logic
         # on tiles. These will need to be replaced with better stuff.
-        locations_deck = load_location_deck('test')
+        locations_deck = load_location_deck('standard')
+        # locations_deck = load_location_deck('test')
         self.gameboard = GameBoard.new_game(locations_deck['cards'])
 
     @property