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:
@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,