comparison gamelib/scenes/mess.py @ 478:a9925aaf5f61 1.0.1

i18n and Russian translation
author Stefano Rivera <stefano@rivera.za.net>
date Tue, 08 Mar 2011 12:29:14 +0200
parents af2a23b9787d
children 2f1952748cdb
comparison
equal deleted inserted replaced
477:51055400a9a8 478:a9925aaf5f61
11 11
12 from gamelib.sound import get_sound 12 from gamelib.sound import get_sound
13 from gamelib import constants 13 from gamelib import constants
14 from gamelib.scenes.game_constants import PLAYER_ID 14 from gamelib.scenes.game_constants import PLAYER_ID
15 15
16 from gamelib.i18n import _
16 17
17 class Mess(Scene): 18 class Mess(Scene):
18 19
19 FOLDER = "mess" 20 FOLDER = "mess"
20 BACKGROUND = "mess_hall.png" 21 BACKGROUND = "mess_hall.png"
32 self.add_thing(Boomslang()) 33 self.add_thing(Boomslang())
33 self.add_item(DetergentBottle('detergent_bottle')) 34 self.add_item(DetergentBottle('detergent_bottle'))
34 # Flavour items 35 # Flavour items
35 # extra cans on shelf 36 # extra cans on shelf
36 self.add_thing(GenericDescThing('mess.cans', 1, 37 self.add_thing(GenericDescThing('mess.cans', 1,
37 "A large collection of rusted, useless cans.", 38 _("A large collection of rusted, useless cans."),
38 ( 39 (
39 (154, 335, 89, 106), 40 (154, 335, 89, 106),
40 (152, 435, 63, 66), 41 (152, 435, 63, 66),
41 ))) 42 )))
42 self.add_thing(GenericDescThing('mess.broccoli', 2, 43 self.add_thing(GenericDescThing('mess.broccoli', 2,
43 "An impressively overgrown broccoli.", 44 _("An impressively overgrown broccoli."),
44 ( 45 (
45 (503, 89, 245, 282), 46 (503, 89, 245, 282),
46 (320, 324, 229, 142), 47 (320, 324, 229, 142),
47 ))) 48 )))
48 49
49 50
50 class BaseCan(CloneableItem): 51 class BaseCan(CloneableItem):
51 """Base class for the cans""" 52 """Base class for the cans"""
52 53
53 def interact_with_full_can(self, item, state): 54 def interact_with_full_can(self, item, state):
54 return Result("You bang the cans together. It sounds like two cans being banged together.", soundfile="can_hit.ogg") 55 return Result(_("You bang the cans together. It sounds like two cans being banged together."), soundfile="can_hit.ogg")
55 56
56 def interact_with_dented_can(self, item, state): 57 def interact_with_dented_can(self, item, state):
57 return self.interact_with_full_can(item, state) 58 return self.interact_with_full_can(item, state)
58 59
59 def interact_with_empty_can(self, item, state): 60 def interact_with_empty_can(self, item, state):
60 return self.interact_with_full_can(item, state) 61 return self.interact_with_full_can(item, state)
61 62
62 def interact_with_machete(self, item, state): 63 def interact_with_machete(self, item, state):
63 return Result("You'd mangle it beyond usefulness.") 64 return Result(_("You'd mangle it beyond usefulness."))
64 65
65 def interact_with_canopener(self, item, state): 66 def interact_with_canopener(self, item, state):
66 empty = EmptyCan('empty_can') 67 empty = EmptyCan('empty_can')
67 state.add_item(empty) 68 state.add_item(empty)
68 state.replace_inventory_item(self.name, empty.name) 69 state.replace_inventory_item(self.name, empty.name)
69 return Result("You open both ends of the can, discarding the hideous contents.") 70 return Result(_("You open both ends of the can, discarding the hideous contents."))
70 71
71 72
72 class EmptyCan(BaseCan): 73 class EmptyCan(BaseCan):
73 "After emptying the full can." 74 "After emptying the full can."
74 75
75 INVENTORY_IMAGE = "empty_can.png" 76 INVENTORY_IMAGE = "empty_can.png"
76 CURSOR = CursorSprite('empty_can_cursor.png') 77 CURSOR = CursorSprite('empty_can_cursor.png')
77 78
78 def interact_with_titanium_leg(self, item, state): 79 def interact_with_titanium_leg(self, item, state):
79 return Result("Flattening the can doesn't look like a useful thing to do.") 80 return Result(_("Flattening the can doesn't look like a useful thing to do."))
80 81
81 def interact_with_canopener(self, item, state): 82 def interact_with_canopener(self, item, state):
82 return Result("There's nothing left to open on this can") 83 return Result(_("There's nothing left to open on this can"))
83 84
84 85
85 class FullCan(BaseCan): 86 class FullCan(BaseCan):
86 "Found on the shelf." 87 "Found on the shelf."
87 88
90 91
91 def interact_with_titanium_leg(self, item, state): 92 def interact_with_titanium_leg(self, item, state):
92 dented = DentedCan("dented_can") 93 dented = DentedCan("dented_can")
93 state.add_item(dented) 94 state.add_item(dented)
94 state.replace_inventory_item(self.name, dented.name) 95 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") 96 return Result(_("You club the can with the femur. The can gets dented, but doesn't open."), soundfile="can_hit.ogg")
96 97
97 98
98 class DentedCan(BaseCan): 99 class DentedCan(BaseCan):
99 "A can banged on with the femur" 100 "A can banged on with the femur"
100 101
101 INVENTORY_IMAGE = "dented_can.png" 102 INVENTORY_IMAGE = "dented_can.png"
102 CURSOR = CursorSprite('dented_can_cursor.png') 103 CURSOR = CursorSprite('dented_can_cursor.png')
103 104
104 def interact_with_titanium_leg(self, item, state): 105 def interact_with_titanium_leg(self, item, state):
105 return Result("You club the can with the femur. The dents shift around, but it still doesn't open.", soundfile="can_hit.ogg") 106 return Result(_("You club the can with the femur. The dents shift around, but it still doesn't open."), soundfile="can_hit.ogg")
106 107
107 108
108 class CansOnShelf(Thing): 109 class CansOnShelf(Thing):
109 110
110 NAME = "mess.cans" 111 NAME = "mess.cans"
131 self.set_data('cans_available', starting_cans - 1) 132 self.set_data('cans_available', starting_cans - 1)
132 self.set_interact('%icans' % (starting_cans - 1)) 133 self.set_interact('%icans' % (starting_cans - 1))
133 if starting_cans == 1: 134 if starting_cans == 1:
134 self.scene.remove_thing(self) 135 self.scene.remove_thing(self)
135 return Result({ 136 return Result({
136 3: "Best before a long time in the past. Better not eat these.", 137 3: _("Best before a long time in the past. Better not eat these."),
137 2: "Mmmm. Nutritious bacteria stew.", 138 2: _("Mmmm. Nutritious bacteria stew."),
138 1: "Candied silkworms. Who stocked this place?!", 139 1: _("Candied silkworms. Who stocked this place?!"),
139 }[starting_cans]) 140 }[starting_cans])
140 else: 141 else:
141 return Result("The rest of the cans are rusted beyond usefulness.") 142 return Result(_("The rest of the cans are rusted beyond usefulness."))
142 143
143 def get_description(self): 144 def get_description(self):
144 return "The contents of these cans look synthetic." 145 return _("The contents of these cans look synthetic.")
145 146
146 147
147 class Tubes(Thing): 148 class Tubes(Thing):
148 149
149 NAME = "mess.tubes" 150 NAME = "mess.tubes"
161 "status": "blocked", 162 "status": "blocked",
162 } 163 }
163 164
164 def get_description(self): 165 def get_description(self):
165 if self.get_data('status') == "blocked": 166 if self.get_data('status') == "blocked":
166 return "The broccoli seems to have become entangled with something." 167 return _("The broccoli seems to have become entangled with something.")
167 elif self.get_data("status") == "broken": 168 elif self.get_data("status") == "broken":
168 return "These broken pipes look important." 169 return _("These broken pipes look important.")
169 elif self.get_data("status") == "replaced": 170 elif self.get_data("status") == "replaced":
170 return "The pipes have been repaired but are the repairs aren't airtight, yet" 171 return _("The pipes have been repaired but are the repairs aren't airtight, yet")
171 else: 172 else:
172 return "Your fix looks like it's holding up well." 173 return _("Your fix looks like it's holding up well.")
173 174
174 def interact_with_machete(self, item): 175 def interact_with_machete(self, item):
175 if self.get_data("status") == "blocked": 176 if self.get_data("status") == "blocked":
176 self.set_data("status", "broken") 177 self.set_data("status", "broken")
177 self.set_interact("broken") 178 self.set_interact("broken")
178 return Result("With a flurry of disgusting mutant vegetable " 179 return Result(_("With a flurry of disgusting mutant vegetable "
179 "chunks, you clear the overgrown broccoli away from " 180 "chunks, you clear the overgrown broccoli away from "
180 "the access panel and reveal some broken tubes. " 181 "the access panel and reveal some broken tubes. "
181 "They look important.", 182 "They look important."),
182 soundfile='chopping.ogg') 183 soundfile='chopping.ogg')
183 elif self.get_data("status") == "broken": 184 elif self.get_data("status") == "broken":
184 return Result("It looks broken enough already.") 185 return Result(_("It looks broken enough already."))
185 elif self.get_data("status") == "replaced": 186 elif self.get_data("status") == "replaced":
186 return Result("Cutting holes won't repair the leaks.") 187 return Result(_("Cutting holes won't repair the leaks."))
187 else: 188 else:
188 return Result("After all that effort fixing it, chopping it to " 189 return Result(_("After all that effort fixing it, chopping it to "
189 "bits doesn't seem very smart.") 190 "bits doesn't seem very smart."))
190 191
191 def interact_with_cryo_pipes_three(self, item): 192 def interact_with_cryo_pipes_three(self, item):
192 if self.get_data("status") == "blocked": 193 if self.get_data("status") == "blocked":
193 return Result("It would get lost in the fronds.") 194 return Result(_("It would get lost in the fronds."))
194 else: 195 else:
195 self.state.remove_inventory_item(item.name) 196 self.state.remove_inventory_item(item.name)
196 self.set_data('status', 'replaced') 197 self.set_data('status', 'replaced')
197 self.set_interact("replaced") 198 self.set_interact("replaced")
198 self.scene.set_data('life support status', 'replaced') 199 self.scene.set_data('life support status', 'replaced')
199 return Result( 200 return Result(
200 "The pipes slot neatly into place, but don't make an airtight seal. " 201 _("The pipes slot neatly into place, but don't make an airtight seal. "
201 "One of the pipes has cracked slightly as well." 202 "One of the pipes has cracked slightly as well.")
202 ) 203 )
203 204
204 def interact_with_duct_tape(self, item): 205 def interact_with_duct_tape(self, item):
205 if self.get_data("status") == "broken": 206 if self.get_data("status") == "broken":
206 return Result("It would get lost in the fronds.") 207 return Result(_("It would get lost in the fronds."))
207 elif self.get_data("status") == 'fixed': 208 elif self.get_data("status") == 'fixed':
208 return Result("There's quite enough tape on the ducting already.") 209 return Result(_("There's quite enough tape on the ducting already."))
209 else: 210 else:
210 self.set_data("fixed", True) 211 self.set_data("fixed", True)
211 self.set_data("status", "fixed") 212 self.set_data("status", "fixed")
212 self.set_interact("fixed") 213 self.set_interact("fixed")
213 self.scene.set_data('life support status', 'fixed') 214 self.scene.set_data('life support status', 'fixed')
214 # TODO: A less anticlimactic climax? 215 # TODO: A less anticlimactic climax?
215 return Result("It takes quite a lot of tape, but eventually everything is" 216 return Result(_("It takes quite a lot of tape, but eventually everything is"
216 " airtight and ready to hold pressure. Who'd've thought duct" 217 " airtight and ready to hold pressure. Who'd've thought duct"
217 " tape could actually be used to tape ducts?") 218 " tape could actually be used to tape ducts?"))
218 219
219 def interact_without(self): 220 def interact_without(self):
220 if self.get_data("status") == "blocked": 221 if self.get_data("status") == "blocked":
221 return Result("The mutant broccoli resists your best efforts.") 222 return Result(_("The mutant broccoli resists your best efforts."))
222 elif self.get_data("status") == "broken": 223 elif self.get_data("status") == "broken":
223 return Result("Shoving the broken pipes around doesn't help much.") 224 return Result(_("Shoving the broken pipes around doesn't help much."))
224 elif self.get_data("status") == "replaced": 225 elif self.get_data("status") == "replaced":
225 return Result("Do you really want to hold it together for the " 226 return Result(_("Do you really want to hold it together for the "
226 "rest of the voyage?") 227 "rest of the voyage?"))
227 else: 228 else:
228 return Result("You don't find any leaks. Good job, Prisoner %s." % PLAYER_ID) 229 return Result(_("You don't find any leaks. Good job, Prisoner %s.") % PLAYER_ID)
229 230
230 231
231 class Boomslang(Thing): 232 class Boomslang(Thing):
232 NAME = 'mess.boomslang' 233 NAME = 'mess.boomslang'
233 234
282 'taken': False, 283 'taken': False,
283 } 284 }
284 285
285 def interact_without(self): 286 def interact_without(self):
286 if self.get_data('taken'): 287 if self.get_data('taken'):
287 return Result("The remaining bottles leak.") 288 return Result(_("The remaining bottles leak."))
288 self.set_data('taken', True) 289 self.set_data('taken', True)
289 self.set_interact('taken') 290 self.set_interact('taken')
290 self.state.add_inventory_item('detergent_bottle') 291 self.state.add_inventory_item('detergent_bottle')
291 return Result("You pick up an empty dishwashing liquid bottle. You can't find any sponges.") 292 return Result(_("You pick up an empty dishwashing liquid bottle. You can't find any sponges."))
292 293
293 def get_description(self): 294 def get_description(self):
294 return "Empty plastic containers. They used to hold dishwasher soap." 295 return _("Empty plastic containers. They used to hold dishwasher soap.")
295 296
296 297
297 class DetergentBottle(Item): 298 class DetergentBottle(Item):
298 INVENTORY_IMAGE = 'bottle_empty.png' 299 INVENTORY_IMAGE = 'bottle_empty.png'
299 CURSOR = CursorSprite('bottle_empty_cursor.png', 27, 7) 300 CURSOR = CursorSprite('bottle_empty_cursor.png', 27, 7)