annotate gamelib/scenes/machine.py @ 206:6a52752f4920

some more interacations. Add sound to grinder
author Neil Muller <neil@dip.sun.ac.za>
date Thu, 26 Aug 2010 14:19:57 +0200
parents 9887c68110d8
children 08f39251c6a5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
1 """Machine room where tools and machines are found."""
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
2
151
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
3 from gamelib.state import Scene, Item, Thing, InteractText, Result
194
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
4 from gamelib.cursor import CursorSprite
47
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
5
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
6
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
7 class Machine(Scene):
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
8
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
9 FOLDER = "machine"
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
10 BACKGROUND = None # TODO
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
11
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
12 INITIAL_DATA = {
151
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
13 'accessible': True,
47
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
14 }
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
15
151
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
16 def __init__(self, state):
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
17 super(Machine, self).__init__(state)
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
18 self.add_thing(ToMap())
193
738608e90e9c CloneableItem tweaks and a usable laser welder. zOMG!
Jeremy Thurgood <firxen@gmail.com>
parents: 190
diff changeset
19 self.add_thing(LaserWelder())
194
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
20 self.add_thing(Grinder())
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
21 self.add_item(TitaniumMachete('titanium_machete'))
151
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
22
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
23 def enter(self):
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
24 return Result("The machine room is dark and forbidding.")
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
25
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
26
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
27 class ToMap(Thing):
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
28 "Way to map."
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
29
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
30 NAME = "machine.tomap"
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
31 DEST = "map"
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
32
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
33 INTERACTS = {
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
34 "door": InteractText(100, 200, "To Map"),
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
35 }
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
36
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
37 INITIAL = "door"
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
38
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
39 def interact_without(self):
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
40 """Go to map."""
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
41 self.state.set_current_scene("map")
d00aa26941c4 Add machine and engine rooms to map. Fix typo in name of mess hall doorway thing.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 55
diff changeset
42
47
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
43
190
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
44 class LaserWelder(Thing):
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
45
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
46 NAME = "machine.laser_welder"
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
47
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
48 INTERACTS = {
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
49 "weld": InteractText(200, 200, "Laser welder"),
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
50 }
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
51
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
52 INITIAL = "weld"
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
53
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
54 INITIAL_DATA = {
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
55 'cans_in_place': 0,
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
56 }
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
57
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
58 def interact_without(self):
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
59 if self.get_data('cans_in_place') < 1:
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
60 return Result("The laser welder doesn't currently contain anything weldable.")
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
61 elif self.get_data('cans_in_place') < 3:
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
62 return Result("You'll need more cans than that.")
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
63 else:
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
64 self.set_data('cans_in_place', 0)
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
65 self.state.add_inventory_item('tube_fragments')
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
66 return Result("With high-precision spitzensparken, the cans are welded into a replacement tube.")
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
67
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
68 def interact_with_dented_can(self, item):
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
69 return self.interact_with_empty_can(item)
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
70
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
71 def interact_with_empty_can(self, item):
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
72 starting_cans = self.get_data('cans_in_place')
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
73 if starting_cans < 3:
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
74 self.state.remove_inventory_item(item.name)
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
75 self.set_data('cans_in_place', starting_cans + 1)
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
76 return Result({
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
77 0: "You carefully place the empty can in the area marked 'to weld'.",
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
78 1: "You carefully place the empty can next to the other.",
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
79 2: "You carefully place the empty can next to its mates.",
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
80 }[starting_cans])
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
81 else:
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
82 return Result("The machine has enough cans to weld for the moment.")
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
83
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
84 def get_description(self):
193
738608e90e9c CloneableItem tweaks and a usable laser welder. zOMG!
Jeremy Thurgood <firxen@gmail.com>
parents: 190
diff changeset
85 if self.get_data('cans_in_place') == 0:
738608e90e9c CloneableItem tweaks and a usable laser welder. zOMG!
Jeremy Thurgood <firxen@gmail.com>
parents: 190
diff changeset
86 return "This is a Smith and Wesson 'zOMG' class high-precision laser welder."
738608e90e9c CloneableItem tweaks and a usable laser welder. zOMG!
Jeremy Thurgood <firxen@gmail.com>
parents: 190
diff changeset
87 msg = "The laser welder looks hungry, somehow."
190
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
88 if self.get_data('cans_in_place') == 1:
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
89 msg += " It currently contains an empty can."
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
90 elif self.get_data('cans_in_place') == 2:
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
91 msg += " It currently contains two empty cans."
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
92 elif self.get_data('cans_in_place') == 3:
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
93 msg += " It currently contains three empty cans."
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
94 return msg
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
95
30f2308c1efc Fix tests and add a (currently unhooked) laser welder.
Jeremy Thurgood <firxen@gmail.com>
parents: 151
diff changeset
96
194
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
97 class Grinder(Thing):
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
98
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
99 NAME = "machine.grinder"
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
100
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
101 INTERACTS = {
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
102 "grind": InteractText(200, 300, "Grinder"),
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
103 }
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
104
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
105 INITIAL = "grind"
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
106
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
107 def interact_without(self):
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
108 return Result("It looks like it eats fingers. Perhaps a different approach is in order?")
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
109
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
110 def interact_with_titanium_leg(self, item):
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
111 self.state.replace_inventory_item(item, self.state.items['titanium_machete'])
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
112 return Result("After much delicate grinding and a few close calls with"
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
113 " various body parts, the titanium femur now resembles"
206
6a52752f4920 some more interacations. Add sound to grinder
Neil Muller <neil@dip.sun.ac.za>
parents: 194
diff changeset
114 " a machete more than a bone. Nice and sharp, too.",
6a52752f4920 some more interacations. Add sound to grinder
Neil Muller <neil@dip.sun.ac.za>
parents: 194
diff changeset
115 soundfile="grinder.ogg")
194
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
116
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
117 def get_description(self):
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
118 return "A pretty ordinary, albeit rather industrial, grinding machine."
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
119
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
120
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
121 class TitaniumMachete(Item):
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
122 "Titanium machete, formerly a leg."
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
123
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
124 INVENTORY_IMAGE = "triangle.png"
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
125 CURSOR = CursorSprite('titanium_femur_cursor.png', 47, 3)
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
126
9887c68110d8 Sharp things.
Jeremy Thurgood <firxen@gmail.com>
parents: 193
diff changeset
127
47
8f1fccb8cadf Skeletons for scenes in plot outline.
Simon Cross <simon@simonx>
parents:
diff changeset
128 SCENES = [Machine]