changeset 226:a5325919342e

Tubes, pipes and ducts.
author Jeremy Thurgood <firxen@gmail.com>
date Thu, 26 Aug 2010 22:48:03 +0200
parents c2660c045041
children be4ac4418aa2
files gamelib/scenes/cryo.py gamelib/scenes/machine.py gamelib/scenes/mess.py gamelib/state.py
diffstat 4 files changed, 61 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/scenes/cryo.py	Thu Aug 26 22:38:17 2010 +0200
+++ b/gamelib/scenes/cryo.py	Thu Aug 26 22:48:03 2010 +0200
@@ -178,6 +178,7 @@
 
     INVENTORY_IMAGE = "triangle.png"
     CURSOR = CursorSprite('triangle.png', 20, 30)
+    TOOL_NAME = "pipe"
 
 
 class CryoPipeLeft(CryoPipeBase):
--- a/gamelib/scenes/machine.py	Thu Aug 26 22:38:17 2010 +0200
+++ b/gamelib/scenes/machine.py	Thu Aug 26 22:48:03 2010 +0200
@@ -95,6 +95,14 @@
         return msg
 
 
+class TinPipe(Item):
+    "A pipe made out of welded-together tins."
+
+    INVENTORY_IMAGE = "tube_fragments.png"
+    CURSOR = CursorSprite('tube_fragments_cursor.png', 36, 3)
+    TOOL_NAME = "pipe"
+
+
 class Grinder(Thing):
 
     NAME = "machine.grinder"
--- a/gamelib/scenes/mess.py	Thu Aug 26 22:38:17 2010 +0200
+++ b/gamelib/scenes/mess.py	Thu Aug 26 22:48:03 2010 +0200
@@ -17,8 +17,6 @@
 
     def __init__(self, state):
         super(Mess, self).__init__(state)
-        self.add_item(TubeFragments("tube_fragments"))
-        self.add_item(ReplacementTubes("replacement_tubes"))
         self.add_thing(CansOnShelf())
         self.add_thing(Tubes())
         self.add_thing(ToMap())
@@ -46,7 +44,6 @@
     INVENTORY_IMAGE = "empty_can.png"
     CURSOR = CursorSprite('empty_can_cursor.png', 20, 30)
 
-
     def interact_with_titanium_leg(self, item, state):
         return Result("Flattening the can doesn't look like a useful thing to do")
 
@@ -74,20 +71,6 @@
         return Result("You club the can with the femur. The dents shift around, but it still doesn't open.", soundfile="can_hit.ogg")
 
 
-class TubeFragments(Item):
-    "Old tubes that need repair."
-
-    INVENTORY_IMAGE = "tube_fragments.png"
-    CURSOR = CursorSprite('tube_fragments_cursor.png', 36, 3)
-
-
-class ReplacementTubes(Item):
-    "Repaired tubes."
-
-    INVENTORY_IMAGE = "replacement_tubes.png"
-    CURSOR = CursorSprite('replacement_tubes.png', 53, 46)
-
-
 class CansOnShelf(Thing):
 
     NAME = "mess.cans"
@@ -137,6 +120,52 @@
 
     INITIAL = "blocked"
 
+    INITIAL_DATA = {
+        "status": "blocked",
+        "pipes_replaced": 0,
+        "fixed": False,
+        }
+
+    def interact_with_machete(self, item):
+        if self.get_data("status") == "blocked":
+            self.set_data("status", "broken")
+            self.set_interact("broken")
+            return Result("With a flurry of disgusting mutant vegetable chunks,"
+                          " you clear the overgrown broccoli away from the access"
+                          " panel and reveal some broken tubes. They look important.")
+        elif self.get_data("status") == "broken":
+            return Result("It looks broken enough already.")
+        else:
+            return Return("After all that effort fixing it, chopping it to bits doesn't seem very smart.")
+
+    def interact_with_pipe(self, item):
+        if self.get_data("status") == "blocked":
+            return Result("It would get lost in the fronds.")
+        else:
+            self.data['pipes_replaced'] += 1
+            self.state.remove_inventory_item(item.name)
+            return Result({
+                    1: "The pipe slots neatly into place, but doesn't make an airtight seal.",
+                    2: "This pipe is a little looser than the first. It definitely needs to be taped up.",
+                    3: "The final pipe fits snugly, but won't hold under pressure.",
+                    }[self.get_data('pipes_replaced')])
+
+    def interact_with_duct_tape(self, item):
+        if self.get_data("status") == "broken":
+            return Result("It would get lost in the fronds.")
+        elif self.get_data("fixed"):
+            return Result("There's quite enough tape on the ducting already.")
+        elif self.get_data("pipes_replaced") < 3:
+            return Result("All the pipes need to be in place before they can be taped up.")
+        else:
+            self.set_data("fixed", True)
+            self.set_data("status", "fixed")
+            self.set_interact("fixed")
+            # TODO: A less anticlimactic climax?
+            return Result("It takes quite a lot of tape, but eventually everything is"
+                          " airtight and ready to hold pressure. Who'd've thought duct"
+                          " tape could actually be used to tape ducts?")
+
 
 class ToMap(Thing):
     "Way to map."
--- a/gamelib/state.py	Thu Aug 26 22:38:17 2010 +0200
+++ b/gamelib/state.py	Thu Aug 26 22:48:03 2010 +0200
@@ -562,9 +562,13 @@
     # image for inventory
     INVENTORY_IMAGE = None
 
+    TOOL_NAME = None
+
     def __init__(self, name):
         self.name = name
         self.tool_name = name
+        if self.TOOL_NAME is not None:
+            self.tool_name = self.TOOL_NAME
         self.inventory_image = get_image('items', self.INVENTORY_IMAGE)
         # TODO: needs cursor
 
@@ -593,3 +597,5 @@
         CloneableItem._counter += 1
         super(CloneableItem, self).__init__("%s.%s" % (name, my_count))
         self.tool_name = name
+        if self.TOOL_NAME is not None:
+            self.tool_name = self.TOOL_NAME