+
+
+class SetBits(LocationAction):
+ TEXT = "Set %(location_bits)s."
+
+ def perform_action(self, board, location):
+ board.player.bits.set_bits(location.bitwise_operand)
+
+
+class ToggleBits(LocationAction):
+ TEXT = "Toggle %(location_bits)s."
+
+ def perform_action(self, board, location):
+ board.player.bits.toggle_bits(location.bitwise_operand)
+
+
+class LoseHealthOrMSBAndSetBits(LocationAction):
+ TEXT = "Lose HEALTH or MSB, then set %(location_bits)s."
+ USES_MSB = True
+
+ def perform_action(self, board, location):
+ if not self.check_and_clear_MSB(board.player):
+ board.lose_health()
+ board.player.bits.set_bits(location.bitwise_operand)
+
+
+class AcquireWinToken(LocationAction):
+ TEXT = "Gain WINTOKEN, then clear {RED,GREEN,BLUE}."
+
+ def perform_action(self, board, location):
+ board.acquire_win_token()
+ board.player.bits.clear_bits(set([
+ BITS.RED, BITS.GREEN, BITS.BLUE,
+ ]))
+
+
+class GainHealthAndClearBitsOrMSB(LocationAction):
+ TEXT = "Gain HEALTH, then clear %(location_bits)s or MSB."
+ USES_MSB = True
+
+ def perform_action(self, board, location):
+ board.gain_health()
+ if not self.check_and_clear_MSB(board.player):
+ board.player.bits.clear_bits(location.bitwise_operand)
+
+
+class ShiftLocations(LocationAction):
+ TEXT = "Shift current %(rowcol)s %(direction)s."
+
+ def perform_action(self, board, location):
+ board.shift_locations(self.data['direction'])
+
+
+class AllowChessMove(LocationAction):
+ TEXT = "Move like a %(chesspiece_name)s for one turn."
+
+ def perform_action(self, board, location):
+ if self.data['chesspiece'] in CHESS_PIECES:
+ chesspiece = CHESS_PIECES[self.data['chesspiece']]
+ board.allow_chess_move(chesspiece)