X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Factions.py;h=45698ef1c495c1cc6c0092e2faa25a4490940655;hb=e5731d2cbc0c7a260e7b69aac07e6c26b9b2c56d;hp=c0f19c634cf62443bd2af5bce8bf145bd7098a59;hpb=03a118a3e62b13b477c1308514235a7533083d2c;p=naja.git diff --git a/naja/actions.py b/naja/actions.py index c0f19c6..45698ef 100644 --- a/naja/actions.py +++ b/naja/actions.py @@ -46,7 +46,11 @@ class LocationAction(object): substitutions['location_bits'] = bit_glyphs( location.bitwise_operand) - return self.TEXT % substitutions + text = self.TEXT + if self.data.get('message', None) is not None: + text = self.data['message'] + + return text % substitutions def check_available(self, player): return player.bits.check_bits(self.required_bits) @@ -94,6 +98,14 @@ class SetBits(LocationAction): board.player.bits.set_bits(location.bitwise_operand) +class ClearBits(LocationAction): + TEXT = "Clear %(location_bits)s." + GLYPHS = (ACTION_GLYPHS.CLEAR_BITS,) + + def perform_action(self, board, location): + board.player.bits.clear_bits(location.bitwise_operand) + + class ToggleBits(LocationAction): TEXT = "Toggle %(location_bits)s." GLYPHS = (ACTION_GLYPHS.TOGGLE_BITS,) @@ -188,7 +200,9 @@ class AllowChessMove(LocationAction): class AllowChessMoveIfMSB(LocationAction): - TEXT = "Clear {MSB} and move like a %(chesspiece_name)s for one turn." + TEXT = ( + "Clear {MSB} and move like a %(chesspiece_name)s for one turn if it " + "was set.") MSB_GLYPH = ACTION_GLYPHS.MOVEMENT def perform_action(self, board, location):