X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fgameboard.py;h=367a9e15118b4cbd6b9fe3248a691c141f66831d;hb=0dfef62c2ebdab980497ca8c26bc3228f47b9069;hp=edda43c702c146211ec0fca2f016e44c89f5c626;hpb=02ac35df9206ceaf9469ce5e77555b4809c1abcf;p=naja.git diff --git a/naja/gameboard.py b/naja/gameboard.py index edda43c..367a9e1 100644 --- a/naja/gameboard.py +++ b/naja/gameboard.py @@ -130,6 +130,9 @@ class GameBoard(object): elif BITS[direction] == BITS.WEST: self.shift_location_row(-1, is_vertical=False) + def allow_chess_move(self, chesspiece): + self.player.allow_chess_move(chesspiece) + def change_mode(self, new_mode): """Advance to the next mode""" if new_mode == self.player_mode: @@ -170,17 +173,26 @@ class LocationCard(object): @classmethod def build_action(cls, definition): action_class = getattr(actions, definition['action_class']) - required_bits = definition['required_bits'] + required_bits = cls.parse_bits(definition['required_bits']) data = definition.get('data', {}) return action_class(required_bits, **data) @classmethod def new_location(cls, definition): + if 'bits' in definition: + bits = cls.parse_bits(definition['bits']) + else: + bits = cls.generate_bitwise_operand() return cls.import_location({ - 'bitwise_operand': cls.generate_bitwise_operand(), + 'bitwise_operand': bits, 'actions': definition['actions'], }) + @classmethod + def parse_bits(self, bit_list): + # Convert names to numbers if applicable. + return frozenset(BITS.get(bit, bit) for bit in bit_list) + def export(self): return { 'bitwise_operand': self.bitwise_operand,