comparison gamelib/scenes/engine.py @ 539:11530992924a

PEP8 clean-up for engine, machine and mess.
author Simon Cross <hodgestar+bzr@gmail.com>
date Sat, 11 Feb 2012 12:20:12 +0200
parents 0ce08d5e2acb
children 098ea4ea0d0d
comparison
equal deleted inserted replaced
538:d1b86d5849a0 539:11530992924a
16 FOLDER = "engine" 16 FOLDER = "engine"
17 BACKGROUND = "engine_room.png" 17 BACKGROUND = "engine_room.png"
18 18
19 INITIAL_DATA = { 19 INITIAL_DATA = {
20 'engine online': False, 20 'engine online': False,
21 'greet' : True, 21 'greet': True,
22 } 22 }
23 23
24 def __init__(self, state): 24 def __init__(self, state):
25 super(Engine, self).__init__(state) 25 super(Engine, self).__init__(state)
26 self.add_item(CanOpener('canopener')) 26 self.add_item(CanOpener('canopener'))
62 (377, 422, 19, 29), 62 (377, 422, 19, 29),
63 (239, 547, 123, 39), 63 (239, 547, 123, 39),
64 ) 64 )
65 )) 65 ))
66 self.add_thing(GenericDescThing('engine.empty_cans', 7, 66 self.add_thing(GenericDescThing('engine.empty_cans', 7,
67 "Empty chocolate-covered bacon cans? Poor guy, he must have found them irresistible.", 67 "Empty chocolate-covered bacon cans? Poor guy, he must have"
68 " found them irresistible.",
68 ( 69 (
69 (562, 422, 30, 31), 70 (562, 422, 30, 31),
70 ) 71 )
71 )) 72 ))
72 self.add_thing(GenericDescThing('engine.engines', 8, 73 self.add_thing(GenericDescThing('engine.engines', 8,
74 ( 75 (
75 (342, 261, 109, 81), 76 (342, 261, 109, 81),
76 ) 77 )
77 )) 78 ))
78 self.add_thing(GenericDescThing('engine.laser_cutter', 9, 79 self.add_thing(GenericDescThing('engine.laser_cutter', 9,
79 "A burned-out laser cutter. It may be responsible for the hole in the floor.", 80 "A burned-out laser cutter. It may be responsible for the"
81 " hole in the floor.",
80 ( 82 (
81 (120, 466, 115, 67), 83 (120, 466, 115, 67),
82 ) 84 )
83 )) 85 ))
84 self.add_thing(GenericDescThing('engine.fuel_lines', 10, 86 self.add_thing(GenericDescThing('engine.fuel_lines', 10,
100 (438, 217, 30, 11), 102 (438, 217, 30, 11),
101 (435, 225, 18, 15), 103 (435, 225, 18, 15),
102 ) 104 )
103 )) 105 ))
104 self.add_thing(GenericDescThing('engine.spare_fuel_line', 11, 106 self.add_thing(GenericDescThing('engine.spare_fuel_line', 11,
105 "The spare fuel line. If something went wrong with the main one, you would hook that one up.", 107 "The spare fuel line. If something went wrong with the main"
108 " one, you would hook that one up.",
106 ( 109 (
107 (512, 49, 68, 44), 110 (512, 49, 68, 44),
108 ) 111 )
109 )) 112 ))
110 self.add_thing(GenericDescThing('engine.danger_area', 12, 113 self.add_thing(GenericDescThing('engine.danger_area', 12,
126 and self.things['engine.superconductor'].get_data('working'): 129 and self.things['engine.superconductor'].get_data('working'):
127 self.set_data('engine online', True) 130 self.set_data('engine online', True)
128 self.remove_thing(self.things['engine.engines.8']) 131 self.remove_thing(self.things['engine.engines.8'])
129 self.add_thing(Engines()) 132 self.add_thing(Engines())
130 return make_jim_dialog("The engines are now operational. You have" 133 return make_jim_dialog("The engines are now operational. You have"
131 "done a satisfactory job, Prisoner %s." % PLAYER_ID, 134 "done a satisfactory job, Prisoner %s."
135 % PLAYER_ID,
132 self.state) 136 self.state)
133 137
134 def enter(self): 138 def enter(self):
135 if self.get_data('greet'): 139 if self.get_data('greet'):
136 self.set_data('greet', False) 140 self.set_data('greet', False)
137 return Result( 141 return Result(
138 "With your improvised helmet, the automatic airlock allows you into the engine room. Even if there wasn't a vacuum " 142 "With your improvised helmet, the automatic airlock allows"
143 " you into the engine room. Even if there wasn't a vacuum "
139 "it would be eerily quiet.") 144 "it would be eerily quiet.")
145
140 146
141 class Engines(Thing): 147 class Engines(Thing):
142 NAME = 'engine.engines' 148 NAME = 'engine.engines'
143 149
144 INTERACTS = { 150 INTERACTS = {
194 'working': False, 200 'working': False,
195 } 201 }
196 202
197 def get_description(self): 203 def get_description(self):
198 if self.get_data('present') and not self.get_data('working'): 204 if self.get_data('present') and not self.get_data('working'):
199 return "That superconductor looks burned out. It's wedged in there pretty firmly." 205 return ("That superconductor looks burned out. It's wedged"
206 " in there pretty firmly.")
200 elif not self.get_data('present'): 207 elif not self.get_data('present'):
201 return "An empty superconductor socket" 208 return "An empty superconductor socket"
202 else: 209 else:
203 return "A working superconductor." 210 return "A working superconductor."
204 211
205 def interact_without(self): 212 def interact_without(self):
206 if self.get_data('present') and not self.get_data('working'): 213 if self.get_data('present') and not self.get_data('working'):
207 return Result("It's wedged in there pretty firmly, it won't come out.") 214 return Result("It's wedged in there pretty firmly, it won't"
215 " come out.")
208 elif self.get_data('working'): 216 elif self.get_data('working'):
209 return Result("You decide that working engines are more important than having a shiny superconductor.") 217 return Result("You decide that working engines are more important"
218 " than having a shiny superconductor.")
210 219
211 def interact_with_machete(self, item): 220 def interact_with_machete(self, item):
212 if self.get_data('present') and not self.get_data('working'): 221 if self.get_data('present') and not self.get_data('working'):
213 self.set_interact('removed') 222 self.set_interact('removed')
214 self.set_data('present', False) 223 self.set_data('present', False)
215 return Result("With leverage, the burned-out superconductor snaps out. " 224 return Result("With leverage, the burned-out superconductor"
216 "You discard it.") 225 " snaps out. You discard it.")
217 226
218 def interact_with_superconductor(self, item): 227 def interact_with_superconductor(self, item):
219 if self.get_data('present'): 228 if self.get_data('present'):
220 return Result("It might help to remove the broken superconductor first") 229 return Result("It might help to remove the broken"
230 " superconductor first")
221 else: 231 else:
222 return Result("You plug in the superconductor, and feel a hum " 232 return Result("You plug in the superconductor, and feel a hum "
223 "as things kick into life. " 233 "as things kick into life. "
224 "Unfortunately, it's the wrong size for the socket " 234 "Unfortunately, it's the wrong size for the socket "
225 "and just falls out again when you let go.") 235 "and just falls out again when you let go.")
233 results = [Result("The chair's superconductor looks over-specced " 243 results = [Result("The chair's superconductor looks over-specced "
234 "for this job, but it should work.")] 244 "for this job, but it should work.")]
235 results.append(self.scene.engine_online_check()) 245 results.append(self.scene.engine_online_check())
236 return results 246 return results
237 else: 247 else:
238 return Result("It might help to remove the broken superconductor first.") 248 return Result("It might help to remove the broken superconductor"
249 " first.")
239 250
240 251
241 class CryoContainers(Thing): 252 class CryoContainers(Thing):
242 NAME = 'engine.cryo_containers' 253 NAME = 'engine.cryo_containers'
243 254
267 INTERACTS = { 278 INTERACTS = {
268 'containers': InteractRectUnion(( 279 'containers': InteractRectUnion((
269 (132, 250, 56, 28), 280 (132, 250, 56, 28),
270 (184, 258, 42, 30), 281 (184, 258, 42, 30),
271 (219, 267, 42, 24), 282 (219, 267, 42, 24),
272 )) 283 )),
273 } 284 }
274 285
275 INITIAL = 'containers' 286 INITIAL = 'containers'
276 287
277 def get_description(self): 288 def get_description(self):
377 INTERACTS = { 388 INTERACTS = {
378 'arrows': InteractAnimated(25, 324, ( 389 'arrows': InteractAnimated(25, 324, (
379 'arrow_top_left_1.png', 'arrow_top_left_2.png', 390 'arrow_top_left_1.png', 'arrow_top_left_2.png',
380 'arrow_top_left_3.png', 'arrow_top_left_4.png', 391 'arrow_top_left_3.png', 'arrow_top_left_4.png',
381 ), 15, 392 ), 15,
382 ) 393 ),
383 } 394 }
384 395
385 INITIAL = 'arrows' 396 INITIAL = 'arrows'
386 397
387 def is_interactive(self, tool=None): 398 def is_interactive(self, tool=None):
394 INTERACTS = { 405 INTERACTS = {
395 'arrows': InteractAnimated(32, 425, ( 406 'arrows': InteractAnimated(32, 425, (
396 'arrow_bottom_left_1.png', 'arrow_bottom_left_2.png', 407 'arrow_bottom_left_1.png', 'arrow_bottom_left_2.png',
397 'arrow_bottom_left_3.png', 'arrow_bottom_left_4.png', 408 'arrow_bottom_left_3.png', 'arrow_bottom_left_4.png',
398 ), 16, 409 ), 16,
399 ) 410 ),
400 } 411 }
401 412
402 INITIAL = 'arrows' 413 INITIAL = 'arrows'
403 414
404 def is_interactive(self, tool=None): 415 def is_interactive(self, tool=None):
411 INTERACTS = { 422 INTERACTS = {
412 'arrows': InteractAnimated(708, 172, ( 423 'arrows': InteractAnimated(708, 172, (
413 'arrow_right_1.png', 'arrow_right_2.png', 424 'arrow_right_1.png', 'arrow_right_2.png',
414 'arrow_right_3.png', 'arrow_right_4.png', 425 'arrow_right_3.png', 'arrow_right_4.png',
415 ), 17, 426 ), 17,
416 ) 427 ),
417 } 428 }
418 429
419 INITIAL = 'arrows' 430 INITIAL = 'arrows'
420 431
421 def is_interactive(self, tool=None): 432 def is_interactive(self, tool=None):
427 438
428 INTERACTS = { 439 INTERACTS = {
429 'sign': InteractAnimated(299, 341, ( 440 'sign': InteractAnimated(299, 341, (
430 'danger_dim.png', 'danger_bright.png', 441 'danger_dim.png', 'danger_bright.png',
431 ), 10, 442 ), 10,
432 ) 443 ),
433 } 444 }
434 445
435 INITIAL = 'sign' 446 INITIAL = 'sign'
436 447
437 def is_interactive(self, tool=None): 448 def is_interactive(self, tool=None):
441 class Stars(Thing): 452 class Stars(Thing):
442 NAME = 'engine.stars' 453 NAME = 'engine.stars'
443 454
444 INTERACTS = { 455 INTERACTS = {
445 'stars': InteractAnimated(287, 455, 456 'stars': InteractAnimated(287, 455,
446 ['stars_%d.png' % (i+1) for i in range(5) + range(3,0,-1)], 457 ['stars_%d.png' % (i + 1) for i
458 in range(5) + range(3, 0, -1)],
447 30, 459 30,
448 ) 460 ),
449 } 461 }
450 462
451 INITIAL = 'stars' 463 INITIAL = 'stars'
452 464
453 def is_interactive(self, tool=None): 465 def is_interactive(self, tool=None):
514 FOLDER = "engine" 526 FOLDER = "engine"
515 BACKGROUND = "engine_comp_detail.png" 527 BACKGROUND = "engine_comp_detail.png"
516 NAME = "engine_comp_detail" 528 NAME = "engine_comp_detail"
517 529
518 ALERTS = { 530 ALERTS = {
519 'cryo leaking' : 'ec_cryo_leaking.png', 531 'cryo leaking': 'ec_cryo_leaking.png',
520 'cryo empty' : 'ec_cryo_reservoir_empty.png', 532 'cryo empty': 'ec_cryo_reservoir_empty.png',
521 'super malfunction' : 'ec_cryo_super_malfunction.png', 533 'super malfunction': 'ec_cryo_super_malfunction.png',
522 } 534 }
523 535
524 # Point to start drawing changeable alerts 536 # Point to start drawing changeable alerts
525 ALERT_OFFSET = (16, 100) 537 ALERT_OFFSET = (16, 100)
526 ALERT_SPACING = 4 538 ALERT_SPACING = 4
532 for key, name in self.ALERTS.iteritems(): 544 for key, name in self.ALERTS.iteritems():
533 self._alert_messages[key] = get_image(self.FOLDER, name) 545 self._alert_messages[key] = get_image(self.FOLDER, name)
534 546
535 def _draw_alerts(self, surface): 547 def _draw_alerts(self, surface):
536 xpos, ypos = self.ALERT_OFFSET 548 xpos, ypos = self.ALERT_OFFSET
537 if not self.state.scenes['engine'].things['engine.cracked_pipe'].get_data('fixed'): 549 engine = self.state.scenes['engine']
550 if not engine.things['engine.cracked_pipe'].get_data('fixed'):
538 image = self._alert_messages['cryo leaking'] 551 image = self._alert_messages['cryo leaking']
539 surface.blit(image, (xpos, ypos)) 552 surface.blit(image, (xpos, ypos))
540 ypos += image.get_size()[1] + self.ALERT_SPACING 553 ypos += image.get_size()[1] + self.ALERT_SPACING
541 if not self.state.scenes['engine'].things['engine.cryo_containers'].get_data('filled'): 554 if not engine.things['engine.cryo_containers'].get_data('filled'):
542 image = self._alert_messages['cryo empty'] 555 image = self._alert_messages['cryo empty']
543 surface.blit(image, (xpos, ypos)) 556 surface.blit(image, (xpos, ypos))
544 ypos += image.get_size()[1] + self.ALERT_SPACING 557 ypos += image.get_size()[1] + self.ALERT_SPACING
545 if not self.state.scenes['engine'].things['engine.superconductor'].get_data('working'): 558 if not engine.things['engine.superconductor'].get_data('working'):
546 image = self._alert_messages['super malfunction'] 559 image = self._alert_messages['super malfunction']
547 surface.blit(image, (xpos, ypos)) 560 surface.blit(image, (xpos, ypos))
548 ypos += image.get_size()[1] + self.ALERT_SPACING 561 ypos += image.get_size()[1] + self.ALERT_SPACING
549 562
550 def draw_things(self, surface): 563 def draw_things(self, surface):