comparison gamelib/scenes/engine.py @ 759:386475464202 pyntnclick

Inspect game state for Thing.set_interact() instead of setting it manually everywhere.
author Jeremy Thurgood <firxen@gmail.com>
date Sat, 26 Jan 2013 13:00:31 +0200
parents 2f74064bc779
children a8510f4e2ea1 43b49f1de828
comparison
equal deleted inserted replaced
758:f4853f817a7a 759:386475464202
205 elif not self.get_data('present'): 205 elif not self.get_data('present'):
206 return "An empty superconductor socket" 206 return "An empty superconductor socket"
207 else: 207 else:
208 return "A working superconductor." 208 return "A working superconductor."
209 209
210 def select_interact(self):
211 if not self.get_data('present'):
212 return 'removed'
213 if self.get_data('working'):
214 return 'fixed'
215 return self.INITIAL
216
210 def interact_without(self): 217 def interact_without(self):
211 if self.get_data('present') and not self.get_data('working'): 218 if self.get_data('present') and not self.get_data('working'):
212 return Result("It's wedged in there pretty firmly, it won't" 219 return Result("It's wedged in there pretty firmly, it won't"
213 " come out.") 220 " come out.")
214 elif self.get_data('working'): 221 elif self.get_data('working'):
215 return Result("You decide that working engines are more important" 222 return Result("You decide that working engines are more important"
216 " than having a shiny superconductor.") 223 " than having a shiny superconductor.")
217 224
218 def interact_with_machete(self, item): 225 def interact_with_machete(self, item):
219 if self.get_data('present') and not self.get_data('working'): 226 if self.get_data('present') and not self.get_data('working'):
220 self.set_interact('removed')
221 self.set_data('present', False) 227 self.set_data('present', False)
228 self.set_interact()
222 return Result("With leverage, the burned-out superconductor" 229 return Result("With leverage, the burned-out superconductor"
223 " snaps out. You discard it.") 230 " snaps out. You discard it.")
224 231
225 def interact_with_superconductor(self, item): 232 def interact_with_superconductor(self, item):
226 if self.get_data('present'): 233 if self.get_data('present'):
232 "Unfortunately, it's the wrong size for the socket " 239 "Unfortunately, it's the wrong size for the socket "
233 "and just falls out again when you let go.") 240 "and just falls out again when you let go.")
234 241
235 def interact_with_taped_superconductor(self, item): 242 def interact_with_taped_superconductor(self, item):
236 if not self.get_data('present'): 243 if not self.get_data('present'):
237 self.set_interact('fixed')
238 self.set_data('present', True) 244 self.set_data('present', True)
239 self.set_data('working', True) 245 self.set_data('working', True)
246 self.set_interact()
240 self.game.remove_inventory_item(item.name) 247 self.game.remove_inventory_item(item.name)
241 results = [Result("The chair's superconductor looks over-specced " 248 results = [Result("The chair's superconductor looks over-specced "
242 "for this job, but it should work.")] 249 "for this job, but it should work.")]
243 results.append(self.scene.engine_online_check()) 250 results.append(self.scene.engine_online_check())
244 return results 251 return results
259 266
260 INITIAL_DATA = { 267 INITIAL_DATA = {
261 'filled': False, 268 'filled': False,
262 } 269 }
263 270
271 def select_interact(self):
272 if self.get_data('filled'):
273 return 'full'
274 return self.INITIAL
275
264 def get_description(self): 276 def get_description(self):
265 if not self.get_data('filled'): 277 if not self.get_data('filled'):
266 return "Those are coolant reservoirs. They look empty." 278 return "Those are coolant reservoirs. They look empty."
267 return "The coolant reservoirs are full." 279 return "The coolant reservoirs are full."
268 280
294 if not self.scene.things['engine.cracked_pipe'].get_data('fixed'): 306 if not self.scene.things['engine.cracked_pipe'].get_data('fixed'):
295 return Result("Pouring the precious cryo fluid into a" 307 return Result("Pouring the precious cryo fluid into a"
296 " container connected to a cracked pipe would be a waste.") 308 " container connected to a cracked pipe would be a waste.")
297 self.game.remove_inventory_item(item.name) 309 self.game.remove_inventory_item(item.name)
298 self.scene.things['engine.cryo_containers'].set_data('filled', True) 310 self.scene.things['engine.cryo_containers'].set_data('filled', True)
299 self.scene.things['engine.cryo_containers'].set_interact('full') 311 self.scene.things['engine.cryo_containers'].set_interact()
300 results = [Result("You fill the reservoirs. " 312 results = [Result("You fill the reservoirs. "
301 "The detergent bottle was just big enough, which " 313 "The detergent bottle was just big enough, which "
302 "is handy, because it's sprung a leak.")] 314 "is handy, because it's sprung a leak.")]
303 results.append(self.scene.engine_online_check()) 315 results.append(self.scene.engine_online_check())
304 return results 316 return results
487 return "The duct tape appears to be holding." 499 return "The duct tape appears to be holding."
488 else: 500 else:
489 return "The pipe looks cracked and won't hold" \ 501 return "The pipe looks cracked and won't hold" \
490 " fluid until it's fixed." 502 " fluid until it's fixed."
491 503
504 def select_interact(self):
505 if self.get_data('fixed'):
506 return 'taped'
507 return self.INITIAL
508
492 def interact_with_duct_tape(self, item): 509 def interact_with_duct_tape(self, item):
493 if self.get_data('fixed'): 510 if self.get_data('fixed'):
494 return Result("The duct tape already there appears to be " 511 return Result("The duct tape already there appears to be "
495 "sufficient.") 512 "sufficient.")
496 else: 513 else:
497 self.set_data('fixed', True) 514 self.set_data('fixed', True)
498 self.set_interact('taped') 515 self.set_interact()
499 return Result("You apply your trusty duct tape to the " 516 return Result("You apply your trusty duct tape to the "
500 "creak, sealing it.") 517 "creak, sealing it.")
501 518
502 519
503 class ComputerConsole(Thing): 520 class ComputerConsole(Thing):