home · contact · privacy
Record ideas for optimizing Dijkstra mapping.
[plomrogue2] / plomrogue / tasks.py
index eca94003d6c8a5a52e3b6f15d13464f188c17d86..8fa3a178067bf4864f929638b79d5a8e4d8bb6d2 100644 (file)
@@ -103,8 +103,20 @@ class Task_DROP(Task):
     def check(self):
         if not self.thing.carrying:
             raise PlayError('nothing to drop')
+        if self.thing.carrying.type_ == 'Bottle' and self.thing.carrying.full:
+            for t in [t for t in self.thing.game.things
+                      if t.type_ == 'BottleDeposit'
+                      and t.position == self.thing.position]:
+                raise PlayError('cannot drop full bottle into bottle deposit')
 
     def do(self):
+        if self.thing.carrying.type_ == 'Bottle' and not self.thing.carrying.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.things.remove(self.thing.carrying)
+                break
         self.thing.carrying = None
 
 
@@ -136,6 +148,7 @@ class Task_INTOXICATE(Task):
 
     def do(self):
         self.thing.carrying.full = False
+        self.thing.carrying.empty()
         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('RANDOM_COLORS', c_id)