Mercurial > pyntnclick
comparison gamelib/scenes/mess.py @ 539:11530992924a
PEP8 clean-up for engine, machine and mess.
author | Simon Cross <hodgestar+bzr@gmail.com> |
---|---|
date | Sat, 11 Feb 2012 12:20:12 +0200 |
parents | 0ce08d5e2acb |
children | 098ea4ea0d0d |
comparison
equal
deleted
inserted
replaced
538:d1b86d5849a0 | 539:11530992924a |
---|---|
18 | 18 |
19 FOLDER = "mess" | 19 FOLDER = "mess" |
20 BACKGROUND = "mess_hall.png" | 20 BACKGROUND = "mess_hall.png" |
21 | 21 |
22 INITIAL_DATA = { | 22 INITIAL_DATA = { |
23 'life support status': 'broken', # broken, replaced, fixed | 23 'life support status': 'broken', # broken, replaced, fixed |
24 } | 24 } |
25 | 25 |
26 def __init__(self, state): | 26 def __init__(self, state): |
27 super(Mess, self).__init__(state) | 27 super(Mess, self).__init__(state) |
28 self.add_thing(CansOnShelf()) | 28 self.add_thing(CansOnShelf()) |
49 | 49 |
50 class BaseCan(CloneableItem): | 50 class BaseCan(CloneableItem): |
51 """Base class for the cans""" | 51 """Base class for the cans""" |
52 | 52 |
53 def interact_with_full_can(self, item): | 53 def interact_with_full_can(self, item): |
54 return Result("You bang the cans together. It sounds like two cans being banged together.", soundfile="can_hit.ogg") | 54 return Result("You bang the cans together. It sounds like two" |
55 " cans being banged together.", | |
56 soundfile="can_hit.ogg") | |
55 | 57 |
56 def interact_with_dented_can(self, item): | 58 def interact_with_dented_can(self, item): |
57 return self.interact_with_full_can(item) | 59 return self.interact_with_full_can(item) |
58 | 60 |
59 def interact_with_empty_can(self, item): | 61 def interact_with_empty_can(self, item): |
64 | 66 |
65 def interact_with_canopener(self, item): | 67 def interact_with_canopener(self, item): |
66 empty = EmptyCan('empty_can') | 68 empty = EmptyCan('empty_can') |
67 self.state.add_item(empty) | 69 self.state.add_item(empty) |
68 self.state.replace_inventory_item(self.name, empty.name) | 70 self.state.replace_inventory_item(self.name, empty.name) |
69 return Result("You open both ends of the can, discarding the hideous contents.") | 71 return Result("You open both ends of the can, discarding the" |
72 " hideous contents.") | |
70 | 73 |
71 | 74 |
72 class EmptyCan(BaseCan): | 75 class EmptyCan(BaseCan): |
73 "After emptying the full can." | 76 "After emptying the full can." |
74 | 77 |
75 INVENTORY_IMAGE = "empty_can.png" | 78 INVENTORY_IMAGE = "empty_can.png" |
76 CURSOR = CursorSprite('empty_can_cursor.png') | 79 CURSOR = CursorSprite('empty_can_cursor.png') |
77 | 80 |
78 def interact_with_titanium_leg(self, item): | 81 def interact_with_titanium_leg(self, item): |
79 return Result("Flattening the can doesn't look like a useful thing to do.") | 82 return Result("Flattening the can doesn't look like a useful" |
83 " thing to do.") | |
80 | 84 |
81 def interact_with_canopener(self, item): | 85 def interact_with_canopener(self, item): |
82 return Result("There's nothing left to open on this can") | 86 return Result("There's nothing left to open on this can") |
83 | 87 |
84 | 88 |
90 | 94 |
91 def interact_with_titanium_leg(self, item): | 95 def interact_with_titanium_leg(self, item): |
92 dented = DentedCan("dented_can") | 96 dented = DentedCan("dented_can") |
93 self.state.add_item(dented) | 97 self.state.add_item(dented) |
94 self.state.replace_inventory_item(self.name, dented.name) | 98 self.state.replace_inventory_item(self.name, dented.name) |
95 return Result("You club the can with the femur. The can gets dented, but doesn't open.", soundfile="can_hit.ogg") | 99 return Result("You club the can with the femur. The can gets dented," |
100 " but doesn't open.", soundfile="can_hit.ogg") | |
96 | 101 |
97 | 102 |
98 class DentedCan(BaseCan): | 103 class DentedCan(BaseCan): |
99 "A can banged on with the femur" | 104 "A can banged on with the femur" |
100 | 105 |
101 INVENTORY_IMAGE = "dented_can.png" | 106 INVENTORY_IMAGE = "dented_can.png" |
102 CURSOR = CursorSprite('dented_can_cursor.png') | 107 CURSOR = CursorSprite('dented_can_cursor.png') |
103 | 108 |
104 def interact_with_titanium_leg(self, item): | 109 def interact_with_titanium_leg(self, item): |
105 return Result("You club the can with the femur. The dents shift around, but it still doesn't open.", soundfile="can_hit.ogg") | 110 return Result("You club the can with the femur. The dents shift" |
111 " around, but it still doesn't open.", | |
112 soundfile="can_hit.ogg") | |
106 | 113 |
107 | 114 |
108 class CansOnShelf(Thing): | 115 class CansOnShelf(Thing): |
109 | 116 |
110 NAME = "mess.cans" | 117 NAME = "mess.cans" |
131 self.set_data('cans_available', starting_cans - 1) | 138 self.set_data('cans_available', starting_cans - 1) |
132 self.set_interact('%icans' % (starting_cans - 1)) | 139 self.set_interact('%icans' % (starting_cans - 1)) |
133 if starting_cans == 1: | 140 if starting_cans == 1: |
134 self.scene.remove_thing(self) | 141 self.scene.remove_thing(self) |
135 return Result({ | 142 return Result({ |
136 3: "Best before a long time in the past. Better not eat these.", | 143 3: "Best before a long time in the past." |
144 " Better not eat these.", | |
137 2: "Mmmm. Nutritious bacteria stew.", | 145 2: "Mmmm. Nutritious bacteria stew.", |
138 1: "Candied silkworms. Who stocked this place?!", | 146 1: "Candied silkworms. Who stocked this place?!", |
139 }[starting_cans]) | 147 }[starting_cans]) |
140 else: | 148 else: |
141 return Result("The rest of the cans are rusted beyond usefulness.") | 149 return Result("The rest of the cans are rusted beyond usefulness.") |
161 "status": "blocked", | 169 "status": "blocked", |
162 } | 170 } |
163 | 171 |
164 def get_description(self): | 172 def get_description(self): |
165 if self.get_data('status') == "blocked": | 173 if self.get_data('status') == "blocked": |
166 return "The broccoli seems to have become entangled with something." | 174 return ("The broccoli seems to have become" |
175 " entangled with something.") | |
167 elif self.get_data("status") == "broken": | 176 elif self.get_data("status") == "broken": |
168 return "These broken pipes look important." | 177 return "These broken pipes look important." |
169 elif self.get_data("status") == "replaced": | 178 elif self.get_data("status") == "replaced": |
170 return "The pipes have been repaired but are the repairs aren't airtight, yet" | 179 return ("The pipes have been repaired but are the repairs" |
180 " aren't airtight, yet") | |
171 else: | 181 else: |
172 return "Your fix looks like it's holding up well." | 182 return "Your fix looks like it's holding up well." |
173 | 183 |
174 def interact_with_machete(self, item): | 184 def interact_with_machete(self, item): |
175 if self.get_data("status") == "blocked": | 185 if self.get_data("status") == "blocked": |
194 else: | 204 else: |
195 self.state.remove_inventory_item(item.name) | 205 self.state.remove_inventory_item(item.name) |
196 self.set_data('status', 'replaced') | 206 self.set_data('status', 'replaced') |
197 self.set_interact("replaced") | 207 self.set_interact("replaced") |
198 self.scene.set_data('life support status', 'replaced') | 208 self.scene.set_data('life support status', 'replaced') |
199 return Result( | 209 return Result("The pipes slot neatly into place, but don't make" |
200 "The pipes slot neatly into place, but don't make an airtight seal. " | 210 " an airtight seal. One of the pipes has cracked" |
201 "One of the pipes has cracked slightly as well." | 211 " slightly as well.") |
202 ) | |
203 | 212 |
204 def interact_with_duct_tape(self, item): | 213 def interact_with_duct_tape(self, item): |
205 if self.get_data("status") == "broken": | 214 if self.get_data("status") == "broken": |
206 return Result("It would get lost in the fronds.") | 215 return Result("It would get lost in the fronds.") |
207 elif self.get_data("status") == 'fixed': | 216 elif self.get_data("status") == 'fixed': |
210 self.set_data("fixed", True) | 219 self.set_data("fixed", True) |
211 self.set_data("status", "fixed") | 220 self.set_data("status", "fixed") |
212 self.set_interact("fixed") | 221 self.set_interact("fixed") |
213 self.scene.set_data('life support status', 'fixed') | 222 self.scene.set_data('life support status', 'fixed') |
214 # TODO: A less anticlimactic climax? | 223 # TODO: A less anticlimactic climax? |
215 return Result("It takes quite a lot of tape, but eventually everything is" | 224 return Result("It takes quite a lot of tape, but eventually" |
216 " airtight and ready to hold pressure. Who'd've thought duct" | 225 "everything is airtight and ready to hold pressure." |
217 " tape could actually be used to tape ducts?") | 226 " Who'd've thought duct tape could actually be used" |
227 " to tape ducts?") | |
218 | 228 |
219 def interact_without(self): | 229 def interact_without(self): |
220 if self.get_data("status") == "blocked": | 230 if self.get_data("status") == "blocked": |
221 return Result("The mutant broccoli resists your best efforts.") | 231 return Result("The mutant broccoli resists your best efforts.") |
222 elif self.get_data("status") == "broken": | 232 elif self.get_data("status") == "broken": |
223 return Result("Shoving the broken pipes around doesn't help much.") | 233 return Result("Shoving the broken pipes around doesn't help much.") |
224 elif self.get_data("status") == "replaced": | 234 elif self.get_data("status") == "replaced": |
225 return Result("Do you really want to hold it together for the " | 235 return Result("Do you really want to hold it together for the " |
226 "rest of the voyage?") | 236 "rest of the voyage?") |
227 else: | 237 else: |
228 return Result("You don't find any leaks. Good job, Prisoner %s." % PLAYER_ID) | 238 return Result("You don't find any leaks. Good job, Prisoner %s." |
239 % PLAYER_ID) | |
229 | 240 |
230 | 241 |
231 class Boomslang(Thing): | 242 class Boomslang(Thing): |
232 NAME = 'mess.boomslang' | 243 NAME = 'mess.boomslang' |
233 | 244 |
270 class DetergentThing(Thing): | 281 class DetergentThing(Thing): |
271 | 282 |
272 NAME = "mess.detergent" | 283 NAME = "mess.detergent" |
273 | 284 |
274 INTERACTS = { | 285 INTERACTS = { |
275 'present': InteractImageRect(581, 424, 'detergent_lid.png', 565, 399, 62, 95), | 286 'present': InteractImageRect(581, 424, 'detergent_lid.png', |
287 565, 399, 62, 95), | |
276 'taken': InteractNoImage(565, 399, 62, 95), | 288 'taken': InteractNoImage(565, 399, 62, 95), |
277 } | 289 } |
278 | 290 |
279 INITIAL = 'present' | 291 INITIAL = 'present' |
280 | 292 |
286 if self.get_data('taken'): | 298 if self.get_data('taken'): |
287 return Result("The remaining bottles leak.") | 299 return Result("The remaining bottles leak.") |
288 self.set_data('taken', True) | 300 self.set_data('taken', True) |
289 self.set_interact('taken') | 301 self.set_interact('taken') |
290 self.state.add_inventory_item('detergent_bottle') | 302 self.state.add_inventory_item('detergent_bottle') |
291 return Result("You pick up an empty dishwashing liquid bottle. You can't find any sponges.") | 303 return Result("You pick up an empty dishwashing liquid bottle. You" |
304 " can't find any sponges.") | |
292 | 305 |
293 def get_description(self): | 306 def get_description(self): |
294 return "Empty plastic containers. They used to hold dishwasher soap." | 307 return "Empty plastic containers. They used to hold dishwasher soap." |
295 | 308 |
296 | 309 |