# HG changeset patch # User Simon Cross # Date 1282668772 -7200 # Node ID 97c5ff0a05bb433f1fa420081a8b34dcfbce85bd # Parent 11afefc4aeaf4d4348e1ca3c9c6d961503562ea2 Hook up map. diff -r 11afefc4aeaf -r 97c5ff0a05bb gamelib/scenes/cryo.py --- a/gamelib/scenes/cryo.py Tue Aug 24 18:38:44 2010 +0200 +++ b/gamelib/scenes/cryo.py Tue Aug 24 18:52:52 2010 +0200 @@ -114,8 +114,8 @@ if self.get_data('door') != "open": return Result("It moves slightly and then stops. A chain on the other side is preventing it from opening completely.") else: - self.state.set_current_scene('bridge') - return Result("you leave the room, hoping to never return.") + self.state.set_current_scene('map') + return Result("You leave the room, hoping to never return.") def interact_default(self, item): return Result(random.choice([ diff -r 11afefc4aeaf -r 97c5ff0a05bb gamelib/scenes/map.py --- a/gamelib/scenes/map.py Tue Aug 24 18:38:44 2010 +0200 +++ b/gamelib/scenes/map.py Tue Aug 24 18:52:52 2010 +0200 @@ -7,7 +7,7 @@ Many parts of the ship are derelict and inaccessible. """ -from gamelib.state import Scene, Item, Thing, InteractText +from gamelib.state import Scene, Item, Thing, InteractText, Result class Map(Scene): @@ -28,10 +28,23 @@ self.add_thing(ToMachine()) -class ToCryo(Thing): +class DoorThing(Thing): + + # name of destination + DEST = None + + def interact_without(self): + """Go to destination.""" + if self.DEST in self.state.scenes: + self.state.set_current_scene('bridge') + return Result("You head for the %s." % self.DEST) + + +class ToCryo(DoorThing): "Way to cryo room." NAME = "map.tocryo" + DEST = "cryo" INTERACTS = { "room": InteractText(100, 200, "To Cryo"), @@ -40,10 +53,11 @@ INITIAL = "room" -class ToBridge(Thing): +class ToBridge(DoorThing): "Way to bridge room." NAME = "map.tobridge" + DEST = "bridge" INTERACTS = { "room": InteractText(300, 200, "To Bridge"), @@ -52,10 +66,11 @@ INITIAL = "room" -class ToMess(Thing): +class ToMess(DoorThing): "Way to cryo room." NAME = "map.tomess" + DEST = "mess" INTERACTS = { "room": InteractText(100, 300, "To Mess"), @@ -68,6 +83,7 @@ "Way to engine room." NAME = "map.toengine" + DEST = "engine" INTERACTS = { "room": InteractText(300, 300, "To Engine"), @@ -76,10 +92,11 @@ INITIAL = "room" -class ToMachine(Thing): +class ToMachine(DoorThing): "Way to machine room." NAME = "map.tomachine" + DEST = "machine" INTERACTS = { "room": InteractText(100, 400, "To Machine"),