From: David Sharpe Date: Sat, 17 May 2014 20:17:42 +0000 (+0200) Subject: Merge branch 'master' of git://ctpug.org.za/naja X-Git-Tag: 0.1~29 X-Git-Url: https://git.ctpug.org.za/?p=naja.git;a=commitdiff_plain;h=e329ac961000595f819bfa145c8d150641c2aece;hp=-c Merge branch 'master' of git://ctpug.org.za/naja --- e329ac961000595f819bfa145c8d150641c2aece diff --combined naja/actions.py index 9513a0a,395a1f5..5701109 --- a/naja/actions.py +++ b/naja/actions.py @@@ -16,6 -16,9 +16,9 @@@ class LocationAction(object) self.required_bits = required_bits self.data = data + def sanity_check(self, location): + pass + def get_glyphs(self): return self.GLYPHS @@@ -116,7 -119,7 +119,7 @@@ class ClearBits(LocationAction) class ClearBitsAndHealth(LocationAction): - TEXT = "Clear %(location_bits)s and {HEALTH}." + TEXT = "Clear %(location_bits)s and lose {HEALTH}." GLYPHS = (ACTION_GLYPHS.CLEAR_BITS, ACTION_GLYPHS.DAMAGE) def perform_action(self, board, location): @@@ -153,6 -156,16 +156,16 @@@ class GenericBits(LocationAction) self.acquire_win = self.data.get('acquire_win', False) self.lose_health = self.data.get('lose_health', False) + def sanity_check(self, location): + missing_bits = set() + missing_bits.update(self.set_bits - set(location.bitwise_operand)) + missing_bits.update(self.clear_bits - set(location.bitwise_operand)) + missing_bits.update(self.toggle_bits - set(location.bitwise_operand)) + if missing_bits: + raise ValueError( + "Location %s missing bits %r" + % (location.card_name, sorted(list(missing_bits)))) + def perform_action(self, board, location): bits = board.player.bits bits.set_bits(self.set_bits)