comparison gamelib/scenes/map.py @ 131:97c5ff0a05bb

Hook up map.
author Simon Cross <hodgestar+bzr@gmail.com>
date Tue, 24 Aug 2010 18:52:52 +0200
parents 11afefc4aeaf
children 686bb74a52f8
comparison
equal deleted inserted replaced
130:11afefc4aeaf 131:97c5ff0a05bb
5 six months. 5 six months.
6 6
7 Many parts of the ship are derelict and inaccessible. 7 Many parts of the ship are derelict and inaccessible.
8 """ 8 """
9 9
10 from gamelib.state import Scene, Item, Thing, InteractText 10 from gamelib.state import Scene, Item, Thing, InteractText, Result
11 11
12 12
13 class Map(Scene): 13 class Map(Scene):
14 14
15 FOLDER = "map" 15 FOLDER = "map"
26 self.add_thing(ToMess()) 26 self.add_thing(ToMess())
27 self.add_thing(ToEngine()) 27 self.add_thing(ToEngine())
28 self.add_thing(ToMachine()) 28 self.add_thing(ToMachine())
29 29
30 30
31 class ToCryo(Thing): 31 class DoorThing(Thing):
32
33 # name of destination
34 DEST = None
35
36 def interact_without(self):
37 """Go to destination."""
38 if self.DEST in self.state.scenes:
39 self.state.set_current_scene('bridge')
40 return Result("You head for the %s." % self.DEST)
41
42
43 class ToCryo(DoorThing):
32 "Way to cryo room." 44 "Way to cryo room."
33 45
34 NAME = "map.tocryo" 46 NAME = "map.tocryo"
47 DEST = "cryo"
35 48
36 INTERACTS = { 49 INTERACTS = {
37 "room": InteractText(100, 200, "To Cryo"), 50 "room": InteractText(100, 200, "To Cryo"),
38 } 51 }
39 52
40 INITIAL = "room" 53 INITIAL = "room"
41 54
42 55
43 class ToBridge(Thing): 56 class ToBridge(DoorThing):
44 "Way to bridge room." 57 "Way to bridge room."
45 58
46 NAME = "map.tobridge" 59 NAME = "map.tobridge"
60 DEST = "bridge"
47 61
48 INTERACTS = { 62 INTERACTS = {
49 "room": InteractText(300, 200, "To Bridge"), 63 "room": InteractText(300, 200, "To Bridge"),
50 } 64 }
51 65
52 INITIAL = "room" 66 INITIAL = "room"
53 67
54 68
55 class ToMess(Thing): 69 class ToMess(DoorThing):
56 "Way to cryo room." 70 "Way to cryo room."
57 71
58 NAME = "map.tomess" 72 NAME = "map.tomess"
73 DEST = "mess"
59 74
60 INTERACTS = { 75 INTERACTS = {
61 "room": InteractText(100, 300, "To Mess"), 76 "room": InteractText(100, 300, "To Mess"),
62 } 77 }
63 78
66 81
67 class ToEngine(Thing): 82 class ToEngine(Thing):
68 "Way to engine room." 83 "Way to engine room."
69 84
70 NAME = "map.toengine" 85 NAME = "map.toengine"
86 DEST = "engine"
71 87
72 INTERACTS = { 88 INTERACTS = {
73 "room": InteractText(300, 300, "To Engine"), 89 "room": InteractText(300, 300, "To Engine"),
74 } 90 }
75 91
76 INITIAL = "room" 92 INITIAL = "room"
77 93
78 94
79 class ToMachine(Thing): 95 class ToMachine(DoorThing):
80 "Way to machine room." 96 "Way to machine room."
81 97
82 NAME = "map.tomachine" 98 NAME = "map.tomachine"
99 DEST = "machine"
83 100
84 INTERACTS = { 101 INTERACTS = {
85 "room": InteractText(100, 400, "To Machine"), 102 "room": InteractText(100, 400, "To Machine"),
86 } 103 }
87 104