# HG changeset patch # User Jeremy Thurgood # Date 1282848799 -7200 # Node ID 326300c218a6d19f9ab85bcf6f803d3a24e2473c # Parent 6ad6575b501cd524995cfed476f5c1c2fffd3d26 Choppable cryopipes and can refactoring. diff -r 6ad6575b501c -r 326300c218a6 gamelib/scenes/cryo.py --- a/gamelib/scenes/cryo.py Thu Aug 26 20:34:57 2010 +0200 +++ b/gamelib/scenes/cryo.py Thu Aug 26 20:53:19 2010 +0200 @@ -6,7 +6,7 @@ from gamelib import speech from gamelib.sound import get_sound from gamelib.cursor import CursorSprite -from gamelib.state import Scene, Item, Thing, Result, \ +from gamelib.state import Scene, Item, CloneableItem, Thing, Result, \ InteractImage, InteractNoImage, InteractRectUnion, \ InteractAnimated from gamelib.statehelpers import GenericDescThing @@ -40,6 +40,8 @@ self.add_thing(CryoUnitAlpha()) self.add_thing(CryoRoomDoor()) self.add_thing(CryoComputer()) + self.add_thing(CryoPipeLeft()) + self.add_thing(CryoPipeRight()) # Flavour items # pipes @@ -151,6 +153,53 @@ change_playlist(None) +class CryoPipeBase(Thing): + "Base class for cryo pipes that need to be stolen." + + INITIAL = "fixed" + + INITIAL_DATA = { + 'fixed': True, + } + + def interact_with_machete(self, item): + self.set_data('fixed', False) + pipe = CryoPipe('cryopipe') + self.state.add_item(pipe) + self.state.add_inventory_item(pipe.name) + self.set_interact("chopped") + + def is_interactive(self): + return self.get_data('fixed') + + +class CryoPipe(CloneableItem): + "After emptying the full can." + + INVENTORY_IMAGE = "triangle.png" + CURSOR = CursorSprite('triangle.png', 20, 30) + + +class CryoPipeLeft(CryoPipeBase): + "Left cryo pipe." + + NAME = "cryo.pipe.left" + INTERACTS = { + "fixed": InteractNoImage(125, 192, 27, 258), + "chopped": InteractImage(125, 192, "triangle.png"), + } + + +class CryoPipeRight(CryoPipeBase): + "Left cryo pipe." + + NAME = "cryo.pipe.right" + INTERACTS = { + "fixed": InteractNoImage(643, 199, 38, 233), + "chopped": InteractImage(643, 199, "triangle.png"), + } + + class TitaniumLeg(Item): "Titanium leg, found on a piratical corpse." diff -r 6ad6575b501c -r 326300c218a6 gamelib/scenes/machine.py --- a/gamelib/scenes/machine.py Thu Aug 26 20:34:57 2010 +0200 +++ b/gamelib/scenes/machine.py Thu Aug 26 20:53:19 2010 +0200 @@ -18,7 +18,7 @@ self.add_thing(ToMap()) self.add_thing(LaserWelder()) self.add_thing(Grinder()) - self.add_item(TitaniumMachete('titanium_machete')) + self.add_item(TitaniumMachete('machete')) def enter(self): return Result("The machine room is dark and forbidding.") @@ -109,7 +109,7 @@ return Result("It looks like it eats fingers. Perhaps a different approach is in order?") def interact_with_titanium_leg(self, item): - self.state.replace_inventory_item(item, self.state.items['titanium_machete']) + self.state.replace_inventory_item(item, self.state.items['machete']) return Result("After much delicate grinding and a few close calls with" " various body parts, the titanium femur now resembles" " a machete more than a bone. Nice and sharp, too.", diff -r 6ad6575b501c -r 326300c218a6 gamelib/scenes/mess.py --- a/gamelib/scenes/mess.py Thu Aug 26 20:34:57 2010 +0200 +++ b/gamelib/scenes/mess.py Thu Aug 26 20:53:19 2010 +0200 @@ -34,10 +34,10 @@ return Result("You bang the cans togther. It sounds like two cans being banged togther.", soundfile="can_hit.ogg") def interact_with_dented_can(self, item, state): - return Result("You bang the cans togther. It sounds like two cans being banged togther.", soundfile="can_hit.ogg") + return self.interact_with_full_can(item, state) def interact_with_empty_can(self, item, state): - return Result("You bang the cans togther. It sounds like two cans being banged togther.", soundfile="can_hit.ogg") + return self.interact_with_full_can(item, state) class FullCan(CloneableItem): @@ -56,10 +56,10 @@ return Result("You bang the cans togther. It sounds like two cans being banged togther.", soundfile="can_hit.ogg") def interact_with_dented_can(self, item, state): - return Result("You bang the cans togther. It sounds like two cans being banged togther.", soundfile="can_hit.ogg") + return self.interact_with_full_can(item, state) def interact_with_empty_can(self, item, state): - return Result("You bang the cans togther. It sounds like two cans being banged togther.", soundfile="can_hit.ogg") + return self.interact_with_full_can(item, state) class DentedCan(CloneableItem): @@ -75,10 +75,10 @@ return Result("You bang the cans togther. It sounds like two cans being banged togther.", soundfile="can_hit.ogg") def interact_with_dented_can(self, item, state): - return Result("You bang the cans togther. It sounds like two cans being banged togther.", soundfile="can_hit.ogg") + return self.interact_with_full_can(item, state) def interact_with_empty_can(self, item, state): - return Result("You bang the cans togther. It sounds like two cans being banged togther.", soundfile="can_hit.ogg") + return self.interact_with_full_can(item, state) class TubeFragments(Item):