From: Christian Heller Date: Thu, 24 Aug 2017 22:39:09 +0000 (+0200) Subject: Add basic movement AI test, extend move command directions. X-Git-Url: https://plomlompom.com/repos/task?a=commitdiff_plain;h=e2cfe7d89a649ac44c840b747804a818895373be;p=plomrogue2-experiments Add basic movement AI test, extend move command directions. --- diff --git a/server.py b/server.py index e8bca6a..aa8b1c3 100755 --- a/server.py +++ b/server.py @@ -103,9 +103,18 @@ class Thing: self.position[0] -= 1 elif direction == 'DOWN': self.position[0] += 1 + elif direction == 'RIGHT': + self.position[1] += 1 + elif direction == 'LEFT': + self.position[1] -= 1 def decide_task(self): - self.set_task('wait') + if self.position[1] > 1: + self.set_task('move', 'LEFT') + elif self.position[1] < 3: + self.set_task('move', 'RIGHT') + else: + self.set_task('wait') def set_task(self, task, *args, **kwargs): self.task = Task(task, args, kwargs) @@ -258,8 +267,9 @@ class CommandHandler: def cmd_move(self, direction, connection_id): """Set player task to 'move' with direction arg, finish player turn.""" - if not direction in {'UP', 'DOWN'}: - raise ArgumentError('MOVE ARGUMENT MUST BE "UP" or "DOWN"') + if not direction in {'UP', 'DOWN', 'RIGHT', 'LEFT'}: + raise ArgumentError('MOVE ARGUMENT MUST BE ONE OF: ' + 'UP, DOWN, RIGHT, LEFT') self.world.player.set_task('move', direction=direction) self.proceed_to_next_player_turn(connection_id)