isefire

game1.py

Mar 2nd, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.06 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. #
  3. #  game1.py
  4. #  
  5. #  Copyright 2014 [email protected]
  6. #  
  7. #  This program is free software; you can redistribute it and/or modify
  8. #  it under the terms of the GNU General Public License as published by
  9. #  the Free Software Foundation; either version 2 of the License, or
  10. #  (at your option) any later version.
  11. #  
  12. #  This program is distributed in the hope that it will be useful,
  13. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. #  GNU General Public License for more details.
  16. #  
  17. #  You should have received a copy of the GNU General Public License
  18. #  along with this program; if not, write to the Free Software
  19. #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  20. #  MA 02110-1301, USA.
  21. #  
  22. #  
  23. from random import randint
  24. import webbrowser
  25. import sys
  26. import os
  27. def restart_program():
  28.     """Restarts the current program.
  29.    Note: this function does not return. Any cleanup action (like
  30.    saving data) must be done before calling this function."""
  31.     python = sys.executable
  32.     os.execl(python, python, * sys.argv)
  33.  
  34. money = 0
  35. # b1
  36. cask = 1
  37. # b2
  38. snkskn = 1
  39. #
  40. inventory = ["Stalk","Robes"]
  41. name = raw_input("Name? ")
  42. age = raw_input("Age? ")
  43. race = raw_input("What is your race? Choose: Human, Elf, or Dwarf --> ")
  44. profile = { "Name": name, "Age": age, "Race": race}
  45. races = ("human","Human","elf","Elf","Dwarf","dwarf")
  46. indexrace = races.index(race)
  47.    
  48. if indexrace >= 0:
  49.     print "So you are a %s named %s aged %s. You are an elder vampire lord. Godspeed!" % (race, name, age)
  50. else:
  51.     print "You got it wrong bitch!"
  52.     quit(0)
  53.        
  54. if indexrace == 0 or indexrace == 1:
  55.     profile.update({"Health":100, "Magicka":80})
  56. elif indexrace == 2 or indexrace == 3:
  57.     profile.update({"Health" : 60, "Magicka": 120})
  58. else:
  59.     profile.update({"Health" : 120, "Magicka": 60})
  60.  
  61. print "Your starting health for race %s is %s and magicka is %s" % (race, profile["Health"], profile["Magicka"])
  62.     #for i in profile:
  63.     #   print i, " : ", profile[i]
  64.        
  65.        
  66. print "\nWelcome to the dungeon! Try to find your way to the Treasure Trove at the top of the tallest tower!"
  67.  
  68. def dead(why):
  69.     print why
  70.     print "You are dead!"
  71.     print "\nPlay again?"
  72.     ded = raw_input("y/n ---> ")
  73.     if ded == "y":
  74.         webbrowser.open("http://youtu.be/ZZ5LpwO-An4")
  75.         restart_program()
  76.     else:
  77.         webbrowser.open("http://youtu.be/ZZ5LpwO-An4")
  78.         quit(0)
  79.        
  80.  
  81. def b1dungeon():
  82.     print "\nYou are in the very bottom of the castle, the lowest dungeon of dungeons. It smells of butts."
  83.     print "You have a black as night cloak, %d coins, and a wooden stalk." % money
  84.     print "You take a look around you. There is an upside down casket in the corner of the room surrounded by rats, and 2 doors left and right."
  85.     b1 = raw_input("\nWhat do you choose to do? Casket, Right, or Left.-----> ")
  86.     global cask
  87.     if b1 == "Casket" or b1 == "casket" and cask == 1:
  88.         print "\nYou chose to open the casket in the corner!"
  89.         print "You kick it over, BANG!"
  90.         print "IT'S A TRAP!"
  91.         print "You are sprayed with poison. Lose 20 health."
  92.         profile.update({"Health":profile["Health"]-20})
  93.         print "You now have %s health left." % profile["Health"]
  94.         cask = 0
  95.         b1dungeon()
  96.     elif b1 == "right" or b1 == "Right":
  97.         b1adungeon()
  98.     elif b1 == "left" or b1 == "Left":
  99.         b2dungeon()
  100.     elif b1 == "Casket" or b1 == "casket" and cask == 0:
  101.         print "\nYou have already tried this!"
  102.         b1dungeon()
  103.     else:
  104.         print "\nI do not understand this!"
  105.         b1dungeon()
  106.    
  107. def b1adungeon():
  108.     dead("When you walk into the room, you are instantly impaled by a thousand arrows.")
  109.    
  110.        
  111. def b2dungeon():
  112.     global snkskn
  113.     if snkskn == 1:
  114.         print "\nYou enter a room with a set of stairs! You also see a snakeskin on the ground to pick up."
  115.         b2 = raw_input("Stairs or Snakeskin?----> ")
  116.     else:
  117.         print "\nYou enter a room with a set of stairs!"
  118.         b2 = raw_input("Stairs?----> ")
  119.     if b2 == "Stairs" or b2 == "stairs":
  120.         guardroom()
  121.     elif b2 == "Snakeskin" or b2 == "snakeskin" and snkskn == 1:
  122.         print "\nYou picked up the snakeskin!"
  123.         print "Snakeskin added to inventory!"
  124.         inventory.append("Snakeskin")
  125.         snkskn = 0
  126.         b2dungeon()
  127.     elif b2 == "Snakeskin" or b2 == "snakeskin" and snkskn == 0:
  128.         print "\nYou already picked that up!"
  129.         b2dungeon()
  130.     else:
  131.         print "\nI can't understand that!"
  132.         b2dungeon()
  133.  
  134. def guardroom():
  135.     global money
  136.     print """\nYou enter a room lit up faintly with candles.
  137.     There is a man clad in chainmail that appears to be the jailer at a corner table napping. You tip-toe
  138.     to a near barrel to hide behind before you make up your mind on
  139.     what you want to do."""
  140.     print "There is a door at the end of the room across from you and past the sleeping guard"
  141.     print "The door appears locked, but there is a ring of keys hanging off the jailer's hauberk."
  142.     print "There also appears to be a dagger laying on the table nearest the jailer, right behind him."
  143.     gr = raw_input("Steal keys, steal dagger, or tickle guard? -----> " )
  144.     if gr == "tickle" or gr == "tickle guard" or gr == "Tickle guard" or gr == "Tickle Guard":
  145.         dead("The guard wakes up and laughing, and swings his sword out of his scabbard to stab you.")
  146.     elif gr == "steal keys" or gr == "keys" or gr == "Steal keys":
  147.         print "\nYou quietly sneak the keys off the guards haukerk."
  148.         opndrgr = raw_input("Open door?---> ")
  149.         if opndrgr == "open" or opndrgr == "door" or opndrgr == "Open door" or opndrgr == "open door":
  150.             dragonroom()
  151.         else:
  152.             dead("You took too long to decide! Guard woke up an stabbed you from behind!")
  153.     elif gr == "steal dagger" or gr == "dagger" or gr == "Steal dagger":
  154.         print "\nYou steal the dagger. What now?"
  155.         inventory.append("Steel Dagger")
  156.         daggrgr = raw_input("Are you going to attack? y/n ---> ")
  157.         if daggrgr == "y" or daggrgr == "yes":
  158.             print "\nYou kill the man, and suck his blood. Gain 20 Health."
  159.             profile.update({"Health":profile["Health"]+20})
  160.             print "You now have %s Health" % profile["Health"]
  161.             print "You loot his body and find 30 coin!"
  162.             money += 30
  163.             print "Steel Dagger added to inventory!"
  164.             print "You take the key ring from his body."
  165.             krng = raw_input("Opening door now...[ENTER]")
  166.             dragonroom()
  167.         else:
  168.             print "\nYou did not attack. Guard woke up and attacked you instead."
  169.             dead("Stabbed in the heart by jailer.")
  170.     else:
  171.         print "/n I don't understand that!"
  172.         guardroom()
  173.  
  174. def dragonroom():
  175.     print "\nYou enter a room devoid of most light with a small, golden dragon statue in the center."
  176.     print "You walk up to the statue, and touch it."
  177.     print "SUDDENLY you hear a voice in the back of your mind -- 'STOP. What sayeth your name?'"
  178.     print "Uhhhh my name, sir. is...."
  179.     nam1 = raw_input("%s, Billy, or Jordan?---->" % name)
  180.     if nam1 == name or nam1 == name.lower():
  181.         print "'You tell the truth, young vampire. You may take this as my gift to you.'"
  182.         profile.update({"Nightvision":True})
  183.         print "\n*Nightvision enabled! You can no see in dark, dark places!*"
  184.         print "\nThe room lights up due to your new ability. You see a door ahead of you."
  185.         nam2 = raw_input("Walking to the door...[ENTER]")
  186.         towerstair()
  187.     else:
  188.         print "\n*SQUUEEEELLCCHHHHasdfgfhngfgbc*"
  189.         dead("Your head explodes due to a psychic force.")
  190.  
  191. def towerstair():
  192.     print "\nYou enter a room with a spiral staircase surrounding a magical elevator in the middle."
  193.     twrstr = raw_input("What do? Stairs, or elevator?----> ")
  194.     if twrstr == "Stairs" or twrstr == "stairs":
  195.         print "\nYou decide to head up the staircase!"
  196.         dead("A rolling boulder comes down as you reach the half-way mark.")
  197.     elif twrstr == "Elevator" or twrstr == "elevator":
  198.         print "You go up to the elevator, and walk onto the platform. There seems to be a random number game instead of buttons..."
  199.         elev = raw_input("Play game, or leave?----> ")
  200.         if elev == "Play game" or elev == "play" or elev == "game" or elev == "play game":
  201.             print "\nYou play the random number game! A number is going to be chosen between 0 and 3. If you can guess the number, you get a ride to the top! If not... uh-oh."
  202.             print "*ring ring ring ring*"
  203.             print "The number has been chosen."
  204.             rnd = randint(0, 3)
  205.             # DEBUG
  206.             #print rnd
  207.             #
  208.             chs = raw_input("What is your choice of number; 0, 1, 2, or 3?----> ")
  209.             if int(chs) == rnd:
  210.                 print "\n*RING RING RING*"
  211.                 print "You WIN!"
  212.                 print "The Elevator ascends to the top of the tower."
  213.                 goldroom()
  214.             else:
  215.                 print "*...........BEEP!*"
  216.                 print "You lose!"
  217.                 dead("You were poisoned by a toxic gas!")
  218.         elif elev == "Leave" or elev == "leave":
  219.             print "\nYou leave the elevator."
  220.             towerstair()
  221.     else:
  222.         print "\nI can't understand that!"
  223.         towerstair()
  224.        
  225. def goldroom():
  226.     needmuch = randint(5000,100000)
  227.     print "\nYou exit the elevator and enter a room filled with gold!"
  228.     print "A voice in your head tells you that you should take %s amount, but it's your choice..." % needmuch
  229.     howmuch = raw_input("How much do you take?----> ")
  230.     if int(howmuch) == needmuch:
  231.             print "YOU WIN!"
  232.             webbrowser.open('http://youtu.be/oHg5SJYRHA0')
  233.     else:
  234.         dead("LISTen Here BITCH")
  235.            
  236.  
  237. b1dungeon()
Advertisement
Add Comment
Please, Sign In to add comment