comparison gamelib/scenes/cryo.py @ 182:5cb3fbe61f75

Add genric thing with description helper class
author Neil Muller <neil@dip.sun.ac.za>
date Wed, 25 Aug 2010 15:45:45 +0200
parents 6b3ccee6f3f9
children 829551aad0f1
comparison
equal deleted inserted replaced
181:f98bc17f5e67 182:5cb3fbe61f75
1 """Cryo room where the prisoner starts out.""" 1 """Cryo room where the prisoner starts out."""
2 2
3 import random 3 import random
4 from albow.music import change_playlist, get_music, PlayList 4 from albow.music import change_playlist, get_music, PlayList
5 from pygame.colordict import THECOLORS
6 from pygame.color import Color
7 5
8 from gamelib import speech 6 from gamelib import speech
9 from gamelib.sound import get_sound 7 from gamelib.sound import get_sound
10 from gamelib.cursor import CursorSprite 8 from gamelib.cursor import CursorSprite
11 from gamelib.state import Scene, Item, Thing, Result, \ 9 from gamelib.state import Scene, Item, Thing, Result, \
12 InteractImage, InteractNoImage, InteractRectUnion, \ 10 InteractImage, InteractNoImage, InteractRectUnion, \
13 InteractAnimated 11 InteractAnimated
12 from gamelib.statehelpers import GenericDescThing
14 from gamelib.constants import DEBUG 13 from gamelib.constants import DEBUG
15 14
16 15
17 class Cryo(Scene): 16 class Cryo(Scene):
18 17
153 if self.get_data('contains_titanium_leg'): 152 if self.get_data('contains_titanium_leg'):
154 return "A broken cryo chamber, with a poor unfortunate corpse inside." 153 return "A broken cryo chamber, with a poor unfortunate corpse inside."
155 return "A broken cryo chamber. The corpse inside is missing a leg." 154 return "A broken cryo chamber. The corpse inside is missing a leg."
156 155
157 156
158 class GenericCryoUnit(Thing): 157 class GenericCryoUnit(GenericDescThing):
159 "Generic Cryo unit" 158 "Generic Cryo unit"
160 159
161 INITIAL = 'unit'
162
163 def __init__(self, number, description, detailed_description, areas): 160 def __init__(self, number, description, detailed_description, areas):
164 super(GenericCryoUnit, self).__init__() 161 super(GenericCryoUnit, self).__init__('cryo.unit', number, description, areas)
165 self.description = description
166 self.detailed_description = detailed_description 162 self.detailed_description = detailed_description
167 self.name = 'cryo.unit.%d' % number
168 self.interacts = {
169 'unit' : InteractRectUnion(areas)
170 }
171 if DEBUG:
172 # Individual colors to make debugging easier
173 self._interact_hilight_color = Color(THECOLORS.keys()[number])
174 163
175 def interact_without(self): 164 def interact_without(self):
176 return Result(self.detailed_description) 165 return Result(self.detailed_description)
177 166
178 def get_description(self): 167 def get_description(self):