comparison gamelib/scenes/mess.py @ 603:3ce19d33b51f pyntnclick

Rename state to game to not cause confusion with the other state
author Neil Muller <neil@dip.sun.ac.za>
date Sat, 11 Feb 2012 20:09:47 +0200
parents 4e9178215e75
children f703bdce8c9e
comparison
equal deleted inserted replaced
602:1aac5a3b17e1 603:3ce19d33b51f
61 def interact_with_machete(self, item): 61 def interact_with_machete(self, item):
62 return Result("You'd mangle it beyond usefulness.") 62 return Result("You'd mangle it beyond usefulness.")
63 63
64 def interact_with_canopener(self, item): 64 def interact_with_canopener(self, item):
65 empty = EmptyCan('empty_can') 65 empty = EmptyCan('empty_can')
66 self.state.add_item(empty) 66 self.game.add_item(empty)
67 self.state.replace_inventory_item(self.name, empty.name) 67 self.game.replace_inventory_item(self.name, empty.name)
68 return Result("You open both ends of the can, discarding the" 68 return Result("You open both ends of the can, discarding the"
69 " hideous contents.") 69 " hideous contents.")
70 70
71 71
72 class EmptyCan(BaseCan): 72 class EmptyCan(BaseCan):
89 INVENTORY_IMAGE = "full_can.png" 89 INVENTORY_IMAGE = "full_can.png"
90 CURSOR = CursorSprite('full_can_cursor.png') 90 CURSOR = CursorSprite('full_can_cursor.png')
91 91
92 def interact_with_titanium_leg(self, item): 92 def interact_with_titanium_leg(self, item):
93 dented = DentedCan("dented_can") 93 dented = DentedCan("dented_can")
94 self.state.add_item(dented) 94 self.game.add_item(dented)
95 self.state.replace_inventory_item(self.name, dented.name) 95 self.game.replace_inventory_item(self.name, dented.name)
96 return Result("You club the can with the femur. The can gets dented," 96 return Result("You club the can with the femur. The can gets dented,"
97 " but doesn't open.", soundfile="can_hit.ogg") 97 " but doesn't open.", soundfile="can_hit.ogg")
98 98
99 99
100 class DentedCan(BaseCan): 100 class DentedCan(BaseCan):
128 128
129 def interact_without(self): 129 def interact_without(self):
130 starting_cans = self.get_data('cans_available') 130 starting_cans = self.get_data('cans_available')
131 if starting_cans > 0: 131 if starting_cans > 0:
132 can = FullCan("full_can") 132 can = FullCan("full_can")
133 self.state.add_item(can) 133 self.game.add_item(can)
134 self.state.add_inventory_item(can.name) 134 self.game.add_inventory_item(can.name)
135 self.set_data('cans_available', starting_cans - 1) 135 self.set_data('cans_available', starting_cans - 1)
136 self.set_interact('%icans' % (starting_cans - 1)) 136 self.set_interact('%icans' % (starting_cans - 1))
137 if starting_cans == 1: 137 if starting_cans == 1:
138 self.scene.remove_thing(self) 138 self.scene.remove_thing(self)
139 return Result({ 139 return Result({
197 197
198 def interact_with_cryo_pipes_three(self, item): 198 def interact_with_cryo_pipes_three(self, item):
199 if self.get_data("status") == "blocked": 199 if self.get_data("status") == "blocked":
200 return Result("It would get lost in the fronds.") 200 return Result("It would get lost in the fronds.")
201 else: 201 else:
202 self.state.remove_inventory_item(item.name) 202 self.game.remove_inventory_item(item.name)
203 self.set_data('status', 'replaced') 203 self.set_data('status', 'replaced')
204 self.set_interact("replaced") 204 self.set_interact("replaced")
205 self.scene.set_data('life support status', 'replaced') 205 self.scene.set_data('life support status', 'replaced')
206 return Result("The pipes slot neatly into place, but don't make" 206 return Result("The pipes slot neatly into place, but don't make"
207 " an airtight seal. One of the pipes has cracked" 207 " an airtight seal. One of the pipes has cracked"
258 258
259 def is_interactive(self, tool=None): 259 def is_interactive(self, tool=None):
260 return False 260 return False
261 261
262 def animate(self): 262 def animate(self):
263 hiss = self.state.gd.sound.get_sound(self.HISS) 263 hiss = self.game.gd.sound.get_sound(self.HISS)
264 if self.get_data('anim_pos') > -1: 264 if self.get_data('anim_pos') > -1:
265 self.current_interact.animate() 265 self.current_interact.animate()
266 if self.get_data('anim_pos') > self.current_interact._anim_pos: 266 if self.get_data('anim_pos') > self.current_interact._anim_pos:
267 self.set_interact('no_snake') 267 self.set_interact('no_snake')
268 self.set_data('anim_pos', -1) 268 self.set_data('anim_pos', -1)
269 else: 269 else:
270 self.set_data('anim_pos', self.current_interact._anim_pos) 270 self.set_data('anim_pos', self.current_interact._anim_pos)
271 return True 271 return True
272 if randint(0, 30 * self.state.gd.constants.frame_rate) == 0: 272 if randint(0, 30 * self.game.gd.constants.frame_rate) == 0:
273 self.set_interact('snake') 273 self.set_interact('snake')
274 self.set_data('anim_pos', 0) 274 self.set_data('anim_pos', 0)
275 hiss.play() 275 hiss.play()
276 return False 276 return False
277 277
295 def interact_without(self): 295 def interact_without(self):
296 if self.get_data('taken'): 296 if self.get_data('taken'):
297 return Result("The remaining bottles leak.") 297 return Result("The remaining bottles leak.")
298 self.set_data('taken', True) 298 self.set_data('taken', True)
299 self.set_interact('taken') 299 self.set_interact('taken')
300 self.state.add_inventory_item('detergent_bottle') 300 self.game.add_inventory_item('detergent_bottle')
301 return Result("You pick up an empty dishwashing liquid bottle. You" 301 return Result("You pick up an empty dishwashing liquid bottle. You"
302 " can't find any sponges.") 302 " can't find any sponges.")
303 303
304 def get_description(self): 304 def get_description(self):
305 return "Empty plastic containers. They used to hold dishwasher soap." 305 return "Empty plastic containers. They used to hold dishwasher soap."