diff gamelib/scenes/bridge.py @ 764:a8510f4e2ea1 pyntnclick

Conditionally add things based on state.
author Jeremy Thurgood <firxen@gmail.com>
date Sat, 26 Jan 2013 15:24:56 +0200
parents 386475464202
children a35f5364437d
line wrap: on
line diff
--- a/gamelib/scenes/bridge.py	Sat Jan 26 13:24:01 2013 +0200
+++ b/gamelib/scenes/bridge.py	Sat Jan 26 15:24:56 2013 +0200
@@ -8,9 +8,9 @@
 
 from pyntnclick.cursor import CursorSprite
 from pyntnclick.state import Scene, Item, Thing, Result
-from pyntnclick.scenewidgets import (InteractNoImage, InteractRectUnion,
-                                  InteractImage, InteractAnimated,
-                                  GenericDescThing)
+from pyntnclick.scenewidgets import (
+    InteractNoImage, InteractRectUnion, InteractImage, InteractAnimated,
+    GenericDescThing, TakeableThing)
 
 from gamelib.scenes.game_constants import PLAYER_ID
 from gamelib.scenes.game_widgets import Door, BaseCamera, make_jim_dialog
@@ -176,8 +176,8 @@
     CURSOR = CursorSprite('stethoscope.png')
 
 
-class StethoscopeThing(Thing):
-    "Stehoscope on the doctor"
+class StethoscopeThing(TakeableThing):
+    "Stethoscope on the doctor"
 
     NAME = 'bridge.stethoscope'
 
@@ -186,13 +186,13 @@
     }
 
     INITIAL = 'stethoscope'
+    ITEM = 'stethoscope'
 
     def get_description(self):
         return "A stethoscope hangs from the neck of the skeleton."
 
     def interact_without(self):
-        self.game.add_inventory_item('stethoscope')
-        self.scene.remove_thing(self)
+        self.take()
         # Fill in the doctor's rect
         self.scene.doctor.rect.append(self.rect)
         return Result("You pick up the stethoscope and verify that the"
@@ -221,7 +221,7 @@
                       " successfully avoid disaster.")
 
 
-class SuperconductorThing(Thing):
+class SuperconductorThing(TakeableThing):
     "Superconductor from the massage chair."
 
     NAME = 'bridge.superconductor'
@@ -231,12 +231,12 @@
     }
 
     INITIAL = 'superconductor'
+    ITEM = 'superconductor'
 
     def interact_without(self):
-        self.game.add_inventory_item('superconductor')
         self.game.scenes['bridge'].things['bridge.massagechair_base'] \
                           .set_data('contains_superconductor', False)
-        self.scene.remove_thing(self)
+        self.take()
         return (Result("The superconductor module unclips easily."),
                 make_jim_dialog(("Prisoner %s. That chair you've destroyed"
                                  " was property of the ship's captain. "