From: Jeremy Thurgood Date: Tue, 13 May 2014 21:07:40 +0000 (+0200) Subject: Add win token action. X-Git-Tag: 0.1~320 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=520e32c0dbfb3cdfdf63ea762429f259fe8b7435;p=naja.git Add win token action. --- 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