X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fgameboard.py;h=9c5af7b3554382158c79df337742e605c6b819a7;hb=18eaa15b16160df3dcd23dd2773603d1f2e179ce;hp=a107b16315416a1deb6cce27e74e1abc9b9216bf;hpb=eccb327f1260b9aa981755840e097d5b23af05a9;p=naja.git diff --git a/naja/gameboard.py b/naja/gameboard.py index a107b16..9c5af7b 100644 --- a/naja/gameboard.py +++ b/naja/gameboard.py @@ -31,14 +31,21 @@ class GameBoard(object): 'wins': 0, } + def update_state(self, state): + self.health = state['health'] + self.wins = state['wins'] + + def lose_health(self): + self.health -= 1 + # TODO: Check win/lose + class LocationCard(object): """ A particular set of options available on a location. """ - def __init__(self, bitwise_operation, bitwise_operand, actions): - self.bitwise_operation = bitwise_operation + def __init__(self, bitwise_operand, actions): self.bitwise_operand = bitwise_operand self.actions = actions @@ -66,27 +73,27 @@ class LocationCard(object): def generate_location_actions(): raise NotImplementedError("TODO") - def apply_bitwise_operation(self, player): - operator = { - 'SET': player.bits.set_bits, - 'CLEAR': player.bits.clear_bits, - 'TOGGLE': player.bits.toggle_bits, - }[self.bitwise_operation] - operator(self.bitwise_operand) - class LocationAction(object): """ An action that may be performed on a location. """ - REQUIRED_BITS = frozenset() + TEXT = None - def __init__(self, **data): + def __init__(self, required_bits, **data): + self.required_bits = required_bits self.data = data def check_available(self, player): - return player.bits.check_bits(self.REQUIRED_BITS) + return player.bits.check_bits(self.required_bits) def perform_action(self, player, board): raise NotImplementedError("TODO") + + def check_and_clear_MSB(self, player): + if player.bits.check_bit(BITS.MSB): + player.bits.clear_bit(BITS.MSB) + return True + else: + return False