home · contact · privacy
Add BottleDeposit thing that spawns MusicPlayers for returned Bottles.
[plomrogue2] / plomrogue / tasks.py
index eca94003d6c8a5a52e3b6f15d13464f188c17d86..423758d8f5959ec7ebec088abfa18d7800d28bc1 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