Mercurial > pyntnclick
changeset 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 |
files | gamelib/scenes/cryo.py gamelib/scenes/map.py |
diffstat | 2 files changed, 24 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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([
--- 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"),