From: Jeremy Thurgood Date: Sat, 17 May 2014 17:25:33 +0000 (+0200) Subject: Move-if-MSB actions. X-Git-Tag: 0.1~66 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=556f041912b43276d73f6afc9855ab5168c9c3ac;p=naja.git Move-if-MSB actions. --- diff --git a/data/location_decks/standard.yaml b/data/location_decks/standard.yaml index c4fe96a..5e14e9d 100644 --- a/data/location_decks/standard.yaml +++ b/data/location_decks/standard.yaml @@ -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 diff --git a/naja/actions.py b/naja/actions.py index 9f3b221..464b3ae 100644 --- a/naja/actions.py +++ b/naja/actions.py @@ -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)