Mercurial > pyntnclick
comparison gamelib/scenes/engine.py @ 764:a8510f4e2ea1 pyntnclick
Conditionally add things based on state.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 26 Jan 2013 15:24:56 +0200 |
parents | 386475464202 |
children | a35f5364437d |
comparison
equal
deleted
inserted
replaced
763:afe7b1cb16c0 | 764:a8510f4e2ea1 |
---|---|
1 """Engine room where things need to be repaired.""" | 1 """Engine room where things need to be repaired.""" |
2 | 2 |
3 from pyntnclick.cursor import CursorSprite | 3 from pyntnclick.cursor import CursorSprite |
4 from pyntnclick.state import Scene, Item, Thing, Result | 4 from pyntnclick.state import Scene, Item, Thing, Result |
5 from pyntnclick.scenewidgets import (InteractNoImage, InteractRectUnion, | 5 from pyntnclick.scenewidgets import ( |
6 InteractImage, InteractAnimated, | 6 InteractNoImage, InteractRectUnion, InteractImage, InteractAnimated, |
7 GenericDescThing) | 7 GenericDescThing, TakeableThing) |
8 | 8 |
9 from gamelib.scenes.game_constants import PLAYER_ID | 9 from gamelib.scenes.game_constants import PLAYER_ID |
10 from gamelib.scenes.game_widgets import Door, make_jim_dialog | 10 from gamelib.scenes.game_widgets import Door, make_jim_dialog |
11 | 11 |
12 | 12 |
66 " found them irresistible.", | 66 " found them irresistible.", |
67 ( | 67 ( |
68 (562, 422, 30, 31), | 68 (562, 422, 30, 31), |
69 ) | 69 ) |
70 )) | 70 )) |
71 self.add_thing(GenericDescThing('engine.engines', 8, | 71 if not self.get_data('engine online'): |
72 "The engines. They don't look like they are working.", | 72 self.add_thing(GenericDescThing('engine.engines', 8, |
73 ( | 73 "The engines. They don't look like they are working.", |
74 (342, 261, 109, 81), | 74 ( |
75 ) | 75 (342, 261, 109, 81), |
76 )) | 76 ) |
77 )) | |
77 self.add_thing(GenericDescThing('engine.laser_cutter', 9, | 78 self.add_thing(GenericDescThing('engine.laser_cutter', 9, |
78 "A burned-out laser cutter. It may be responsible for the" | 79 "A burned-out laser cutter. It may be responsible for the" |
79 " hole in the floor.", | 80 " hole in the floor.", |
80 ( | 81 ( |
81 (120, 466, 115, 67), | 82 (120, 466, 115, 67), |
161 class CanOpener(Item): | 162 class CanOpener(Item): |
162 INVENTORY_IMAGE = 'can_opener.png' | 163 INVENTORY_IMAGE = 'can_opener.png' |
163 CURSOR = CursorSprite('can_opener_cursor.png') | 164 CURSOR = CursorSprite('can_opener_cursor.png') |
164 | 165 |
165 | 166 |
166 class CanOpenerThing(Thing): | 167 class CanOpenerThing(TakeableThing): |
167 NAME = 'engine.canopener' | 168 NAME = 'engine.canopener' |
168 | 169 |
169 INTERACTS = { | 170 INTERACTS = { |
170 'canopener': InteractImage(565, 456, 'can_opener.png'), | 171 'canopener': InteractImage(565, 456, 'can_opener.png'), |
171 } | 172 } |
172 | 173 |
173 INITIAL = 'canopener' | 174 INITIAL = 'canopener' |
175 ITEM = 'canopener' | |
174 | 176 |
175 def get_description(self): | 177 def get_description(self): |
176 return "A can opener. Looks like you won't be starving" | 178 return "A can opener. Looks like you won't be starving" |
177 | 179 |
178 def interact_without(self): | 180 def interact_without(self): |
179 self.game.add_inventory_item('canopener') | 181 self.take() |
180 self.scene.remove_thing(self) | |
181 return Result("You pick up the can opener. It looks brand new; " | 182 return Result("You pick up the can opener. It looks brand new; " |
182 "the vacuum has kept it in perfect condition.") | 183 "the vacuum has kept it in perfect condition.") |
183 | 184 |
184 | 185 |
185 class SuperconductorSocket(Thing): | 186 class SuperconductorSocket(Thing): |