X-Git-Url: https://git.ctpug.org.za/?p=naja.git;a=blobdiff_plain;f=naja%2Factions.py;h=f5b03a0e4399e3715c2d0cee3ffd5feeec5a15d4;hp=89c43f81abb049f42923658d7f0cc9763ab5535e;hb=e6c9584589c3e3565be85f9b0f0eb5923a394a86;hpb=98f1e5d415b33e746850ec64c0cc804d38bd1bc3 diff --git a/naja/actions.py b/naja/actions.py index 89c43f8..f5b03a0 100644 --- a/naja/actions.py +++ b/naja/actions.py @@ -77,6 +77,10 @@ class LocationAction(object): 'data': self.data, 'action_class': self.__class__.__name__} + def take_damage(self, board): + sound.play_sound('awwww.ogg') + board.lose_health() + class DoNothing(LocationAction): TEXT = "No effect." @@ -92,8 +96,7 @@ class LoseHealthOrMSB(LocationAction): def perform_action(self, board, location): if not self.check_and_clear_MSB(board.player): - sound.play_sound('awwww.ogg') - board.lose_health() + self.take_damage(board) class SetBits(LocationAction): @@ -112,6 +115,15 @@ class ClearBits(LocationAction): board.player.bits.clear_bits(location.bitwise_operand) +class ClearBitsAndHealth(LocationAction): + TEXT = "Clear %(location_bits)s and {HEALTH}." + GLYPHS = (ACTION_GLYPHS.CLEAR_BITS, ACTION_GLYPHS.DAMAGE) + + def perform_action(self, board, location): + board.player.bits.clear_bits(location.bitwise_operand) + self.take_damage(board) + + class ToggleBits(LocationAction): TEXT = "Toggle %(location_bits)s." GLYPHS = (ACTION_GLYPHS.TOGGLE_BITS,) @@ -120,6 +132,15 @@ class ToggleBits(LocationAction): board.player.bits.toggle_bits(location.bitwise_operand) +class ToggleBitsAndHarm(LocationAction): + TEXT = "Toggle %(location_bits)s and lose {HEALTH}." + GLYPHS = (ACTION_GLYPHS.TOGGLE_BITS, ACTION_GLYPHS.DAMAGE) + + def perform_action(self, board, location): + board.player.bits.toggle_bits(location.bitwise_operand) + self.take_damage(board) + + class GenericBits(LocationAction): GLYPHS = (ACTION_GLYPHS.SET_BITS, ACTION_GLYPHS.CLEAR_BITS)