changeset 837:bdebe693453f pyntnclick

Track total sentence
author Neil Muller <neil@dip.sun.ac.za>
date Tue, 29 Jan 2013 21:45:27 +0200
parents daecbd66d19c
children f12b187a3d5f
files TODO gamelib/scenes/crew_quarters.py gamelib/scenes/cryo.py gamelib/scenes/game_widgets.py gamelib/scenes/map.py gamelib/ss_state.py
diffstat 6 files changed, 23 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/TODO	Tue Jan 29 17:45:41 2013 +0200
+++ b/TODO	Tue Jan 29 21:45:27 2013 +0200
@@ -23,7 +23,6 @@
   * JIM Speaks after fixing engines & repairing environment?
 
 Game:
-  * Keep track of total sentence.
   * Add descriptions for items.
   * Add sound to more rooms.
 
--- a/gamelib/scenes/crew_quarters.py	Tue Jan 29 17:45:41 2013 +0200
+++ b/gamelib/scenes/crew_quarters.py	Tue Jan 29 21:45:27 2013 +0200
@@ -8,7 +8,8 @@
     TakeableThing)
 
 from gamelib.scenes.game_constants import PLAYER_ID
-from gamelib.scenes.game_widgets import Door, BaseCamera, make_jim_dialog
+from gamelib.scenes.game_widgets import (Door, BaseCamera, make_jim_dialog,
+        make_sentence_dialog)
 
 
 class CrewQuarters(Scene):
@@ -89,10 +90,10 @@
         if self.get_data('is_cracked'):
             return Result(_("It's already unlocked. "
                             "There's no more challenge."))
-        # TODO: Add years to the sentence for safecracking.
         # TODO: Wax lyrical some more about safecracking.
         self.set_data('is_cracked', True)
         self.set_interact()
+        self.state.increase_sentence(20)
         return (Result(_("Even after centuries of neglect, the tumblers slide"
                          " almost silently into place. Turns out the"
                          " combination was '1 2 3 4 5'. An idiot must keep his"
@@ -100,8 +101,9 @@
                 make_jim_dialog(_("Prisoner %s, you have been observed"
                                   " committing a felony violation. This will"
                                   " go onto your permanent record, and your"
-                                  " sentence may be extended by up to twenty"
-                                  " years.") % PLAYER_ID, self.game))
+                                  " sentence will be extended by twenty"
+                                  " years.") % PLAYER_ID, self.game),
+                make_sentence_dialog(PLAYER_ID, self.game))
 
     def get_description(self):
         return _("Ah, a vintage Knoxx & Co. model QR3. Quaint, but"
--- a/gamelib/scenes/cryo.py	Tue Jan 29 17:45:41 2013 +0200
+++ b/gamelib/scenes/cryo.py	Tue Jan 29 21:45:27 2013 +0200
@@ -22,6 +22,7 @@
     INITIAL_DATA = {
         'greet': True,
         'vandalism_warn': True,
+        'sentence': 30,
         }
 
     # sounds that will be played randomly as background noise
--- a/gamelib/scenes/game_widgets.py	Tue Jan 29 17:45:41 2013 +0200
+++ b/gamelib/scenes/game_widgets.py	Tue Jan 29 21:45:27 2013 +0200
@@ -39,6 +39,12 @@
         return None
 
 
+def make_sentence_dialog(prisoner, game):
+    return make_jim_dialog(
+            _("Prisoner %(id)s, your total sentence is now %(sen)d years.") % {
+                "id": prisoner, 'sen': game.data.get_total_sentence()}, game) 
+
+
 class BaseCamera(Thing):
     "Base class for the camera puzzles"
 
--- a/gamelib/scenes/map.py	Tue Jan 29 17:45:41 2013 +0200
+++ b/gamelib/scenes/map.py	Tue Jan 29 21:45:27 2013 +0200
@@ -13,7 +13,7 @@
         InteractText, InteractNoImage)
 
 from gamelib.scenes.game_constants import PLAYER_ID
-from gamelib.scenes.game_widgets import make_jim_dialog
+from gamelib.scenes.game_widgets import make_jim_dialog, make_sentence_dialog
 
 
 class Map(Scene):
@@ -44,11 +44,12 @@
                   "neural implant to help you navigate around the ship."),
                 self.game)
             if ai1:
+                self.state.increase_sentence(3)
                 return ai1, make_jim_dialog(_("Prisoner %s, you are 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,
-                self.game)
+                self.game), make_sentence_dialog(PLAYER_ID, self.game)
 
 
 class DoorThing(Thing):
--- a/gamelib/ss_state.py	Tue Jan 29 17:45:41 2013 +0200
+++ b/gamelib/ss_state.py	Tue Jan 29 21:45:27 2013 +0200
@@ -15,3 +15,10 @@
 
     def break_ai(self):
         self['bridge']['ai status'] = 'dead'
+
+    def get_total_sentence(self):
+        return self['cryo']['sentence']
+
+    def increase_sentence(self, years):
+        if self['bridge']['ai status'] == 'online':
+            self['cryo']['sentence'] += years