-from naja.constants import BITS
+from naja.constants import BITS, CHESS_PIECES
class LocationAction(object):
def get_text(self):
substitutions = self.data.copy()
+
if 'direction' in self.data:
substitutions['rowcol'] = {
'NORTH': 'column',
'EAST': 'row',
'WEST': 'row',
}[self.data['direction']]
+
+ if 'chesspiece' in self.data:
+ substitutions['chesspiece_name'] = self.data['chesspiece'].lower()
+
return self.TEXT % substitutions
def check_available(self, player):
def perform_action(self, board, location):
board.shift_locations(self.data['direction'])
+
+
+class AllowChessMove(LocationAction) :
+ TEXT = "Move like a %(chesspiece_name)s for one turn."
+
+ def perform_action(self, board, location):
+ if self.data['chesspiece'] in CHESS_PIECES:
+ chesspiece = CHESS_PIECES[self.data['chesspiece']]
+ board.allow_chess_move(chesspiece)