comparison gamelib/scenes/cryo.py @ 78:6bfebfbce42e

Partial message support
author Neil Muller <neil@dip.sun.ac.za>
date Mon, 23 Aug 2010 23:05:55 +0200
parents 6b0f7364f3bf
children 593bddfacf18
comparison
equal deleted inserted replaced
77:bb7c8072f8c0 78:6bfebfbce42e
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 4
5 from gamelib.state import Scene, Item, Thing 5 from gamelib.state import Scene, Item, Thing, Result
6 6
7 7
8 class Cryo(Scene): 8 class Cryo(Scene):
9 9
10 FOLDER = "cryo" 10 FOLDER = "cryo"
43 INITIAL_DATA = { 43 INITIAL_DATA = {
44 'contains_titanium_leg': True, 44 'contains_titanium_leg': True,
45 } 45 }
46 46
47 def interact_without(self): 47 def interact_without(self):
48 self.message("The corpse in this cryo unit has a prosthetic leg made out of titanium. You take it.")
49 self.state.add_inventory_item('titanium_leg') 48 self.state.add_inventory_item('titanium_leg')
50 self.set_data('contains_titanium_leg', False) 49 self.set_data('contains_titanium_leg', False)
50 return Result("The corpse in this cryo unit has a prosthetic leg made out of titanium. You take it.")
51 51
52 def is_interactive(self): 52 def is_interactive(self):
53 return self.get_data('contains_titanium_leg') 53 return self.get_data('contains_titanium_leg')
54 54
55 55
62 INITIAL_DATA = { 62 INITIAL_DATA = {
63 'open': False, 63 'open': False,
64 } 64 }
65 65
66 def interact_with_titanium_leg(self, item): 66 def interact_with_titanium_leg(self, item):
67 self.message("You wedge the titanium leg into the chain and twist. With a satisfying *snap*, the chain breaks and the door opens.")
68 self.open_door() 67 self.open_door()
68 return Result("You wedge the titanium leg into the chain and twist. With a satisfying *snap*, the chain breaks and the door opens.")
69 69
70 def interact_without(self): 70 def interact_without(self):
71 self.message("It moves slightly and then stops. A chain on the other side is preventing it from opening completely.") 71 return Result("It moves slightly and then stops. A chain on the other side is preventing it from opening completely.")
72 72
73 def interact_default(self, item): 73 def interact_default(self, item):
74 self.message(random.choice([ 74 return Result(random.choice([
75 "Sadly, this isn't that sort of game.", 75 "Sadly, this isn't that sort of game.",
76 "Your valiant efforts are foiled by the Evil Game Designer.", 76 "Your valiant efforts are foiled by the Evil Game Designer.",
77 "The door resists. Try something else, perhaps?", 77 "The door resists. Try something else, perhaps?",
78 ])) 78 ]))
79 79