comparison 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
comparison
equal deleted inserted replaced
295:4a9f29bae9b0 296:86e3d5dd7fa6
4 4
5 from gamelib.state import Scene, Item, CloneableItem, Thing, Result 5 from gamelib.state import Scene, Item, CloneableItem, Thing, Result
6 from gamelib.cursor import CursorSprite 6 from gamelib.cursor import CursorSprite
7 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage, 7 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage,
8 InteractRectUnion, InteractImage, 8 InteractRectUnion, InteractImage,
9 InteractAnimated, GenericDescThing) 9 InteractImageRect, InteractAnimated,
10 GenericDescThing)
10 11
11 12
12 class Mess(Scene): 13 class Mess(Scene):
13 14
14 FOLDER = "mess" 15 FOLDER = "mess"
21 def __init__(self, state): 22 def __init__(self, state):
22 super(Mess, self).__init__(state) 23 super(Mess, self).__init__(state)
23 self.add_thing(CansOnShelf()) 24 self.add_thing(CansOnShelf())
24 self.add_thing(Tubes()) 25 self.add_thing(Tubes())
25 self.add_thing(ToMap()) 26 self.add_thing(ToMap())
27 self.add_thing(DetergentThing())
28 self.add_item(DetergentBottle('detergent_bottle'))
26 # Flavour items 29 # Flavour items
27 # extra cans on shelf 30 # extra cans on shelf
28 self.add_thing(GenericDescThing('mess.cans', 1, 31 self.add_thing(GenericDescThing('mess.cans', 1,
29 "A large collection of rusted, useless cans.", 32 "A large collection of rusted, useless cans.",
30 ( 33 (
35 "An impressively overgrown broccoli.", 38 "An impressively overgrown broccoli.",
36 ( 39 (
37 (503, 89, 245, 282), 40 (503, 89, 245, 282),
38 (320, 324, 229, 142), 41 (320, 324, 229, 142),
39 ))) 42 )))
40 self.add_thing(GenericDescThing('mess.cans', 2,
41 "Empty plastic containers. They used to hold dishwasher soap.",
42 ((565, 399, 62, 95),)))
43
44 43
45 44
46 class BaseCan(CloneableItem): 45 class BaseCan(CloneableItem):
47 """Base class for the cans""" 46 """Base class for the cans"""
48 47
196 # TODO: A less anticlimactic climax? 195 # TODO: A less anticlimactic climax?
197 return Result("It takes quite a lot of tape, but eventually everything is" 196 return Result("It takes quite a lot of tape, but eventually everything is"
198 " airtight and ready to hold pressure. Who'd've thought duct" 197 " airtight and ready to hold pressure. Who'd've thought duct"
199 " tape could actually be used to tape ducts?") 198 " tape could actually be used to tape ducts?")
200 199
200 class DetergentThing(Thing):
201
202 NAME = "mess.detergent"
203
204 INTERACTS = {
205 'present': InteractImageRect(581, 424, 'detergent_lid.png', 565, 399, 62, 95),
206 'taken': InteractNoImage(565, 399, 62, 95),
207 }
208
209 INITIAL = 'present'
210
211 INITIAL_DATA = {
212 'taken': False,
213 }
214
215 def interact_without(self):
216 if self.get_data('taken'):
217 return Result("I think one dishwashing liquid bottle is enough for now")
218 self.set_data('taken', True)
219 self.set_interact('taken')
220 self.state.add_inventory_item('detergent_bottle')
221 return Result("You pick up an empty dishwashing liquid bottle. You can't find any sponges")
222
223 def get_description(self):
224 return "Empty plastic containers. They used to hold dish washer soap."
225
226 class DetergentBottle(Item):
227 INVENTORY_IMAGE = 'triangle.png'
228 CURSOR = CursorSprite('triangle.png', 25, 23)
229
201 230
202 class ToMap(Door): 231 class ToMap(Door):
203 232
204 SCENE = "mess" 233 SCENE = "mess"
205 234