Move-if-MSB actions.
authorJeremy Thurgood <firxen@gmail.com>
Sat, 17 May 2014 17:25:33 +0000 (19:25 +0200)
committerJeremy Thurgood <firxen@gmail.com>
Sat, 17 May 2014 17:25:44 +0000 (19:25 +0200)
data/location_decks/standard.yaml
naja/actions.py

index c4fe96a69c4c307b8fa0fc2521c8a43da5ad4e94..5e14e9d84da0860c2c059e60a09e188966a62ad9 100644 (file)
@@ -17,6 +17,19 @@ _action_definitions:
     action_class: 'LoseHealthOrMSB'
     required_bits: []
 
+  - &KNIGHT-MSB-DEFAULT
+    action_class: 'AllowChessMoveIfMSB'
+    required_bits: []
+    data: {'chesspiece': KNIGHT}
+  - &CASTLE-MSB-DEFAULT
+    action_class: 'AllowChessMoveIfMSB'
+    required_bits: []
+    data: {'chesspiece': CASTLE}
+  - &BISHOP-MSB-DEFAULT
+    action_class: 'AllowChessMoveIfMSB'
+    required_bits: []
+    data: {'chesspiece': BISHOP}
+
   # One-colour actions.
   - &SET-BITS-R
     action_class: 'SetBits'
@@ -135,6 +148,25 @@ _card_definitions:
       - *SET-BITS-R
       - *BISHOP-MOVE
 
+  - &BISHOP-SET-KNIGHT
+    card_name: 'bishop_set_knight'
+    actions:
+      - *BISHOP-MSB-DEFAULT
+      - *SET-BITS-B
+      - *KNIGHT-MOVE
+  - &KNIGHT-SET-CASTLE
+    card_name: 'knight_set_castle'
+    actions:
+      - *KNIGHT-MSB-DEFAULT
+      - *SET-BITS-G
+      - *CASTLE-MOVE
+  - &CASTLE-SET-BISHOP
+    card_name: 'castle_set_bishop'
+    actions:
+      - *CASTLE-MSB-DEFAULT
+      - *SET-BITS-R
+      - *BISHOP-MOVE
+
   - &TOGGLE-RG-R
     card_name: 'toggle-rg-r'
     bits: [RED, GREEN]  # Colour-blind robot!
@@ -211,6 +243,9 @@ cards:
   - *KNIGHT-AND-SET
   - *CASTLE-AND-SET
   - *BISHOP-AND-SET
+  - *BISHOP-SET-KNIGHT
+  - *KNIGHT-SET-CASTLE
+  - *CASTLE-SET-BISHOP
   - *TOGGLE-RG-R
   - *TOGGLE-RG-G
   - *SHIFT-N-AND-HEAL
index 9f3b221b3af18cf033093465d0306a9ec1ddab93..464b3ae285482c2b6d3967d8687c39759bd78308 100644 (file)
@@ -185,3 +185,14 @@ class AllowChessMove(LocationAction):
         if self.data['chesspiece'] in CHESS_PIECES:
             chesspiece = CHESS_PIECES[self.data['chesspiece']]
             board.allow_chess_move(chesspiece)
+
+
+class AllowChessMoveIfMSB(LocationAction):
+    TEXT = "Clear {MSB} and move like a %(chesspiece_name)s for one turn."
+    MSB_GLYPH = ACTION_GLYPHS.MOVEMENT
+
+    def perform_action(self, board, location):
+        if self.data['chesspiece'] in CHESS_PIECES:
+            if self.check_and_clear_MSB(board.player):
+                chesspiece = CHESS_PIECES[self.data['chesspiece']]
+                board.allow_chess_move(chesspiece)