X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/balance2?a=blobdiff_plain;f=plomrogue%2Ftasks.py;h=9447cc6eecb2b8eb9135ec702a3426bdf8ad451e;hb=ba09978e0179406218f052ed29690f1f7c508920;hp=a5407f345867a7c5f8ad8cc2c632cdbc411d4cbc;hpb=8d0b5840b7df40ee883fdcf2fa1b4cd1d39e26fa;p=plomrogue2 diff --git a/plomrogue/tasks.py b/plomrogue/tasks.py index a5407f3..9447cc6 100644 --- a/plomrogue/tasks.py +++ b/plomrogue/tasks.py @@ -95,6 +95,8 @@ class Task_PICK_UP(Task): raise PlayError('cannot pick up oneself') elif to_pick_up.type_ == 'Player': raise PlayError('cannot pick up player') + elif to_pick_up.carried: + raise PlayError('thing already carried by a player') elif to_pick_up.position not in reach: raise PlayError('thing not in reach') elif not to_pick_up.portable: @@ -104,6 +106,7 @@ class Task_PICK_UP(Task): to_pick_up = self.thing.game.get_thing(self.args[0]) to_pick_up.position = self.thing.position[:] self.thing.carrying = to_pick_up + to_pick_up.carried = True @@ -119,27 +122,26 @@ class Task_DROP(Task): raise PlayError('cannot drop full bottle into bottle deposit') def do(self): - if self.thing.carrying.type_ == 'Bottle' and not self.thing.carrying.full: + dropped = self.thing.uncarry() + if dropped.type_ == 'Bottle' and not dropped.full: for t in [t for t in self.thing.game.things if t.type_ == 'BottleDeposit' and t.position == self.thing.position]: t.accept() - self.thing.game.remove_thing(self.thing.carrying) + self.thing.game.remove_thing(dropped) break - elif self.thing.carrying.type_ == 'Hat': + elif dropped.type_ == 'Hat': for t in [t for t in self.thing.game.things if t.type_ == 'HatRemixer' and t.position == self.thing.position]: - t.accept(self.thing.carrying) + t.accept(dropped) break - self.thing.carrying = None class Task_DOOR(Task): def do(self): - self.thing.carrying = None action_radius = list(self.thing.game.map_geometry. get_neighbors_yxyx(self.thing.position).values()) for t in [t for t in self.thing.game.things if @@ -208,8 +210,8 @@ class Task_INSTALL(Task): def do(self): if self.thing.carrying: - self.thing.carrying.install() - self.thing.carrying = None + t = self.thing.uncarry() + t.install() self.thing.send_msg('CHAT "You install the thing you carry."') else: self._get_uninstallables()[0].uninstall()