Created
December 9, 2010 21:31
-
-
Save Telltak/735368 to your computer and use it in GitHub Desktop.
first go at homework for lpthw ex 35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import exit | |
items = ["swooping sword", "nutritious nuggets"] | |
options = ["help", "look around"] | |
health = 100 | |
def start(): | |
print "You wake up in a room.\nWhat do you do?" | |
start_options = options | |
while 1: | |
option = raw_input("> ") | |
if option in start_options: | |
if option == "help": | |
print start_options | |
elif option == "look around": | |
visible = """ | |
You look around and see 3 doors. | |
One leads forward, one left and one right. | |
What do you do?""" | |
print visible | |
start_options.append("move forward") | |
start_options.append("move left") | |
start_options.append("move right") | |
while 1: | |
option = raw_input("> ") | |
if option in start_options: | |
if option == "help": | |
print start_options | |
elif option == "look around": | |
print visible | |
elif option == "move forward" or option == "move right": | |
procrastinate() | |
elif option == "move left": | |
troll() | |
else: | |
print option | |
else: | |
print "What did you say?" | |
else: | |
print option | |
else: | |
print "What did you say?" | |
def procrastinate(): | |
print "You are in the room of procrastination, what do you do?" | |
pro_options = options | |
while 1: | |
option = raw_input("> ") | |
if option in pro_options: | |
if option == "help": | |
print pro_options | |
elif option == "look around": | |
visible = """ | |
You look around and see pinball machines, poker tables and a door block by security guards. | |
What do you do?""" | |
print visible | |
pro_options.append("play pinball") | |
pro_options.append("play poker") | |
pro_options.append("open door") | |
while 1: | |
option = raw_input("> ") | |
if option in pro_options: | |
if option == "help": | |
print pro_options | |
elif option == "look around": | |
print visible | |
elif option == "play pinball": | |
die("You play pinball until you die.") | |
elif option == "play poker": | |
die("You play poker until you die.") | |
elif option == "open door": | |
print "The main guard stops you and says\n\"Whoah there, you've only just got in, what's the rush?\"" | |
pro_options.append("attack guards") | |
while 1: | |
option = raw_input("> ") | |
if option in pro_options: | |
if option == "help": | |
print pro_options | |
elif option == "look around": | |
print visible | |
elif option == "play pinball": | |
die("You play pinball until you die.") | |
elif option == "play poker": | |
die("You play poker until you die.") | |
elif option == "open doo": | |
die("The guards get annoyed and stab you") | |
elif option == "attack guards": | |
print "You have killed all the guards, well done!" | |
die("You won!") | |
else: | |
print option | |
else: | |
print "What did you say?" | |
else: | |
print option | |
else: | |
print "What did you say?" | |
else: | |
print option | |
else: | |
print "What did you say?" | |
def troll(): | |
print "You enter a dark room that stinks.\nWhat do you do?" | |
troll_options = options | |
while 1: | |
option = raw_input("> ") | |
if option in troll_options: | |
if option == "help": | |
print troll_options | |
elif option == "look around": | |
visible = "You look around and see a troll, behind are two doors.\nWhat do you do?" | |
print visible | |
troll_options.append("attack") | |
troll_options.append("commit suicide") | |
while 1: | |
option = raw_input("> ") | |
if option in toll_options: | |
if option == "help": | |
print troll_options | |
elif option == "look around": | |
die("You were too slow, the troll saw you and killed you.") | |
elif option == "attack": | |
print "You manage to kill the troll! Well done!" | |
troll_doors() | |
elif option == "commit suicide": | |
die("You decided to die by your own hand than by a troll. Good choice!") | |
else: | |
print option | |
else: | |
print "What did you say?" | |
else: | |
print option | |
else: | |
print "What did you say?" | |
def troll_doors(): | |
print "You see two doors, one leads forward, one to the left.\nWhat do you do?" | |
door_options = options | |
door_options.append("move forward") | |
door_options.append("move left") | |
while 1: | |
option = raw_input("> ") | |
if option in door_options: | |
if option == "help": | |
print door_options | |
elif option == "move forward": | |
antelope() | |
elif option == "move left": | |
potion() | |
else: | |
print option | |
else: | |
print "What did you say?" | |
def antelope(): | |
print "You walk in the room and see an antelope.\nWhat do you do?" | |
ante_options = options | |
ante_options.append("feed antelope") | |
ante_options.append("kill antelope") | |
while 1: | |
option = raw_input("> ") | |
if option in ante_options: | |
if option == "help": | |
print ante_options | |
elif option == "look around": | |
die("You took too long and the antelope killed you.") | |
elif option == "feed antelope": | |
print "The antelope likes you, it lets you past." | |
die("You win! Well done!") | |
elif option == "kill antelope": | |
print "You are an asshole." | |
die("But you still win. Not that I want you to.") | |
else: | |
print option | |
else: | |
print "What did you say?" | |
def potion(): | |
print "Well done, you found a potion!" | |
antelope() | |
def die(text): | |
print text | |
exit(0) | |
start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment