Mercurial > pyntnclick
diff gamelib/scenes/mess.py @ 296:86e3d5dd7fa6
Added detergent bottle Item and InteractImageRect class
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Sat, 28 Aug 2010 00:28:18 +0200 |
parents | 4a9f29bae9b0 |
children | c3ff6ff879e6 |
line wrap: on
line diff
--- a/gamelib/scenes/mess.py Sat Aug 28 00:25:26 2010 +0200 +++ b/gamelib/scenes/mess.py Sat Aug 28 00:28:18 2010 +0200 @@ -6,7 +6,8 @@ from gamelib.cursor import CursorSprite from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage, InteractRectUnion, InteractImage, - InteractAnimated, GenericDescThing) + InteractImageRect, InteractAnimated, + GenericDescThing) class Mess(Scene): @@ -23,6 +24,8 @@ self.add_thing(CansOnShelf()) self.add_thing(Tubes()) self.add_thing(ToMap()) + self.add_thing(DetergentThing()) + self.add_item(DetergentBottle('detergent_bottle')) # Flavour items # extra cans on shelf self.add_thing(GenericDescThing('mess.cans', 1, @@ -37,10 +40,6 @@ (503, 89, 245, 282), (320, 324, 229, 142), ))) - self.add_thing(GenericDescThing('mess.cans', 2, - "Empty plastic containers. They used to hold dishwasher soap.", - ((565, 399, 62, 95),))) - class BaseCan(CloneableItem): @@ -198,6 +197,36 @@ " airtight and ready to hold pressure. Who'd've thought duct" " tape could actually be used to tape ducts?") +class DetergentThing(Thing): + + NAME = "mess.detergent" + + INTERACTS = { + 'present': InteractImageRect(581, 424, 'detergent_lid.png', 565, 399, 62, 95), + 'taken': InteractNoImage(565, 399, 62, 95), + } + + INITIAL = 'present' + + INITIAL_DATA = { + 'taken': False, + } + + def interact_without(self): + if self.get_data('taken'): + return Result("I think one dishwashing liquid bottle is enough for now") + self.set_data('taken', True) + self.set_interact('taken') + self.state.add_inventory_item('detergent_bottle') + return Result("You pick up an empty dishwashing liquid bottle. You can't find any sponges") + + def get_description(self): + return "Empty plastic containers. They used to hold dish washer soap." + +class DetergentBottle(Item): + INVENTORY_IMAGE = 'triangle.png' + CURSOR = CursorSprite('triangle.png', 25, 23) + class ToMap(Door):