comparison gamelib/scenes/cryo.py @ 816:eed75a1d50c4 pyntnclick

Better Item handling.
author Jeremy Thurgood <firxen@gmail.com>
date Sun, 27 Jan 2013 22:19:39 +0200
parents 374d96e0b55e
children a1c0c1078342
comparison
equal deleted inserted replaced
815:8f94fbf05ab9 816:eed75a1d50c4
32 'silent.ogg', 32 'silent.ogg',
33 'silent.ogg', 33 'silent.ogg',
34 ] 34 ]
35 35
36 def setup(self): 36 def setup(self):
37 self.add_item(TitaniumLeg("titanium_leg")) 37 self.add_item_factory(TitaniumLeg)
38 self.add_item_factory(TubeFragment)
39 self.add_item_factory(FullBottle)
38 self.add_thing(CryoUnitAlpha()) 40 self.add_thing(CryoUnitAlpha())
39 self.add_thing(CryoRoomDoor()) 41 self.add_thing(CryoRoomDoor())
40 self.add_thing(CryoComputer()) 42 self.add_thing(CryoComputer())
41 self.add_thing(CryoPipeLeft()) 43 self.add_thing(CryoPipeLeft())
42 self.add_thing(CryoPipeRightTop()) 44 self.add_thing(CryoPipeRightTop())
163 return self.INITIAL 165 return self.INITIAL
164 166
165 def interact_with_machete(self, item): 167 def interact_with_machete(self, item):
166 if self.get_data('fixed'): 168 if self.get_data('fixed'):
167 self.set_data('fixed', False) 169 self.set_data('fixed', False)
168 pipe = TubeFragment('tube_fragment') 170 self.game.add_inventory_item('tube_fragment')
169 self.game.add_item(pipe)
170 self.game.add_inventory_item(pipe.name)
171 self.set_interact() 171 self.set_interact()
172 responses = [Result(_("It takes more effort than one would expect," 172 responses = [Result(_("It takes more effort than one would expect,"
173 " but eventually the pipe is separated from" 173 " but eventually the pipe is separated from"
174 " the wall."), soundfile="chop-chop.ogg")] 174 " the wall."), soundfile="chop-chop.ogg")]
175 if self.game.get_current_scene().get_data('vandalism_warn'): 175 if self.game.get_current_scene().get_data('vandalism_warn'):
224 224
225 225
226 class TubeFragment(CloneableItem): 226 class TubeFragment(CloneableItem):
227 "Obtained after cutting down a cryo room pipe." 227 "Obtained after cutting down a cryo room pipe."
228 228
229 NAME = "tube_fragment"
229 INVENTORY_IMAGE = "tube_fragment.png" 230 INVENTORY_IMAGE = "tube_fragment.png"
230 CURSOR = CursorSprite('tube_fragment_cursor.png') 231 CURSOR = CursorSprite('tube_fragment_cursor.png')
231 TOOL_NAME = "tube_fragment" 232 TOOL_NAME = "tube_fragment"
233 MAX_COUNT = 3
232 234
233 235
234 class CryoPipeLeft(CryoPipeBase): 236 class CryoPipeLeft(CryoPipeBase):
235 "Left cryo pipe." 237 "Left cryo pipe."
236 238
262 264
263 265
264 class TitaniumLeg(Item): 266 class TitaniumLeg(Item):
265 "Titanium leg, found on a piratical corpse." 267 "Titanium leg, found on a piratical corpse."
266 268
269 NAME = 'titanium_leg'
267 INVENTORY_IMAGE = "titanium_femur.png" 270 INVENTORY_IMAGE = "titanium_femur.png"
268 CURSOR = CursorSprite('titanium_femur_cursor.png', 13, 5) 271 CURSOR = CursorSprite('titanium_femur_cursor.png', 13, 5)
269 272
270 273
271 class CryoUnitAlpha(Thing): 274 class CryoUnitAlpha(Thing):
461 def get_description(self): 464 def get_description(self):
462 return _("'Prisoner 98CC-764E646391EE. War crimes. 45 years.") 465 return _("'Prisoner 98CC-764E646391EE. War crimes. 45 years.")
463 466
464 467
465 class FullBottle(Item): 468 class FullBottle(Item):
469 NAME = 'full_detergent_bottle'
466 INVENTORY_IMAGE = 'bottle_full.png' 470 INVENTORY_IMAGE = 'bottle_full.png'
467 CURSOR = CursorSprite('bottle_full_cursor.png', 27, 7) 471 CURSOR = CursorSprite('bottle_full_cursor.png', 27, 7)
468 472
469 473
470 class CryoPools(Thing): 474 class CryoPools(Thing):
487 491
488 def interact_without(self): 492 def interact_without(self):
489 return Result(_("It's gooey")) 493 return Result(_("It's gooey"))
490 494
491 def interact_with_detergent_bottle(self, item): 495 def interact_with_detergent_bottle(self, item):
492 full = FullBottle('full_detergent_bottle') 496 self.game.replace_inventory_item(item.name, 'full_detergent_bottle')
493 self.game.add_item(full)
494 self.game.replace_inventory_item(item.name, full.name)
495 return Result(_("You scoop up some coolant and fill the bottle.")) 497 return Result(_("You scoop up some coolant and fill the bottle."))
496 498
497 499
498 class CryoCompDetail(Scene): 500 class CryoCompDetail(Scene):
499 501