home · contact · privacy
Disallow picking up thing already carried by other player.
[plomrogue2] / plomrogue / tasks.py
index c7b35bd00b76bfa6ee0f3695f098c5e71b758fa3..9447cc6eecb2b8eb9135ec702a3426bdf8ad451e 100644 (file)
@@ -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,20 +122,20 @@ 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
 
 
 
@@ -207,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()