1 from server_.game_error import GameError
7 def __init__(self, task_classes):
8 self.task_classes = task_classes
10 def get_task_class(self, task_name):
11 for task_class in self.task_classes:
12 if task_class.__name__ == 'Task_' + task_name:
20 def __init__(self, thing, args=()):
28 class_name = self.__class__.__name__
29 return class_name[len(prefix):]
34 def get_args_string(self):
38 stringed_args += [server_.io.quote(arg)]
40 raise GameError('stringifying arg type not implemented')
41 return ' '.join(stringed_args)
45 class Task_WAIT(Task):
52 class Task_MOVE(Task):
53 argtypes = 'string:direction'
56 test_pos = self.thing.world.map_.move(self.thing.position, self.args[0])
57 if self.thing.world.map_[test_pos] != '.':
58 raise GameError('%s would move into illegal terrain' % self.thing.id_)
59 for t in self.thing.world.things:
60 if t.position == test_pos:
61 raise GameError('%s would move into other thing' % self.thing.id_)
64 self.thing.position = self.thing.world.map_.move(self.thing.position,
69 task_manager = TaskManager((Task_WAIT, Task_MOVE))