Add win token action.
authorJeremy Thurgood <firxen@gmail.com>
Tue, 13 May 2014 21:07:40 +0000 (23:07 +0200)
committerJeremy Thurgood <firxen@gmail.com>
Tue, 13 May 2014 21:07:40 +0000 (23:07 +0200)
data/location_decks/test.yaml
naja/actions.py
naja/gameboard.py

index 53a0c77dcd65e3f62701c7ee675c375bc841f20d..b0b0b111fe19245ac557abd70da2831173c6b164 100644 (file)
@@ -15,6 +15,9 @@ _standard_actions:
   set_bits_ym: &SET-BITS-YM
     action_class: 'SetBits'
     required_bits: [YELLOW, MAGENTA]
+  acquire_win_token: &ACQUIRE-WIN-TOKEN
+    action_class: 'AcquireWinToken'
+    required_bits: [CYAN, MAGENTA, YELLOW]
 
 cards:
   - actions:
@@ -28,3 +31,6 @@ cards:
       required_bits: [YELLOW]
   - actions:
     - *SET-BITS-YM
+  - actions:
+    - *BAD-DEFAULT
+    - *ACQUIRE-WIN-TOKEN
index efbb16b696027255dad973984b15c2dfc54b9e14..354d88097bd8c624e37f17b8762f7e9dd69cccf9 100644 (file)
@@ -74,3 +74,15 @@ class LoseHealthOrMSBAndSetBits(LocationAction):
         if not self.check_and_clear_MSB(board.player):
             board.lose_health()
         board.player.bits.set_bits(location.bitwise_operand)
+
+
+class AcquireWinToken(LocationAction):
+    TEXT = "Acquire a win token, then clear all high bits."
+    USES_MSB = True
+
+    def perform_action(self, board, location):
+        if self.check_and_clear_MSB(board.player):
+            board.acquire_win_token()
+            board.player.bits.clear_bits(set([
+                BITS.CYAN, BITS.MAGENTA, BITS.YELLOW,
+            ]))
index 8d4106cc931011dea15725842abf188a0b51f999..ae80b8c887e926ceaa27af72b76f25ab3ad6a832 100644 (file)
@@ -90,6 +90,10 @@ class GameBoard(object):
         self.health -= 1
         # TODO: Check win/lose
 
+    def acquire_win_token(self):
+        self.wins += 1
+        # TODO: Check win/lose
+
     def replace_card(self, position):
         location = LocationCard.new_location(choice(self.locations).copy())
         self.board_locations[position] = location