changeset 360:452230d78541

Use make_jim_dialog everywhere
author Neil Muller <neil@dip.sun.ac.za>
date Sat, 28 Aug 2010 16:51:40 +0200
parents 6b94f549443b
children 9d97d2e338db
files gamelib/scenes/bridge.py gamelib/scenes/crew_quarters.py gamelib/scenes/cryo.py gamelib/scenes/map.py gamelib/scenes/scene_widgets.py
diffstat 5 files changed, 36 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/scenes/bridge.py	Sat Aug 28 16:36:38 2010 +0200
+++ b/gamelib/scenes/bridge.py	Sat Aug 28 16:51:40 2010 +0200
@@ -13,7 +13,7 @@
 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage,
                                           InteractRectUnion, InteractImage,
                                           InteractAnimated, GenericDescThing,
-                                          BaseCamera)
+                                          BaseCamera, make_jim_dialog)
 
 
 class Bridge(Scene):
@@ -302,8 +302,8 @@
     def interact_default(self):
         if self.scene.get_data('ai status') == 'online':
             return (Result('You feel a shock from the panel'),
-                    Result("JIM says: 'Prisoner %s. Please step away from the panel. "
-                        "You are not an authorized techinican.'" % PLAYER_ID, style="JIM"))
+                    make_jim_dialog("Prisoner %s. Please step away from the panel. "
+                        "You are not an authorized techinican." % PLAYER_ID, self.state))
 
 class ChairDetail(Scene):
 
--- a/gamelib/scenes/crew_quarters.py	Sat Aug 28 16:36:38 2010 +0200
+++ b/gamelib/scenes/crew_quarters.py	Sat Aug 28 16:51:40 2010 +0200
@@ -7,7 +7,7 @@
 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage,
                                           InteractRectUnion, InteractImage,
                                           InteractAnimated, GenericDescThing,
-                                          BaseCamera)
+                                          BaseCamera, make_jim_dialog)
 
 class CrewQuarters(Scene):
 
@@ -91,12 +91,12 @@
                       " almost silently into place. Turns out the combination"
                       " was '1 2 3 4 5'. An idiot must keep his luggage in"
                       " here.")
-        if self.state.scenes['bridge'].get_data('ai status') == 'online':
-            return open_result, Result("JIM says: 'Prisoner %s, you have been observed commiting a felony violation. "
+        ai_result = make_jim_dialog("Prisoner %s, you have been observed commiting a felony violation. "
                     "This will go onto your permenant record, and your sentence may be extended by up to twenty years."
-                    % PLAYER_ID, style="JIM")
-        else:
-            return open_result
+                    % PLAYER_ID, self.state)
+        if ai_result:
+            return open_result, ai_result
+        return open_result
 
     def get_description(self):
         return "Ah, a vintage Knoxx & Co. model QR3. Quaint, but reasonably secure."
--- a/gamelib/scenes/cryo.py	Sat Aug 28 16:36:38 2010 +0200
+++ b/gamelib/scenes/cryo.py	Sat Aug 28 16:51:40 2010 +0200
@@ -11,7 +11,8 @@
 from gamelib.scenes.game_constants import PLAYER_ID
 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage,
                                           InteractRectUnion, InteractImage,
-                                          InteractAnimated, GenericDescThing)
+                                          InteractAnimated, GenericDescThing,
+                                          make_jim_dialog)
 
 
 class Cryo(Scene):
@@ -133,15 +134,15 @@
         change_playlist(background_playlist)
         if self.get_data('greet'):
             self.set_data('greet', False)
-            return Result(
-                    "You hear a voice: 'Greetings, Prisoner %s. "
-                    "This is the Judicial Incarceration Monitor. "
+            return make_jim_dialog(
+                    "Greetings, Prisoner %s.  This is the Judicial "
+                    "Incarceration Monitor. "
                     "You have been woken early under the terms of the "
                     "emergency conscription act to help with repairs to "
                     "the ship. Your behaviour during this time will "
                     "be added to your record and will be relayed to "
                     "prison officials when we reach the destination. "
-                    "Please report to the bridge.'" % PLAYER_ID, style="JIM")
+                    "Please report to the bridge.'" % PLAYER_ID, self.state)
 
     def leave(self):
         # Stop music
--- a/gamelib/scenes/map.py	Sat Aug 28 16:36:38 2010 +0200
+++ b/gamelib/scenes/map.py	Sat Aug 28 16:51:40 2010 +0200
@@ -11,7 +11,8 @@
 from gamelib.scenes.game_constants import PLAYER_ID
 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage,
                                           InteractRectUnion, InteractImage,
-                                          InteractAnimated, GenericDescThing)
+                                          InteractAnimated, GenericDescThing,
+                                          make_jim_dialog)
 
 
 class Map(Scene):
@@ -38,17 +39,16 @@
             door_thing.check_dest()
         if self.get_data('implant'):
             self.set_data('implant', False)
-            return (Result(
-                "JIM says: 'Under the terms of the emergency conscription "
+            ai1 = make_jim_dialog(
+                "Under the terms of the emergency conscription "
                 "act, I have downloaded the ship's schematics to your "
                 "neural implant to help you navigate around the ship. "
-                "Please report to the bridge.'", style="JIM"),
-                Result(
-                "JIM continues: 'Prisoner %s. You are classed "
+                "Please report to the bridge.", self.state)
+            if ai1:
+                return ai1, make_jim_dialog("Prisoner %s. You are classed "
                 "as a class 1 felon. Obtaining access to the ship's schematics "
                 "constitutes a level 2 offence and carries a minimal penalty "
-                "of an additional 3 years on your sentence.'" % PLAYER_ID,
-                style="JIM"))
+                "of an additional 3 years on your sentence.'" % PLAYER_ID, self.state)
 
 
 class DoorThing(Thing):
--- a/gamelib/scenes/scene_widgets.py	Sat Aug 28 16:36:38 2010 +0200
+++ b/gamelib/scenes/scene_widgets.py	Sat Aug 28 16:51:40 2010 +0200
@@ -177,6 +177,15 @@
             "Waving that in the doorway does nothing. Try something else, perhaps?",
             ]))
 
+
+def make_jim_dialog(mesg, state):
+    "Utility helper function"
+    if state.scenes['bridge'].get_data('ai status') == 'online':
+        return Result(mesg, style='JIM')
+    else:
+        return None
+
+
 class BaseCamera(Thing):
    "Base class for the camera puzzles"
 
@@ -186,6 +195,9 @@
        return "A security camera watches over the room"
 
    def interact_with_escher_poster(self, item):
+       # Order matters here, because of helper function
+       ai_response = make_jim_dialog("3D scene reconstruction failed. Critical error. Entering emergency shutdown.", self.state)
        self.state.scenes['bridge'].set_data('ai status', 'looping')
-       return Result("JIM says '3D scene reconstruction failed. Critical error. Entering emergency shutdown.", style="JIM")
+       return ai_response
 
+