X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/cards/%7B%7Bcard_id%7D%7D/form?a=blobdiff_plain;f=plomrogue%2Ftasks.py;h=a6602cea926822ae8b7a58a4c7c50baad28f6e1b;hb=35714a1e0616ada0be5929d5fb8100047e46cdd2;hp=dbe23153f11d7ee842b04bca60ed694bab40f038;hpb=51addf32b5a876c47325fb55756aacaea65ed0da;p=plomrogue2 diff --git a/plomrogue/tasks.py b/plomrogue/tasks.py index dbe2315..a6602ce 100644 --- a/plomrogue/tasks.py +++ b/plomrogue/tasks.py @@ -76,7 +76,7 @@ class Task_FLATTEN_SURROUNDINGS(Task): class Task_PICK_UP(Task): - argtypes = 'int:nonneg' + argtypes = 'int:pos' def check(self): if self.thing.carrying: @@ -162,6 +162,7 @@ class Task_INTOXICATE(Task): self.thing.drunk = 10000 + class Task_COMMAND(Task): argtypes = 'string' @@ -177,3 +178,29 @@ class Task_COMMAND(Task): for c_id in self.thing.game.sessions: if self.thing.game.sessions[c_id]['thing_id'] == self.thing.id_: self.thing.game.io.send('REPLY ' + quote(reply), c_id) + + + +class Task_INSTALL(Task): + + def _get_uninstallables(self): + return [t for t in self.thing.game.things + if t != self.thing + and hasattr(t, 'installable') and t.installable + and (not t.portable) + and t.position == self.thing.position] + + def check(self): + if self.thing.carrying: + if not hasattr(self.thing.carrying, 'installable')\ + or not self.thing.carrying.installable: + raise PlayError('carried thing not installable') + elif len(self._get_uninstallables()) == 0: + raise PlayError('nothing to uninstall here') + + def do(self): + if self.thing.carrying: + self.thing.carrying.install() + self.thing.carrying = None + else: + self._get_uninstallables()[0].uninstall()