From 520e32c0dbfb3cdfdf63ea762429f259fe8b7435 Mon Sep 17 00:00:00 2001 From: Jeremy Thurgood Date: Tue, 13 May 2014 23:07:40 +0200 Subject: [PATCH] Add win token action. --- data/location_decks/test.yaml | 6 ++++++ naja/actions.py | 12 ++++++++++++ naja/gameboard.py | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/data/location_decks/test.yaml b/data/location_decks/test.yaml index 53a0c77..b0b0b11 100644 --- a/data/location_decks/test.yaml +++ b/data/location_decks/test.yaml @@ -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 diff --git a/naja/actions.py b/naja/actions.py index efbb16b..354d880 100644 --- a/naja/actions.py +++ b/naja/actions.py @@ -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, + ])) diff --git a/naja/gameboard.py b/naja/gameboard.py index 8d4106c..ae80b8c 100644 --- a/naja/gameboard.py +++ b/naja/gameboard.py @@ -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 -- 2.34.1