X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Factions.py;h=f92961cd4bdfc38e61d8e5eb33b521aa55446d11;hb=aac1783aa9c84031bb37d74616ee72a7b32ebeac;hp=0535c8be1b37964d752773636d2538c877adc78b;hpb=d2d864e01ddcf38536812f37b8bffb3ee3227d4f;p=naja.git diff --git a/naja/actions.py b/naja/actions.py index 0535c8b..f92961c 100644 --- a/naja/actions.py +++ b/naja/actions.py @@ -1,4 +1,4 @@ -from naja.constants import BITS +from naja.constants import BITS, CHESS_PIECES class LocationAction(object): @@ -15,6 +15,7 @@ class LocationAction(object): def get_text(self): substitutions = self.data.copy() + if 'direction' in self.data: substitutions['rowcol'] = { 'NORTH': 'column', @@ -22,6 +23,10 @@ class LocationAction(object): '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): @@ -108,3 +113,12 @@ class ShiftLocations(LocationAction): 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)