changeset 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 75783238f73d
children 5031b84fbb4c
files gamelib/scenes/machine.py gamelib/scenes/mess.py
diffstat 2 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/scenes/machine.py	Sat Aug 28 01:28:25 2010 +0200
+++ b/gamelib/scenes/machine.py	Sat Aug 28 01:28:51 2010 +0200
@@ -117,9 +117,6 @@
             return Result("With high-precision spitzensparken, the cans are welded into a replacement tube.",
                     soundfile='laser.ogg')
 
-    def interact_with_dented_can(self, item):
-        return self.interact_with_empty_can(item)
-
     def interact_with_empty_can(self, item):
         starting_cans = self.get_data('cans_in_place')
         if starting_cans < 3:
@@ -184,7 +181,7 @@
         return Result("It looks like it eats fingers. Perhaps a different approach is in order?")
 
     def interact_with_titanium_leg(self, item):
-        self.state.replace_inventory_item(item, self.state.items['machete'])
+        self.state.replace_inventory_item(item.name, 'machete')
         return Result("After much delicate grinding and a few close calls with"
                       " various body parts, the titanium femur now resembles"
                       " a machete more than a bone. Nice and sharp, too.",
--- 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")