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