+from naja.constants import BITS
+
+
+class LocationAction(object):
+ """
+ An action that may be performed on a location.
+ """
+
+ TEXT = None
+
+ def __init__(self, required_bits, **data):
+ bits = set()
+ for bit in required_bits:
+ # Convert names to numbers if applicable.
+ bits.add(BITS.get(bit, bit))
+ self.required_bits = frozenset(bits)
+ self.data = data
+
+ def check_available(self, player):
+ return player.bits.check_bits(self.required_bits)
+
+ def perform_action(self, board, location):
+ 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
+
+ def export(self):
+ return {'required_bits': list(self.required_bits),
+ 'data': self.data,
+ 'action_class': self.__class__.__name__}