Mercurial > boomslang
comparison gamelib/scenes/engine.py @ 285:2ec328aeeaf8
Engine room mostly hooked up
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Fri, 27 Aug 2010 23:35:18 +0200 |
parents | 3b4a78422201 |
children | 6d93e04036c9 |
comparison
equal
deleted
inserted
replaced
284:c6e9939aacf8 | 285:2ec328aeeaf8 |
---|---|
1 """Engine room where things need to be repaired.""" | 1 """Engine room where things need to be repaired.""" |
2 | 2 |
3 from gamelib.cursor import CursorSprite | |
3 from gamelib.state import Scene, Item, Thing, Result | 4 from gamelib.state import Scene, Item, Thing, Result |
4 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage, | 5 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage, |
5 InteractRectUnion, InteractImage, | 6 InteractRectUnion, InteractImage, |
6 InteractAnimated, GenericDescThing) | 7 InteractAnimated, GenericDescThing) |
7 | 8 |
15 'accessible': True, | 16 'accessible': True, |
16 } | 17 } |
17 | 18 |
18 def __init__(self, state): | 19 def __init__(self, state): |
19 super(Engine, self).__init__(state) | 20 super(Engine, self).__init__(state) |
21 self.add_item(CanOpener('canopener')) | |
22 self.add_thing(CanOpenerThing()) | |
23 self.add_item(BrokenSuperconductor('superconductor_broken')) | |
24 self.add_thing(SuperconductorSocket()) | |
20 self.add_thing(ToMap()) | 25 self.add_thing(ToMap()) |
26 self.add_thing(GenericDescThing('engine.body', 1, | |
27 "Dead. He must have suffocated in the vacuum.", | |
28 ( | |
29 (594, 387, 45, 109), | |
30 (549, 475, 60, 55), | |
31 ) | |
32 )) | |
33 self.add_thing(GenericDescThing('engine.controlpanel', 1, | |
34 "A control panel. It seems dead.", | |
35 ( | |
36 (513, 330, 58, 50), | |
37 ) | |
38 )) | |
39 self.add_thing(GenericDescThing('engine.computer_console', 1, | |
40 "A computer console. It seems dead", | |
41 ( | |
42 (293, 287, 39, 36), | |
43 ) | |
44 )) | |
45 self.add_thing(GenericDescThing('engine.superconductors', 1, | |
46 "Superconductors. The engines must be power hogs.", | |
47 ( | |
48 (679, 246, 50, 56), | |
49 (473, 277, 28, 23), | |
50 (381, 224, 26, 22), | |
51 ) | |
52 )) | |
53 self.add_thing(GenericDescThing('engine.floor_hole', 1, | |
54 "A gaping hole in the floor of the room. I'm guessing that's why there's a vacuum in here.", | |
55 ( | |
56 (257, 493, 141, 55), | |
57 (301, 450, 95, 45), | |
58 (377, 422, 19, 29), | |
59 (239, 547, 123, 39), | |
60 ) | |
61 )) | |
62 self.add_thing(GenericDescThing('engine.cryo_containers', 1, | |
63 "Those are cryo-fluid containers. They look empty", | |
64 ( | |
65 (129, 246, 135, 160), | |
66 ) | |
67 )) | |
68 self.add_thing(GenericDescThing('engine.empty_cans', 1, | |
69 "Empty Chocolate-Covered-Bacon Cans? He must have got in early", | |
70 ( | |
71 (562, 422, 30, 31), | |
72 ) | |
73 )) | |
74 self.add_thing(GenericDescThing('engine.engines', 1, | |
75 "The engines. They don't look like they are working.", | |
76 ( | |
77 (342, 261, 109, 81), | |
78 ) | |
79 )) | |
80 self.add_thing(GenericDescThing('engine.laser_cutter', 1, | |
81 "A burned out laser cutter. It may be responsible for the hole in the floor.", | |
82 ( | |
83 (120, 466, 115, 67), | |
84 ) | |
85 )) | |
86 self.add_thing(GenericDescThing('engine.spare_fuel_line', 1, | |
87 "The spare fuel line. If something went wrong with the main one, you would hook that one up.", | |
88 ( | |
89 (512, 49, 68, 44), | |
90 ) | |
91 )) | |
92 | |
21 | 93 |
22 def enter(self): | 94 def enter(self): |
23 return Result("Somewhere in the darkness the engine waits and bides its time.") | 95 return Result("You enter the engine room. Even if there wasn't a vacuum " |
96 "it would be errily quiet.") | |
97 | |
98 class CanOpener(Item): | |
99 INVENTORY_IMAGE = 'triangle.png' | |
100 CURSOR = CursorSprite('triangle.png', 25, 23) | |
101 | |
102 | |
103 class CanOpenerThing(Thing): | |
104 NAME = 'engine.canopener' | |
105 | |
106 INTERACTS = { | |
107 'canopener': InteractImage(565, 456, 'can_opener.png'), | |
108 } | |
109 | |
110 INITIAL = 'canopener' | |
111 | |
112 def get_description(self): | |
113 return "A can opener. Looks like you won't be starving" | |
114 | |
115 def interact_without(self): | |
116 self.state.add_inventory_item('canopener') | |
117 self.scene.remove_thing(self) | |
118 return Result("You pick up the can opener. It looks brand new, " | |
119 "the vacuum has kept it in perfect condition.") | |
120 | |
121 | |
122 class BrokenSuperconductor(Item): | |
123 INVENTORY_IMAGE = 'superconductor_broken.png' | |
124 CURSOR = CursorSprite('superconductor_broken_cursor.png', 13, 19) | |
125 | |
126 | |
127 class SuperconductorSocket(Thing): | |
128 NAME = 'engine.superconductor' | |
129 | |
130 INTERACTS = { | |
131 'broken': InteractImage(565, 263, 'superconductor_broken.png'), | |
132 'removed': InteractNoImage(565, 263, 26, 39), | |
133 'fixed': InteractImage(565, 263, 'superconductor_fixed.png'), | |
134 } | |
135 | |
136 INITIAL = 'broken' | |
137 | |
138 INITIAL_DATA = { | |
139 'present': True, | |
140 'working': False, | |
141 } | |
142 | |
143 def get_description(self): | |
144 if self.get_data('present') and not self.get_data('working'): | |
145 return "That superconductor looks burned out. It's wedged in there pretty firmly" | |
146 elif not self.get_data('present'): | |
147 return "An empty superconductor socket" | |
148 else: | |
149 return "A working superconductor." | |
150 | |
151 def interact_without(self): | |
152 if self.get_data('present') and not self.get_data('working'): | |
153 return Result("It's wedged in there pretty firmly, it won't come out.") | |
154 elif self.get_data('working'): | |
155 return Result("You decide that working engines are more important than having a shiny superconductor") | |
156 Thing.interact_without() | |
157 | |
158 def interact_with_machete(self, item): | |
159 if self.get_data('present') and not self.get_data('working'): | |
160 self.set_interact('removed') | |
161 self.set_data('present', False) | |
162 self.state.add_inventory_item('superconductor_broken') | |
163 return Result("With leverage, the burned-out superconductor snaps out.") | |
164 Thing.interact_without() | |
165 | |
166 def interact_with_superconductor(self, item): | |
167 if not self.get_data('present'): | |
168 self.set_interact('fixed') | |
169 self.set_data('present', True) | |
170 self.set_data('working', True) | |
171 self.state.remove_inventory_item(item.name) | |
172 return Result("The chair's superconductor looks over-specced for this job, but it should work") | |
173 else: | |
174 return Result("It might help to remove the broken superconductor first") | |
24 | 175 |
25 | 176 |
26 class ToMap(Door): | 177 class ToMap(Door): |
27 | 178 |
28 SCENE = "engine" | 179 SCENE = "engine" |
31 "door": InteractNoImage(663, 360, 108, 193), | 182 "door": InteractNoImage(663, 360, 108, 193), |
32 } | 183 } |
33 | 184 |
34 INITIAL = "door" | 185 INITIAL = "door" |
35 | 186 |
187 def get_description(self): | |
188 return "The airlock leads back to the rest of the ship." | |
36 | 189 |
37 SCENES = [Engine] | 190 SCENES = [Engine] |