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:
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
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
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()
portable = False
protection = '.'
commandable = False
+ carried = False
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.game.sessions[c_id]['thing_id'] == self.id_:
self.game.io.send(msg, c_id)
break
+
+ def uncarry(self):
+ t = self.carrying
+ t.carried = False
+ self.carrying = None
+ return t