Skip to content

Instantly share code, notes, and snippets.

@CapnKernel
Last active December 16, 2015 03:59
Show Gist options
  • Save CapnKernel/5373650 to your computer and use it in GitHub Desktop.
Save CapnKernel/5373650 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
pages = {
"start": {
"text": "It's a dark night outside. Somewhere a wolf howls.",
"prompt": "Where will you take shelter, the haunted house, or the bat cave?",
"next": ("haunted house", "bat cave"),
},
"haunted house": {
"text": "By the light of your flickering torch, you're able to make it to\n" \
"the haunted house. You find a candle and light it. You can see\n" \
"a winding staircase, and a hallway.",
"prompt": "Go upstairs, or into the hallway?",
"next": ("upstairs", "hallway"),
},
"upstairs": {
"text": "As you reach upstairs, something whooshes past you, knocking out\n" \
"your candle. Oh no, it's coming back again! You feel its fur\n" \
"brushing against your face. You wake in fright to find your cat\n" \
"is on your bed, meowing at you. It was only a dream!",
},
"hallway": {
"text": "You move into the hallway, and trip over into an open coffin. The\n" \
"door slams shut. The haunted house has claimed another victim!",
},
"bat cave": {
"text": "The rocks are very slippery here, too slippery. You're unable to\n" \
"keep your grip. The bats will feast well tonight!",
},
}
where = "start"
while True:
print
print pages[where]['text']
print
if 'next' not in pages[where]:
break
while True:
print "%s (%s)?" % (pages[where]['prompt'], ", ".join(pages[where]['next'])),
to = raw_input()
if to in pages[where]['next']:
where = to
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment