home · contact · privacy
Add hat spinning.
[plomrogue2] / plomrogue / tasks.py
index d8d118a78108eb9fce1cad108816ac8509c8dd94..841a0e663d0f343542dd7e0dd96476f37a5151e3 100644 (file)
@@ -1,4 +1,5 @@
 from plomrogue.errors import PlayError, GameError
+from plomrogue.misc import quote
 
 
 
@@ -190,7 +191,6 @@ class Task_COMMAND(Task):
             raise PlayError('cannot command this item type')
 
     def do(self):
-        from plomrogue.misc import quote
         reply_lines = self.thing.carrying.interpret(self.args[0])
         for line in reply_lines:
             self.thing.send_msg('REPLY ' + quote(line))
@@ -234,8 +234,8 @@ class Task_WEAR(Task):
             raise PlayError('carrying nothing to wear')
         if self.thing.name in self.thing.game.hats:
             raise PlayError('already wearing a hat')
-        if self.thing.carrying.type_ != 'Hat':
-            raise PlayError('can only wear a hat')
+        if self.thing.carrying.type_ not in {'Hat', 'Bottle'}:
+            raise PlayError('can not wear the kind of thing you hold')
 
     def do(self):
         if self.thing.name in self.thing.game.hats:
@@ -249,8 +249,27 @@ class Task_WEAR(Task):
                 remixer.accept(t)
                 break
         else:
-            from plomrogue.misc import quote
-            self.thing.game.hats[self.thing.name] = self.thing.carrying.design
+            if self.thing.carrying.type_ == 'Bottle':
+                self.thing.send_msg('CHAT "Your attempt to wear a bottle on '
+                                    'your head fails."')
+                self.thing.carrying.sound('BOTTLE', 'SMASH')
+            elif self.thing.carrying.type_ == 'Hat':
+                self.thing.game.hats[self.thing.name] =\
+                    self.thing.carrying.design
+                self.thing.send_msg('CHAT "You put on a hat."')
             self.thing.game.remove_thing(self.thing.carrying)
             self.thing.carrying = None
-            self.thing.send_msg('CHAT "You put on a hat."')
+
+
+
+class Task_SPIN(Task):
+
+    def check(self):
+        if not self.thing.carrying:
+            raise PlayError('holding nothing to spin')
+        if not hasattr(self.thing.carrying, 'spinnable'):
+            raise PlayError('held object not spinnable')
+
+    def do(self):
+        self.thing.carrying.spin()
+        self.thing.send_msg('CHAT "You spin this object."')