home · contact · privacy
Add PING.
[plomrogue2-experiments] / new2 / plomrogue / tasks.py
1 from plomrogue.errors import GameError
2 from plomrogue.mapping import YX
3
4
5
6 class Task:
7     argtypes = ''
8     todo = 3
9
10     def __init__(self, thing, args=()):
11         self.thing = thing
12         self.args = args
13
14     def check(self):
15         pass
16
17
18
19 class Task_WAIT(Task):
20     todo = 1
21
22     def do(self):
23         return 'success'
24
25
26
27 class Task_MOVE(Task):
28     todo = 1
29     argtypes = 'string:direction'
30
31     def get_move_target(self):
32         return self.thing.game.map_geometry.move(self.thing.position,
33                                                  self.args[0])
34
35     def check(self):
36         test_pos = self.get_move_target()
37         if test_pos is None:
38             raise GameError('would move out of map')
39
40     def do(self):
41         self.thing.position = self.get_move_target()
42
43
44
45 class Task_WRITE(Task):
46     todo = 1
47     argtypes = 'string:char'
48
49     def check(self):
50         pass
51
52     def do(self):
53         self.thing.game.map[self.thing.position] = self.args[0]