comparison gamelib/scenes/map.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 """Neurally implanted schematic for moving around on the ship.
2
3 It is illegal for prisoners in transit to activate such an
4 implant. Failure to comply carries a minimum sentence of
5 six months.
6
7 Many parts of the ship are derelict and inaccessible.
8 """
9
10 from pyntnclick.i18n import _
11 from pyntnclick.state import Scene, Thing, Result
12 from pyntnclick.scenewidgets import (InteractRectUnion, InteractUnion,
13 InteractText, InteractNoImage)
14
15 from gamelib.scenes.game_constants import PLAYER_ID
16 from gamelib.scenes.game_widgets import make_jim_dialog, make_sentence_dialog
17
18
19 class Map(Scene):
20
21 FOLDER = "map"
22 BACKGROUND = 'map.png'
23
24 INITIAL_DATA = {
25 'implant': True,
26 }
27
28 def setup(self):
29 self.add_thing(ToCryo())
30 self.add_thing(ToBridge())
31 self.add_thing(ToMess())
32 self.add_thing(ToEngine())
33 self.add_thing(ToMachine())
34 self.add_thing(ToCrew())
35 self.add_thing(InaccessibleArea())
36 self.add_thing(HydroponicsArea())
37
38 def enter(self):
39 if self.get_data('implant'):
40 self.set_data('implant', False)
41 ai1 = make_jim_dialog(
42 _("Under the terms of the emergency conscription "
43 "act, I have downloaded the ship's schematics to your "
44 "neural implant to help you navigate around the ship."),
45 self.game)
46 if ai1:
47 self.state.increase_sentence(3)
48 return ai1, make_jim_dialog(_("Prisoner %s, you are a "
49 "class 1 felon. Obtaining access to the ship's schematics "
50 "constitutes a level 2 offence and carries a minimal penalty "
51 "of an additional 3 years on your sentence.") % PLAYER_ID,
52 self.game), make_sentence_dialog(PLAYER_ID, self.game)
53
54
55 class DoorThing(Thing):
56
57 # name of destination
58 DEST = None
59
60 def interact(self, _item):
61 """Go to destination."""
62 if self.DEST in self.game.scenes:
63 self.game.change_scene(self.DEST)
64
65
66 class ToCryo(DoorThing):
67 "Way to cryo room."
68
69 NAME = "map.tocryo"
70 DEST = "cryo"
71
72 INTERACTS = {
73 'door': InteractUnion((
74 InteractNoImage(515, 158, 56, 68),
75 InteractText(361, 512, 245, 33, _("Prisoner cryo chambers"),
76 'white', 20, 'Monospace.ttf'),
77 ))
78 }
79
80 INITIAL = 'door'
81
82
83 class ToBridge(DoorThing):
84 "Way to bridge room."
85
86 NAME = "map.tobridge"
87 DEST = "bridge"
88
89 INTERACTS = {
90 'door': InteractUnion((
91 InteractNoImage(36, 260, 60, 83),
92 InteractText(26, 170, 71, 33, _("Bridge"), 'white', 20,
93 'Monospace.ttf'),
94 ))
95 }
96
97 INITIAL = 'door'
98
99
100 class ToMess(DoorThing):
101 "Way to cryo room."
102
103 NAME = "map.tomess"
104 DEST = "mess"
105
106 INTERACTS = {
107 'door': InteractUnion((
108 InteractNoImage(395, 262, 64, 80),
109 InteractText(341, 430, 110, 33, _("Mess hall"), 'white', 20,
110 'Monospace.ttf'),
111 ))
112 }
113
114 INITIAL = 'door'
115
116
117 class ToEngine(DoorThing):
118 "Way to engine room."
119
120 NAME = "map.toengine"
121 DEST = "engine"
122
123 INTERACTS = {
124 'door': InteractUnion((
125 InteractNoImage(691, 279, 76, 54),
126 InteractText(662, 496, 128, 33, _("Engine room"), 'white', 20,
127 'Monospace.ttf'),
128 ))
129 }
130
131 INITIAL = 'door'
132
133 def interact(self, item):
134 if not self.game.is_in_inventory('helmet:'):
135 return Result(_('The airlock refuses to open. The automated'
136 ' voice says: "Hull breach beyond this door. Personnel'
137 ' must be equipped for vacuum before entry."'))
138 else:
139 return super(ToEngine, self).interact(item)
140
141
142 class ToMachine(DoorThing):
143 "Way to machine room."
144
145 NAME = "map.tomachine"
146 DEST = "machine"
147
148 INTERACTS = {
149 'door': InteractUnion((
150 InteractNoImage(608, 156, 57, 72),
151 InteractText(578, 83, 140, 33, _("Machine room"), 'white', 20,
152 'Monospace.ttf'),
153 ))
154 }
155
156 INITIAL = 'door'
157
158
159 class ToCrew(DoorThing):
160 "Way to crew quarters."
161
162 NAME = "map.tocrew_quarters"
163 DEST = "crew_quarters"
164
165 INTERACTS = {
166 'door': InteractUnion((
167 InteractNoImage(210, 321, 37, 64),
168 InteractText(69, 460, 160, 33, _("Crew quarters"), 'white', 20,
169 'Monospace.ttf'),
170 ))
171 }
172
173 INITIAL = 'door'
174
175
176 class InaccessibleArea(Thing):
177 NAME = 'map.inaccessible'
178
179 INTERACTS = {
180 'areas': InteractRectUnion((
181 (207, 227, 39, 63),
182 (256, 225, 35, 64),
183 (259, 322, 34, 64),
184 (514, 380, 58, 66),
185 (607, 377, 60, 70),
186 ))
187 }
188
189 INITIAL = 'areas'
190
191 def interact(self, _item):
192 return Result(_("You look in the door, but just see empty space: "
193 "that room appears to have been obliterated by "
194 "meteors."))
195
196
197 class HydroponicsArea(Thing):
198 NAME = 'map.hydroponics'
199
200 INTERACTS = {
201 'areas': InteractUnion((
202 InteractNoImage(314, 263, 73, 81),
203 InteractText(313, 132, 140, 33, _("Hydroponics"), 'white', 20,
204 'Monospace.ttf'),
205 ))
206 }
207
208 INITIAL = 'areas'
209
210 def interact(self, _item):
211 return Result(_("Peering in through the window, you see that the "
212 "entire chamber is overgrown with giant broccoli. "
213 "It would take you years to cut a path through that."))
214
215
216 SCENES = [Map]