comparison gamelib/scenes/cryo.py @ 95:7590586180f5

door goes from shut to ajar to open
author Adrianna Pińska <adrianna.pinska@gmail.com>
date Tue, 24 Aug 2010 01:00:10 +0200
parents ce23fad8ecb3
children 0f799b6f40bc
comparison
equal deleted inserted replaced
94:ce23fad8ecb3 95:7590586180f5
53 } 53 }
54 54
55 def interact_without(self): 55 def interact_without(self):
56 self.state.add_inventory_item('titanium_leg') 56 self.state.add_inventory_item('titanium_leg')
57 self.set_data('contains_titanium_leg', False) 57 self.set_data('contains_titanium_leg', False)
58 return Result("The corpse in this cryo unit has a prosthetic leg made out of titanium. You take it.") 58 return Result("The skeletal occupant of this cryo unit has an artificial femur made of titanium. You take it.")
59 59
60 def is_interactive(self): 60 def is_interactive(self):
61 return self.get_data('contains_titanium_leg') 61 return self.get_data('contains_titanium_leg')
62 62
63 def get_description(self): 63 def get_description(self):
70 "Door to the cryo room." 70 "Door to the cryo room."
71 71
72 NAME = "cryo.door" 72 NAME = "cryo.door"
73 73
74 INTERACTS = { 74 INTERACTS = {
75 "shut": InteractNoImage(290, 260, 99, 152),
75 "ajar": InteractImage(290, 260, "door_ajar.png"), 76 "ajar": InteractImage(290, 260, "door_ajar.png"),
76 "open": InteractImage(290, 260, "door_open.png"), 77 "open": InteractImage(290, 260, "door_open.png"),
77 } 78 }
78 79
79 INITIAL = "ajar" 80 INITIAL = "shut"
80 81
81 INITIAL_DATA = { 82 INITIAL_DATA = {
82 'open': False, 83 'door': "shut",
83 } 84 }
84 85
85 def interact_with_titanium_leg(self, item): 86 def interact_with_titanium_leg(self, item):
86 self.open_door() 87 if self.get_data('door') == "ajar":
87 return Result("You wedge the titanium leg into the chain and twist. With a satisfying *snap*, the chain breaks and the door opens.") 88 self.open_door()
89 return Result("You wedge the titanium femur into the chain and twist. With a satisfying *snap*, the chain breaks and the door opens.")
90 else:
91 return Result("You bang on the door with the titanium femur. It makes a clanging sound.")
88 92
89 def interact_without(self): 93 def interact_without(self):
94 if self.get_data('door') == "shut":
95 self.half_open_door()
90 return Result("It moves slightly and then stops. A chain on the other side is preventing it from opening completely.") 96 return Result("It moves slightly and then stops. A chain on the other side is preventing it from opening completely.")
91 97
92 def interact_default(self, item): 98 def interact_default(self, item):
93 return Result(random.choice([ 99 return Result(random.choice([
94 "Sadly, this isn't that sort of game.", 100 "Sadly, this isn't that sort of game.",
95 "Your valiant efforts are foiled by the Evil Game Designer.", 101 "Your valiant efforts are foiled by the Evil Game Designer.",
96 "The door resists. Try something else, perhaps?", 102 "The door resists. Try something else, perhaps?",
97 ])) 103 ]))
98 104
99 def is_interactive(self): 105 def is_interactive(self):
100 return not self.get_data('open') 106 return self.get_data('door') != "open"
107
108 def half_open_door(self):
109 self.set_data('door', "ajar")
110 self.set_interact("ajar")
101 111
102 def open_door(self): 112 def open_door(self):
103 self.set_data('open', True) 113 self.set_data('door', "open")
104 self.set_interact("open") 114 self.set_interact("open")
105 self.state.scenes['bridge'].set_data('accessible', True) 115 self.state.scenes['bridge'].set_data('accessible', True)
106 self.state.remove_inventory_item('titanium_leg') 116 self.state.remove_inventory_item('titanium_leg')
107 117
108 def get_description(self): 118 def get_description(self):
109 if self.get_data('open'): 119 if self.get_data('door') == "open":
110 return 'An open doorway leads to the rest of the ship' 120 return 'An open doorway leads to the rest of the ship.'
111 return 'A rusty door. It is currently closed' 121 elif self.get_data('door') == "open":
122 return "A rusty door. It can't open all the way because of a chain on the other side."
123 return 'A rusty door. It is currently closed.'
112 124
113 125
114 class CryoComputer(Thing): 126 class CryoComputer(Thing):
115 "Computer in the cryo room." 127 "Computer in the cryo room."
116 128