board.shift_locations(
self.data['direction'],
self.data.get('skip_current', True))
+ if self.data.get('move_player', False):
+ pos = {
+ 'NORTH': (0, -1), 'SOUTH': (0, 1),
+ 'EAST': (1, 0), 'WEST': (-1, 0),
+ }.get(self.data['direction'], (0, 0))
+ board.player.force_position(pos, delta=True)
class RotateLocations(LocationAction):
return True
return False
+ def force_position(self, pos, delta=True):
+ if delta:
+ pos = (self.position[0] + pos[0],
+ self.position[1] + pos[1])
+ if (0 <= pos[0] < 5 and 0 <= pos[1] < 5):
+ self.position = pos
+
def set_gameboard(self, gameboard):
self.gameboard = gameboard