comparison gamelib/scenes/bridge.py @ 222:b03debaec72d

Things and Items for bridge
author Stefano Rivera <stefano@rivera.za.net>
date Thu, 26 Aug 2010 21:51:27 +0200
parents 5e5d71e40e54
children b0add10f7556
comparison
equal deleted inserted replaced
221:bcb7b2093118 222:b03debaec72d
1 """Bridge where the final showdown with the AI occurs.""" 1 """Bridge where the final showdown with the AI occurs."""
2 2
3 from gamelib.cursor import CursorSprite
3 from gamelib.state import Scene, Item, Thing, Result, InteractText 4 from gamelib.state import Scene, Item, Thing, Result, InteractText
4
5 5
6 class Bridge(Scene): 6 class Bridge(Scene):
7 7
8 FOLDER = "bridge" 8 FOLDER = "bridge"
9 BACKGROUND = None # TODO 9 BACKGROUND = None # TODO
12 'accessible': True, 12 'accessible': True,
13 } 13 }
14 14
15 def __init__(self, state): 15 def __init__(self, state):
16 super(Bridge, self).__init__(state) 16 super(Bridge, self).__init__(state)
17 self.add_item(Superconductor('superconductor'))
18 self.add_item(Stethoscope('stethoscope'))
17 self.add_thing(ToMap()) 19 self.add_thing(ToMap())
20 self.add_thing(MassageChair())
21 self.add_thing(StethoscopeThing())
18 22
19 def enter(self): 23 def enter(self):
20 return Result("The bridge is in a sorry, shabby state") 24 return Result("The bridge is in a sorry, shabby state")
21 25
22 26
35 def interact_without(self): 39 def interact_without(self):
36 """Go to map.""" 40 """Go to map."""
37 self.state.set_current_scene("map") 41 self.state.set_current_scene("map")
38 42
39 43
44 class MassageChair(Thing):
45 "The captain's massage chair, contains superconductor"
46
47 NAME = 'bridge.massagechair'
48
49 INTERACTS = {
50 'chair': InteractText(200, 200, 'Chair'),
51 }
52
53 INITIAL = 'chair'
54
55 INITIAL_DATA = {
56 'contains_superconductor': True,
57 }
58
59 def interact_without(self):
60 return Result(detail_view='chair_detail')
61
62 def get_description(self):
63 if self.get_data('contains_superconductor'):
64 return "A top of the line Massage-o-Matic Captain's Executive Command Chair."
65 return "The chair won't work any more, it has no power."
66
67
68 class Stethoscope(Item):
69 "Used for cracking safes. Found on the doctor on the chair"
70
71 INVENTORY_IMAGE = 'triangle.png'
72 CURSOR = CursorSprite('triangle.png', 20, 30)
73
74
75 class StethoscopeThing(Thing):
76 "Stehoscope on the doctor"
77
78 NAME ='bridge.stethoscope'
79
80 INTERACTS = {
81 'stethoscope': InteractText(300, 200, 'Stethoscope'),
82 }
83
84 INITIAL = 'stethoscope'
85
86 def interact_without(self):
87 self.state.add_inventory_item('stethoscope')
88 self.scene.remove_thing(self)
89 return Result("You pick up the stethoscope and verify that the doctor's "
90 "heart has stoped. Probably a while ago.")
91
92
93 class Superconductor(Item):
94 "Used for connecting high-powered parts of the ship up"
95
96 INVENTORY_IMAGE = 'triangle.png'
97 CURSOR = CursorSprite('triangle.png', 20, 30)
98
99
100 class SuperconductorThing(Thing):
101 "Superconductor from the massage chair."
102
103 NAME ='bridge.superconductor'
104
105 INTERACTS = {
106 'superconductor': InteractText(100, 200, 'Superconductor'),
107 }
108
109 INITIAL = 'superconductor'
110
111 def interact_without(self):
112 self.state.add_inventory_item('superconductor')
113 self.state.current_scene.things['bridge.massagechair'] \
114 .set_data('contains_superconductor', False)
115 self.scene.remove_thing(self)
116 return Result("You pick up the stethoscope and verify that the doctor's "
117 "heart has stoped. Probably a while ago.")
118
119 class ChairDetail(Scene):
120
121 FOLDER = 'bridge'
122 BACKGROUND = 'chair_detail.png'
123 NAME = 'chair_detail'
124
125 SIZE = (300, 300)
126
127 def __init__(self, state):
128 super(ChairDetail, self).__init__(state)
129 self.add_thing(SuperconductorThing())
130
131
40 SCENES = [Bridge] 132 SCENES = [Bridge]
133 DETAIL_VIEWS = [ChairDetail]