Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- written for python 2.x
- really? ignoring the state of the art for what reason?
- I would have done this with Ipython but
- Ipython does not handle input at all so...
- here it is for what it is...
- the dead function keeps the if-statements from running amok
- '''
- #what is this and why do we need it?
- from sys import exit
- #using each decision as a function is interesting
- def gold_room():
- print "This room is full of gold. How much do you take?"
- #this only works with python 2.x
- next = raw_input("> ")
- #you are not dead if you include a zero or one? that's just strange
- if "0" in next or "1" in next:
- how_much = int(next)
- else:
- dead("Man, learn to type a number.")
- #throw in some kind of moralistic clap trap
- if how_much < 50:
- print "Nice, you're not greedy, you win!"
- exit(0)
- #but, you don't die. It's just a simple game.
- else:
- dead("You greedy bastard!")
- #python 3 would require ("") around the print statements
- def bear_room():
- print "There is a bear here."
- print "The bear has a bunch of honey."
- print "The fat bear is in front of another door."
- print "How are you going to move the bear? Hit enter to get some options"
- bear_moved = False
- while True:
- next = raw_input("> ")
- #added some help for the users otherwise this game would
- #require the users to look at the code
- print "here are your options, and you have to type them exactly: \n take honey \n taunt bear \n open door \n take a look at the code"
- if next == "take honey":
- dead("The bear looks at you then slaps your face off. Which means you are prabably going to restart the game.")
- elif next == "taunt bear" and not bear_moved:
- print "The bear has moved from the door. You can go through it now. Hit enter to see your options."
- bear_moved = True
- elif next == "taunt bear" and bear_moved:
- dead("The bear gets pissed off and chews your leg off.")
- elif next == "open door" and bear_moved:
- gold_room()
- else:
- print "I got no idea what that means."
- def cthulhu_room():
- print "Here you see the great evil Cthulhu."
- print "He, it, whatever stares at you and you go insane."
- print "Do you flee for your life or eat your head?"
- print "Again. Not sophisticated. Type flee or head"
- next = raw_input("> ")
- if "flee" in next:
- start()
- elif "head" in next:
- dead("Well that was tasty!")
- else:
- cthulhu_room()
- #this function is in all the if-statements...
- def dead(why):
- print why, "Good job!"
- exit(0)
- def start():
- print "You are in a dark room."
- print "There is a door to your right and left."
- print "Which one do you take?"
- print "'And you have to type, left or right or the game ends. It's not very sophisticated.'"
- next = raw_input("> ")
- if next == "left":
- bear_room()
- elif next == "right":
- cthulhu_room()
- else:
- dead("You stumble around the room until you starve.")
- start()
Add Comment
Please, Sign In to add comment