diff gamelib/scenes/mess.py @ 306:bd9a760eeb18

Hook up canopener. Fix for replace_inventory changes
author Neil Muller <neil@dip.sun.ac.za>
date Sat, 28 Aug 2010 01:28:51 +0200
parents 6d93e04036c9
children 1208bb5eaf6f
line wrap: on
line diff
--- a/gamelib/scenes/mess.py	Sat Aug 28 01:28:25 2010 +0200
+++ b/gamelib/scenes/mess.py	Sat Aug 28 01:28:51 2010 +0200
@@ -57,6 +57,12 @@
     def interact_with_machete(self, item, state):
         return Result("You'd mangle it beyond usefulness.")
 
+    def interact_with_canopener(self, item, state):
+        empty = EmptyCan('empty_can')
+        state.add_item(empty)
+        state.replace_inventory_item(self.name, empty.name)
+        return Result("You open both ends of the can, discarding the hideous contents.")
+
 
 class EmptyCan(BaseCan):
     "After emptying the full can."
@@ -67,6 +73,9 @@
     def interact_with_titanium_leg(self, item, state):
         return Result("Flattening the can doesn't look like a useful thing to do.")
 
+    def interact_with_canopener(self, item, state):
+        return Result("There's nothing left to open on this can")
+
 
 class FullCan(BaseCan):
     "Found on the shelf."
@@ -77,7 +86,7 @@
     def interact_with_titanium_leg(self, item, state):
         dented = DentedCan("dented_can")
         state.add_item(dented)
-        state.replace_inventory_item(self, dented)
+        state.replace_inventory_item(self.name, dented.name)
         return Result("You club the can with the femur. The can gets dented, but doesn't open.", soundfile="can_hit.ogg")