comparison gamelib/scenes/map.py @ 408:308a433c4713

Initial map hookup
author Stefano Rivera <stefano@rivera.za.net>
date Sat, 28 Aug 2010 22:05:50 +0200
parents 41ee3fc71404
children 4ce318029cd1
comparison
equal deleted inserted replaced
407:c7a6846262e3 408:308a433c4713
16 16
17 17
18 class Map(Scene): 18 class Map(Scene):
19 19
20 FOLDER = "map" 20 FOLDER = "map"
21 BACKGROUND = None # TODO 21 BACKGROUND = 'map.png'
22 22
23 INITIAL_DATA = { 23 INITIAL_DATA = {
24 'accessible': True, 24 'accessible': True,
25 'implant': True, 25 'implant': True,
26 } 26 }
27 27
28 def __init__(self, state): 28 def __init__(self, state):
29 super(Map, self).__init__(state) 29 super(Map, self).__init__(state)
30 self.add_thing(ToCryo()) 30 self.add_thing(ToCryo())
31 self.add_thing(ToBridge()) 31 self.add_thing(ToBridge())
33 self.add_thing(ToEngine()) 33 self.add_thing(ToEngine())
34 self.add_thing(ToMachine()) 34 self.add_thing(ToMachine())
35 self.add_thing(ToCrew()) 35 self.add_thing(ToCrew())
36 36
37 def enter(self): 37 def enter(self):
38 for door_thing in self.things.values():
39 door_thing.check_dest()
40 if self.get_data('implant'): 38 if self.get_data('implant'):
41 self.set_data('implant', False) 39 self.set_data('implant', False)
42 ai1 = make_jim_dialog( 40 ai1 = make_jim_dialog(
43 "Under the terms of the emergency conscription " 41 "Under the terms of the emergency conscription "
44 "act, I have downloaded the ship's schematics to your " 42 "act, I have downloaded the ship's schematics to your "
65 else: 63 else:
66 return Result("You can't go there right now.") 64 return Result("You can't go there right now.")
67 else: 65 else:
68 return Result("You *could* go there, but it doesn't actually exist.") 66 return Result("You *could* go there, but it doesn't actually exist.")
69 67
70 def check_dest(self):
71 if self.DEST in self.state.scenes:
72 if self.state.scenes[self.DEST].get_data('accessible'):
73 self.set_interact('accessible')
74 else:
75 self.set_interact('inaccessible')
76
77 68
78 class ToCryo(DoorThing): 69 class ToCryo(DoorThing):
79 "Way to cryo room." 70 "Way to cryo room."
80 71
81 NAME = "map.tocryo" 72 NAME = "map.tocryo"
82 DEST = "cryo" 73 DEST = "cryo"
83 74
84 INTERACTS = { 75 INTERACTS = {
85 "inaccessible": InteractText(100, 200, "To Cryo"), 76 'door': InteractRectUnion((
86 "accessible": InteractText(100, 200, "To Cryo", (0, 127, 0)), 77 (515, 158, 56, 68),
87 } 78 (361, 519, 245, 29),
79 ))
80 }
88 81
89 INITIAL = "inaccessible" 82 INITIAL = 'door'
90 83
91 84
92 class ToBridge(DoorThing): 85 class ToBridge(DoorThing):
93 "Way to bridge room." 86 "Way to bridge room."
94 87
95 NAME = "map.tobridge" 88 NAME = "map.tobridge"
96 DEST = "bridge" 89 DEST = "bridge"
97 90
98 INTERACTS = { 91 INTERACTS = {
99 "inaccessible": InteractText(300, 200, "To Bridge"), 92 'door': InteractRectUnion((
100 "accessible": InteractText(300, 200, "To Bridge", (0, 127, 0)), 93 (36, 260, 60, 83),
101 } 94 (26, 177, 71, 21),
95 ))
96 }
102 97
103 INITIAL = "inaccessible" 98 INITIAL = 'door'
104 99
105 100
106 class ToMess(DoorThing): 101 class ToMess(DoorThing):
107 "Way to cryo room." 102 "Way to cryo room."
108 103
109 NAME = "map.tomess" 104 NAME = "map.tomess"
110 DEST = "mess" 105 DEST = "mess"
111 106
112 INTERACTS = { 107 INTERACTS = {
113 "inaccessible": InteractText(100, 300, "To Mess"), 108 'door': InteractRectUnion((
114 "accessible": InteractText(100, 300, "To Mess", (0, 127, 0)), 109 (395, 262, 64, 80),
115 } 110 (341, 434, 110, 27),
111 ))
112 }
116 113
117 INITIAL = "inaccessible" 114 INITIAL = 'door'
118 115
119 116
120 class ToEngine(DoorThing): 117 class ToEngine(DoorThing):
121 "Way to engine room." 118 "Way to engine room."
122 119
123 NAME = "map.toengine" 120 NAME = "map.toengine"
124 DEST = "engine" 121 DEST = "engine"
125 122
126 INTERACTS = { 123 INTERACTS = {
127 "inaccessible": InteractText(300, 300, "To Engine"), 124 'door': InteractRectUnion((
128 "accessible": InteractText(300, 300, "To Engine", (0, 127, 0)), 125 (691, 279, 76, 54),
129 } 126 (662, 500, 128, 23),
127 ))
128 }
130 129
131 INITIAL = "inaccessible" 130 INITIAL = 'door'
132 131
133 def interact_without(self): 132 def interact_without(self):
134 if not self.state.is_in_inventory('helmet'): 133 if not self.state.is_in_inventory('helmet'):
135 return Result('The airlock refuses to open. The automated' 134 return Result('The airlock refuses to open. The automated'
136 ' voice says "Hull breach beyond this door. Personnel' 135 ' voice says "Hull breach beyond this door. Personnel'
144 143
145 NAME = "map.tomachine" 144 NAME = "map.tomachine"
146 DEST = "machine" 145 DEST = "machine"
147 146
148 INTERACTS = { 147 INTERACTS = {
149 "inaccessible": InteractText(100, 400, "To Machine"), 148 'door': InteractRectUnion((
150 "accessible": InteractText(100, 400, "To Machine", (0, 127, 0)), 149 (608, 156, 57, 72),
151 } 150 (578, 91, 140, 23),
151 ))
152 }
152 153
153 INITIAL = "inaccessible" 154 INITIAL = 'door'
154 155
155 156
156 class ToCrew(DoorThing): 157 class ToCrew(DoorThing):
157 "Way to crew quarters." 158 "Way to crew quarters."
158 159
159 NAME = "map.tocrew_quarters" 160 NAME = "map.tocrew_quarters"
160 DEST = "crew_quarters" 161 DEST = "crew_quarters"
161 162
162 INTERACTS = { 163 INTERACTS = {
163 "inaccessible": InteractText(300, 400, "To Crew Quarters"), 164 'door': InteractRectUnion((
164 "accessible": InteractText(300, 400, "To Crew Quarters", (0, 127, 0)), 165 (210, 321, 37, 64),
165 } 166 (69, 469, 148, 26),
167 ))
168 }
166 169
167 INITIAL = "inaccessible" 170 INITIAL = 'door'
168 171
169 172
170 SCENES = [Map] 173 SCENES = [Map]