Mercurial > pyntnclick
comparison gamelib/scenes/crew_quarters.py @ 853:f95830b58336
Merge pyntnclick
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Sat, 21 Jun 2014 22:04:35 +0200 |
parents | bdebe693453f |
children |
comparison
equal
deleted
inserted
replaced
546:ad4d6ffd25d7 | 853:f95830b58336 |
---|---|
1 """Crew quarters.""" | 1 """Crew quarters.""" |
2 | 2 |
3 from gamelib.cursor import CursorSprite | 3 from pyntnclick.i18n import _ |
4 from gamelib.state import Scene, Item, Thing, Result | 4 from pyntnclick.cursor import CursorSprite |
5 from gamelib.scenewidgets import (InteractNoImage, InteractImage, | 5 from pyntnclick.state import Scene, Item, Thing, Result |
6 InteractAnimated, GenericDescThing) | 6 from pyntnclick.scenewidgets import ( |
7 InteractNoImage, InteractImage, InteractAnimated, GenericDescThing, | |
8 TakeableThing) | |
7 | 9 |
8 from gamelib.scenes.game_constants import PLAYER_ID | 10 from gamelib.scenes.game_constants import PLAYER_ID |
9 from gamelib.scenes.game_widgets import Door, BaseCamera, make_jim_dialog | 11 from gamelib.scenes.game_widgets import (Door, BaseCamera, make_jim_dialog, |
12 make_sentence_dialog) | |
10 | 13 |
11 | 14 |
12 class CrewQuarters(Scene): | 15 class CrewQuarters(Scene): |
13 | 16 |
14 FOLDER = "crew_quarters" | 17 FOLDER = "crew_quarters" |
15 BACKGROUND = "crew_quarters.png" | 18 BACKGROUND = "crew_quarters.png" |
16 | 19 |
17 OFFSET = (0, -50) | 20 OFFSET = (0, -50) |
18 | 21 |
19 def __init__(self, state): | 22 def setup(self): |
20 super(CrewQuarters, self).__init__(state) | |
21 self.add_thing(ToMap()) | 23 self.add_thing(ToMap()) |
22 self.add_thing(Safe()) | 24 self.add_thing(Safe()) |
23 self.add_thing(FishbowlThing()) | 25 self.add_thing(FishbowlThing()) |
24 self.add_item(Fishbowl('fishbowl')) | 26 self.add_item_factory(Fishbowl) |
25 self.add_item(DuctTape('duct_tape')) | 27 self.add_item_factory(DuctTape) |
26 self.add_item(EscherPoster('escher_poster')) | 28 self.add_item_factory(EscherPoster) |
29 self.add_item_factory(FishbowlHelmet) | |
27 self.add_thing(PosterThing()) | 30 self.add_thing(PosterThing()) |
28 self.add_thing(MonitorCamera()) | 31 self.add_thing(MonitorCamera()) |
29 self.add_thing(GenericDescThing('crew.plant', 1, | 32 self.add_thing(GenericDescThing('crew.plant', 1, |
30 "The plant is doing surprisingly well for centuries of neglect", | 33 _("The plant is doing surprisingly well for centuries of neglect"), |
31 ((624, 215, 61, 108),))) | 34 ((624, 215, 61, 108),))) |
32 self.add_thing(GenericDescThing('crew.cat', 2, | 35 self.add_thing(GenericDescThing('crew.cat', 2, |
33 "A picture of a cat labelled 'Clementine'", | 36 _("A picture of a cat labelled 'Clementine'"), |
34 ((722, 382, 66, 72),))) | 37 ((722, 382, 66, 72),))) |
35 | 38 |
36 | 39 |
37 class ToMap(Door): | 40 class ToMap(Door): |
38 | 41 |
61 INITIAL_DATA = { | 64 INITIAL_DATA = { |
62 'is_cracked': False, | 65 'is_cracked': False, |
63 'has_tape': True, | 66 'has_tape': True, |
64 } | 67 } |
65 | 68 |
69 def select_interact(self): | |
70 if self.get_data('is_cracked'): | |
71 if self.get_data('has_tape'): | |
72 return 'full_safe' | |
73 return 'empty_safe' | |
74 return self.INITIAL | |
75 | |
66 def interact_without(self): | 76 def interact_without(self): |
67 if self.get_data('is_cracked'): | 77 if self.get_data('is_cracked'): |
68 if self.get_data('has_tape'): | 78 if self.get_data('has_tape'): |
69 self.set_data('has_tape', False) | 79 self.set_data('has_tape', False) |
70 self.state.add_inventory_item('duct_tape') | 80 self.game.add_inventory_item('duct_tape') |
71 self.set_interact('empty_safe') | 81 self.set_interact() |
72 return Result("Duct tape. It'll stick to everything except " | 82 return Result(_("Duct tape. It'll stick to everything except " |
73 "ducts, apparently.") | 83 "ducts, apparently.")) |
74 return Result("The perfectly balanced door swings frictionlessly " | 84 return Result(_("The perfectly balanced door swings " |
75 "to and fro. What craftsmanship!") | 85 "frictionlessly to and fro. What craftsmanship!")) |
76 return Result("The safe is locked. This might be an interesting " | 86 return Result(_("The safe is locked. This might be an interesting " |
77 "challenge, if suitable equipment can be found.") | 87 "challenge, if suitable equipment can be found.")) |
78 | 88 |
79 def interact_with_stethoscope(self, item): | 89 def interact_with_stethoscope(self, item): |
80 if self.get_data('is_cracked'): | 90 if self.get_data('is_cracked'): |
81 return Result("It's already unlocked. There's no more challenge.") | 91 return Result(_("It's already unlocked. " |
82 # TODO: Add years to the sentence for safecracking. | 92 "There's no more challenge.")) |
83 # TODO: Wax lyrical some more about safecracking. | 93 # TODO: Wax lyrical some more about safecracking. |
84 self.set_data('is_cracked', True) | 94 self.set_data('is_cracked', True) |
85 self.set_interact('full_safe') | 95 self.set_interact() |
86 return (Result("Even after centuries of neglect, the tumblers slide" | 96 self.state.increase_sentence(20) |
87 " almost silently into place. Turns out the combination" | 97 return (Result(_("Even after centuries of neglect, the tumblers slide" |
88 " was '1 2 3 4 5'. An idiot must keep his luggage in" | 98 " almost silently into place. Turns out the" |
89 " here."), | 99 " combination was '1 2 3 4 5'. An idiot must keep his" |
90 make_jim_dialog("Prisoner %s, you have been observed" | 100 " luggage in here.")), |
91 " committing a felony violation. This will go onto" | 101 make_jim_dialog(_("Prisoner %s, you have been observed" |
92 " your permanent record, and your sentence may be" | 102 " committing a felony violation. This will" |
93 " extended by up to twenty years." | 103 " go onto your permanent record, and your" |
94 % PLAYER_ID, self.state)) | 104 " sentence will be extended by twenty" |
105 " years.") % PLAYER_ID, self.game), | |
106 make_sentence_dialog(PLAYER_ID, self.game)) | |
95 | 107 |
96 def get_description(self): | 108 def get_description(self): |
97 return "Ah, a vintage Knoxx & Co. model QR3. Quaint, but" \ | 109 return _("Ah, a vintage Knoxx & Co. model QR3. Quaint, but" |
98 " reasonably secure." | 110 " reasonably secure.") |
99 | 111 |
100 | 112 |
101 class FishbowlThing(Thing): | 113 class FishbowlThing(Thing): |
102 "A safe, for keeping things safe." | 114 "A safe, for keeping things safe." |
103 | 115 |
112 | 124 |
113 INITIAL_DATA = { | 125 INITIAL_DATA = { |
114 'has_bowl': True, | 126 'has_bowl': True, |
115 } | 127 } |
116 | 128 |
129 def select_interact(self): | |
130 if not self.get_data('has_bowl'): | |
131 return 'fish_no_bowl' | |
132 return self.INITIAL | |
133 | |
117 def interact_without(self): | 134 def interact_without(self): |
118 if not self.get_data('has_bowl'): | 135 if not self.get_data('has_bowl'): |
119 return Result("What's the point of lugging around a very dead" | 136 return Result(_("What's the point of lugging around a very dead" |
120 " fish and a kilogram or so of sand?") | 137 " fish and a kilogram or so of sand?")) |
121 self.set_interact('fish_no_bowl') | |
122 self.set_data('has_bowl', False) | 138 self.set_data('has_bowl', False) |
123 self.state.add_inventory_item('fishbowl') | 139 self.set_interact() |
124 return Result("The fishbowl is useful, but its contents aren't.") | 140 self.game.add_inventory_item('fishbowl') |
141 return Result(_("The fishbowl is useful, but its contents aren't.")) | |
125 | 142 |
126 def get_description(self): | 143 def get_description(self): |
127 if self.get_data('has_bowl'): | 144 if self.get_data('has_bowl'): |
128 return "This fishbowl looks exactly like an old science fiction" \ | 145 return _("This fishbowl looks exactly like an old science fiction" |
129 " space helmet." | 146 " space helmet.") |
130 else: | 147 else: |
131 return "An evicted dead fish and some sand lie forlornly on the" \ | 148 return _("An evicted dead fish and some sand lie forlornly on the" |
132 " table" | 149 " table") |
133 | 150 |
134 | 151 |
135 class Fishbowl(Item): | 152 class Fishbowl(Item): |
136 "A bowl. Sans fish." | 153 "A bowl. Sans fish." |
137 | 154 |
138 INVENTORY_IMAGE = 'fishbowl.png' | 155 INVENTORY_IMAGE = 'fishbowl.png' |
139 CURSOR = CursorSprite('fishbowl.png') | 156 CURSOR = CursorSprite('fishbowl.png') |
140 NAME = "fishbowl" | 157 NAME = "fishbowl" |
141 | 158 |
142 def interact_with_duct_tape(self, item): | 159 def interact_with_duct_tape(self, item): |
143 helmet = FishbowlHelmet('helmet') | 160 self.game.replace_inventory_item(self.name, 'helmet') |
144 self.state.add_item(helmet) | 161 return Result(_("You duct tape the edges of the helmet. The seal is" |
145 self.state.replace_inventory_item(self.name, helmet.name) | 162 " crude, but it will serve as a workable helmet if" |
146 return Result("You duct tape the edges of the helmet. The seal is" | 163 " needed.")) |
147 " crude, but it will serve as a workable helmet if needed.") | |
148 | 164 |
149 | 165 |
150 class FishbowlHelmet(Item): | 166 class FishbowlHelmet(Item): |
151 "A bowl with duct-tape" | 167 "A bowl with duct-tape" |
152 | 168 |
156 | 172 |
157 | 173 |
158 class DuctTape(Item): | 174 class DuctTape(Item): |
159 "A bowl. Sans fish." | 175 "A bowl. Sans fish." |
160 | 176 |
177 NAME = 'duct_tape' | |
161 INVENTORY_IMAGE = 'duct_tape.png' | 178 INVENTORY_IMAGE = 'duct_tape.png' |
162 CURSOR = CursorSprite('duct_tape.png') | 179 CURSOR = CursorSprite('duct_tape.png') |
163 | 180 |
164 | 181 |
165 class MonitorCamera(BaseCamera): | 182 class MonitorCamera(BaseCamera): |
174 'camera_medium_gray.png'), | 191 'camera_medium_gray.png'), |
175 15), | 192 15), |
176 } | 193 } |
177 | 194 |
178 | 195 |
179 class PosterThing(Thing): | 196 class PosterThing(TakeableThing): |
180 "A innocent poster on the wall" | 197 "A innocent poster on the wall" |
181 | 198 |
182 NAME = 'crew.poster' | 199 NAME = 'crew.poster' |
183 | 200 |
184 INTERACTS = { | 201 INTERACTS = { |
185 'poster': InteractImage(29, 166, 'triangle_poster.png'), | 202 'poster': InteractImage(29, 166, 'triangle_poster.png'), |
186 } | 203 } |
187 | 204 |
188 INITIAL = 'poster' | 205 INITIAL = 'poster' |
206 ITEM = 'escher_poster' | |
189 | 207 |
190 def interact_without(self): | 208 def interact_without(self): |
191 self.state.add_inventory_item('escher_poster') | 209 self.take() |
192 self.scene.remove_thing(self) | 210 return Result(_("This poster will go nicely on your bedroom wall.")) |
193 return Result("This poster will go nicely on your bedroom wall.") | |
194 | 211 |
195 def get_description(self): | 212 def get_description(self): |
196 return "A paradoxical poster hangs below the security camera." | 213 return _("A paradoxical poster hangs below the security camera.") |
197 | 214 |
198 | 215 |
199 class EscherPoster(Item): | 216 class EscherPoster(Item): |
200 "A confusing poster to disable JIM" | 217 "A confusing poster to disable JIM" |
201 | 218 |