Advertisement
hotrod121212

Untitled

Mar 23rd, 2015
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 15.61 KB | None | 0 0
  1. import random, logging
  2.  
  3. version = "Alpha 0.2.7 (Windows Edition)"
  4.  
  5. logging.basicConfig(filename='log.log',level=logging.DEBUG)
  6. logging.debug("Game version: %s" % (version))
  7. logging.debug("If you are experiencing issues, or feel like some commands should be added, copy and paste this log to http://pastebin.com/ and send the link to Ratchet.")
  8.  
  9. '''
  10. Todo:
  11. -Finish game (duh)
  12. -Decrease lines of code used (If possible)
  13. -Add newgame function
  14. -Newgame on death
  15. -Save system
  16. '''
  17.  
  18. #intro
  19. print("=< Mildwind by Ratchet Miles >=")
  20. print("\"You can't bring me down\" -Ratchet")
  21. print("Version: %s\n" % (version))
  22.  
  23. #stats
  24. ponyattack = 0
  25. health = 100
  26. armor = 1
  27. strength = 1
  28. potion = 0
  29. attack = (strength * 10) + ponyattack
  30. stamina = "N/A"
  31. shield = "lol, what shield?"
  32. hint = 3
  33.  
  34. #actual game
  35. name = input("Identify yourself\n>")
  36.  
  37. #presets
  38. help = "Objective: The objective of the game is to type commands to beat the game. You simply type a command and read the results.\n\nStats: You can view your stats using the \"stats\" command. Your health is, well, your health. Armor reduces your health damage. Your strength is how strong you are. Potions are a limited resource that restore 50 health per use (This is subject to change). Attack is how much damage you give per hit. Stamina is how much strength you have. This is degraded when you use your shield and regained when the chapter ends. Hints are a limited amount of tips that assist you when you're stuck. These are also known as scrolls.\n\nCommon commands:\n-Help: Brings up this menu.\n-Hint: Gives you a hint as to what to do.\n-Potion: Uses a potion.\n-Attack: Cannot be used all the time, but is used to battle enemies.\n-Shield: Cannot be used all the time, but can give a small amount of damage and regenerate a little health. Uses stamina.\n-Continue, Press forward, Follow, etc: Cannot be used all the time, but is used to progress to the next chapter.\n-Stats: Displays stats such as health.\n-Newname: Gives you the option to change your name.\n-Exit, kill, quit, and close: Close the game."
  39.  
  40. showstats = "=< STATS >=\nName: %s\nHealth: %s\nArmor: %s\nStrength: %s\nAttack: %s\nStamina: %s\nPotions: %s\nHints: %s"
  41.  
  42. #functions
  43. def hintfunc():
  44.     global hint
  45.     if hint > 0:
  46.         hint = hint - 1
  47.         randhint = ["Maybe the guard has something of use?", "Wait for something to happen?", "Maybe the prisoner has something to say?", "The door can be unlocked.", "I guess all you can do is bash your head against the wall."]
  48.         print(random.choice(randhint))
  49.         print("You have %s hint(s) left." % (hint))
  50.     else:
  51.         print("You currently don't have any hints to use.")
  52.        
  53. def potionfunc():
  54.     global potion
  55.     global health
  56.     if health == 100:
  57.         print("You already have max health.")
  58.     elif potion > 0 and health + 50 >= 100:
  59.         potion = potion - 1
  60.         health = 100
  61.         print("Potion used. Your health is now %s" % (int(round(health))))
  62.     elif potion > 0 and health + 50 <= 100:
  63.         potion = potion - 1
  64.         health = health + 50
  65.         print("Potion used. Your health is now %s" % (int(round(health))))
  66.     else:
  67.         print("You don't have any potions to use.")
  68.  
  69. def statfunc():
  70.     print(showstats % (name, int(round(health)), armor, strength, attack, stamina, potion, hint))
  71.  
  72. def helpfunc():
  73.     print(help)
  74.  
  75. def newnamefunc():
  76.     global name
  77.     newname = input("Please enter your new name\n>")
  78.     while True:
  79.         check = input("Are you sure (y/n)?\n>").lower()
  80.         if check == "y":
  81.             name = newname
  82.             print("Your name is now %s" % (name))
  83.             break
  84.         else:
  85.             print("Name left unchanged")
  86.             break
  87.  
  88. def quitfunc():
  89.     check = input("Are you sure you want to quit (y/n)?\n>").lower()
  90.     while True:
  91.         if check == "y":
  92.             quit()
  93.         else:
  94.             break
  95.            
  96. def surveyfunc():
  97.     input("When doing this survey, remember to be very descriptive, and you can't press enter to add a new paragraph. Enter goes to the next question.")
  98.     survey1 = input("On a scale of 1 - 10, what do you think of Mildwind so far?\n>")
  99.     logging.info("Question 1 \"On a scale of 1 - 10, what do you think of Mildwind so far?\": " + survey1)
  100.     survey2 = input("Are there any commands I should add? Where?\n>")
  101.     logging.info("Question 2 \"Are there any commands I should add? Where?\": " + survey2)
  102.     survey3 = input("What problems have you faced?\n>")
  103.     logging.info("Question 3 \"What problems have you faced?\": " + survey3)
  104.     survey4 = input("How could I improve the game?\n>")
  105.     logging.info("Question 4 \"How could I improve the game?\": " + survey4)
  106.     input("Thank you for doing the survey. In order for me to see your answers, you must follow the instructions in the log or readme file.")
  107.  
  108. def gamewin():
  109.     while True:
  110.         print("You win.")
  111.         print("Don't forget to send me your log if you don't mind (More info about that in the readme file)!")
  112.         survey = input("Would you like to take a survey to help me improve my game? The survey answers will be saved in the log file (y/n).\n>").lower()
  113.         if survey == "y":
  114.             surveyfunc()
  115.             quit()
  116.         else:
  117.             logging.info("END OF SESSION; NO SURVEY")
  118.             input("Thank you for playing my game!")
  119.             quit()
  120.  
  121. def gamelose():
  122.     while True:
  123.         print("You lose.")
  124.         survey = input("Would you like to take a survey to help me improve my game? The survey answers will be saved in the log file (y/n).\n>").lower()
  125.         if survey == "y":
  126.             surveyfunc()
  127.             quit()
  128.         else:
  129.             logging.info("END OF SESSION; NO SURVEY")
  130.             input("Thank you for playing my game!")
  131.             quit()
  132.                
  133. def noentryfunc():
  134.     print("Invalid entry. (Need help? Try 'hint' or 'help'.)")
  135.  
  136. #part1
  137. def part1():
  138.     print("You awaken in a dungeon. Behind you is a tiny barred window, and in front of you is a barred door. There is a prisoner in the cell across from you and a guard that marches back and forth in the hall.")
  139.     haskey = False
  140.     hasitems = False
  141.     stolen = False
  142.     while True:
  143.         command = input(">").lower()
  144.         logging.info("Part 1:" + command)
  145.         if command == "hint":
  146.             hintfunc()
  147.         elif command in ["potion", "use potion"]:
  148.             potionfunc()
  149.         elif command == "stats":
  150.             statfunc()
  151.         elif command == "help":
  152.             helpfunc()
  153.         elif command == "newname":
  154.             newnamefunc()
  155.         elif command in ["exit", "quit", "kill", "close"]:
  156.             quitfunc()
  157.         elif command in ["look at window", "look out window", "window"]:
  158.             print("You sigh and gaze out the window.")
  159.         elif command in ["look at guard", "analyse guard", "guard"]:
  160.             print("You notice the guard has something in his pocket. As he walks, it seems to be within your reach.")
  161.         elif command in ["bash head into wall", "bang head into wall", "bang head against wall", "bash head against wall"]:
  162.             if health > 0:
  163.                 health = health - (5 / armor)
  164.                 print("You bashed your head into the wall out of misery. It hurts a little. You lost 5 health.")
  165.             else:
  166.                 print("You bashed your head to death out of misery.")
  167.                 print("\"Hopeless and Stupid\" ending")
  168.                 statfunc()
  169.                 gamelose()
  170.                 quit()
  171.         elif command == "talk to prisoner":
  172.             if hasitems == True:
  173.                 print("I have nothing else to say...")
  174.             else:  
  175.                 hasitems = True
  176.                 potion = potion + 1
  177.                 print("Greetings %s, today is my last day alive... I must face my death sentence... Take this. It won't be of use to me in my afterlife." % (name))
  178.                 print("You were given a potion.")
  179.         elif command == "wait":
  180.             print("You hear a noise coming from the window, when suddenly, the wall breaks down. A man with a wooden metal-plated battering ram bashes the wall down. \"%s, We need your help, only you are capable of killing the dragon. No time to explain right now. Take these items.\"\nYou have been given a steel sword, cheap armor, and a scroll." % (name))
  181.             strength = 4
  182.             hint = hint + 1
  183.             armor = 1.5
  184.             attack = (strength * 10) + ponyattack
  185.             print("Strength increased to 4, armor increased to 1.5, and a hint added.")
  186.             break
  187.         elif command in ["pickpocket guard", "steal", "pickpocket", "steal from guard", "pick guards pocket", "pick pocket", "take from guard", "reach into guards pocket"]:
  188.             if stolen == True:
  189.                 print("The guard shouts \"Hey, I saw that!\" and shanks you for stealing. You lost 20 health.")
  190.                 health = health - (20 / armor)
  191.                 if hint == 0:
  192.                     hint == 0
  193.                 else:
  194.                     hint = hint - 1
  195.                 while True:
  196.                     if health > 0:
  197.                         break
  198.                     else:
  199.                         print("You were shanked to death.\n")
  200.                         print("\"Greedy\" ending")
  201.                         statfunc()
  202.                         gamelose()
  203.                         quit()
  204.             else:  
  205.                 print("As the guard passes by, you reach in his pocket and grabbed some items. You found a dagger, scroll, and key.")
  206.                 strength = 2
  207.                 hint = hint + 1
  208.                 attack = (strength * 10) + ponyattack
  209.                 haskey = True
  210.                 stolen = True
  211.                 print("Strength increased to 2, you obtained a key, and a hint added.")
  212.         elif command in ["open door", "unlock door"]:
  213.             if haskey == True
  214.                 print("You open the door. The guard sees you and begins to run towards you. What do you do? (run/attack)")
  215.                 while True:
  216.                     choice = input(">")
  217.                     if choice == "run":
  218.                         print("As you run, a man came from behind and killed the guard. The man says \"Follow me %s\", and you ran to the exit." % (name))
  219.                         break
  220.                     elif choice == "attack":
  221.                         health = health - (50 / armor)
  222.                         print("You were stabbed by the guard. You lost 50 health.")
  223.                         while True:
  224.                             if health > 0:
  225.                                 print("Maybe attacking isn't such a good idea.")
  226.                                 break
  227.                             else:
  228.                                 print("You were stabbed to death.\n")
  229.                                 print("\"Failed Escape\" ending")
  230.                                 statfunc()
  231.                                 gamelose()
  232.                                 quit()
  233.                     elif choice in ["potion", "use potion"]:
  234.                         potionfunc
  235.                     elif choice == "stats":
  236.                         statfunc()
  237.                     else:
  238.                         noentryfunc()
  239.                 break
  240.             else:
  241.                 print("You don't have a key.")
  242.         else:
  243.             noentryfunc()
  244.  
  245. #part2
  246. def part2():
  247.     logging.info("Part 1 Stats:" + "\n" + showstats % ("Player", int(round(health)), armor, strength, attack, stamina, potion, hint))
  248.     print("\nYou just escaped the dungeon, you meet the man who helped you escape. \"%s, you are the world's only hope of defeating the dragon Dracord. Dracord has risen from the dead thanks to a curse casted upon the world. My name is Ruffin and the prophecy says that you can save humanity, that is why I saved you.\"" % (name))
  249.     hasitems = False
  250.     haskey = False
  251.     stolen = False
  252.     while True:
  253.         command = input(">").lower()
  254.         logging.info("Part 2:" + command)
  255.         if command == "hint":
  256.             hintfunc()
  257.         elif command in ["potion", "use potion"]:
  258.             potionfunc()
  259.         elif command == "stats":
  260.             statfunc()
  261.         elif command == "help":
  262.             helpfunc()
  263.         elif command == "newname":
  264.             newnamefunc()
  265.         elif command in ["exit", "quit", "kill", "close"]:
  266.             quitfunc()
  267.         elif command in ["walk", "run", "continue", "press forward", "move along", "follow ruffin", "follow"]:
  268.             print("You follow Ruffin to the Dungeon that the dragon resides in.")
  269.             part2()
  270.         elif command == "run free":
  271.             print("You are a free man now.")
  272.             print("\"Careless\" ending")
  273.             statfunc()
  274.             gamewin()
  275.             quit()
  276.         else:
  277.             noentryfunc()
  278.  
  279. #part3
  280. def part3():
  281.     logging.info("Part 2 Stats:" + "\n" + showstats % ("Player", int(round(health)), armor, strength, attack, stamina, potion, hint))
  282.     print("\nYou have chosen to follow Ruffin. On your way to the cave that Dracord resides in, you are stopped by a pack of wolves.")
  283.     packhealth = 200
  284.     packdead = False
  285.     while True:
  286.         command = input(">").lower()
  287.         logging.info("Part 3:" + command)
  288.         if command == "hint":
  289.             hintfunc()
  290.         elif command in ["potion", "use potion"]:
  291.             potionfunc()
  292.         elif command == "stats":
  293.             statfunc()
  294.         elif command == "help":
  295.             helpfunc()
  296.         elif command == "newname":
  297.             newnamefunc()
  298.         elif command in ["exit", "quit", "kill", "close"]:
  299.             quitfunc()
  300.         elif command in ["attack", "fight"]:
  301.             if packdead == True:
  302.                 print("You and Ruffin look at the dead wolf pack.")
  303.             else:
  304.                 enattack = [1, 2, 5]
  305.                 packhealth = packhealth - (attack + 15)
  306.                 health = health - (random.choice(enattack) / armor)
  307.                 if health <= 0:
  308.                     print("You were bitten to death.")     
  309.                     print("\"THIS BITES!\" ending")
  310.                     statfunc()
  311.                     gamelose()
  312.                     quit()
  313.                 elif packhealth <= 0:
  314.                     packdead = True
  315.                     potion = potion + 2
  316.                     print("You and Ruffin attacked the wolves. They are now dead, and you have a health of %s. You also picked up 2 potions." % (int(round(health))))
  317.                 elif packhealth > 0:
  318.                     print("You and Ruffin attacked the wolves. The wolves have a health of %s, and you have a health of %s." % (packhealth, int(round(health))))
  319.                 else:
  320.                     print("What did you do to get this message?")
  321.         elif command in ["walk", "run", "continue", "press forward", "move along", "follow ruffin", "follow"]:
  322.             esattack = [0, 4, 10]
  323.             esattackgen = random.choice(esattack)
  324.             if packhealth > 0:
  325.                 health = health - (esattackgen / armor)
  326.                 if health <= 0:
  327.                     print("You were killed by the pack of wolves.")
  328.                     print("\"Manbaby\" ending")
  329.                     statfunc()
  330.                     gamelose()
  331.                     quit()
  332.                 else:
  333.                     if esattackgen == 0:
  334.                         print("You and Ruffin escaped from the pack of wolves safely.")
  335.                         break
  336.                     else:
  337.                         print("The wolves bit you in the back. Your health is now %s." % (int(round(health))))
  338.                         print("You can't leave until the wolves are dead.")
  339.             else:
  340.                 print("You continue your journey to defeat Dracord.")
  341.                 break
  342.         else:
  343.             noentryfunc()
  344.  
  345. #part4
  346. def part4():
  347.     logging.info("Part 3 Stats:" + "\n" + showstats % ("Player", int(round(health)), armor, strength, attack, stamina, potion, hint))
  348.     print("\nYou make it to the entrance of the cave. You and Ruffin walk inside. There is a skeleton to the right and the darkness of the cave ahead.")
  349.     shieldget = False
  350.     while True:
  351.         command = input(">").lower()
  352.         logging.info("Part 4:" + command)
  353.         if command == "hint":
  354.             hintfunc()
  355.         elif command in ["potion", "use potion"]:
  356.             potionfunc()
  357.         elif command == "stats":
  358.             statfunc()
  359.         elif command == "help":
  360.             helpfunc()
  361.         elif command == "newname":
  362.             newnamefunc()
  363.         elif command in ["exit", "quit", "kill", "close"]:
  364.             quitfunc()
  365.         elif command == "ponies!!!":
  366.             ponyattack = 15
  367.             attack = (strength * 10) + ponyattack
  368.             print("You found a purple princess pony. She will now follow you and add 15 damage to your attacks.")
  369.         elif command in ["skeleton", "examine skeleton", "examine", "check", "check skeleton", "loot", "loot skeleton", "look at skeleton", "scavenge", "scavenge skeleton"]:
  370.             if hasitems == True:
  371.                 print("You mourn over the death of the knight.")
  372.             else:
  373.                 shieldget = True
  374.                 stamina = 10
  375.                 hasitems = True
  376.                 shield = strength * 5
  377.                 if armor > 1.4:
  378.                     print("The armor the skeleton is wearing appears to be weaker than what you're wearing, but he has a shield. You can now use \"shield\" to defend yourself from enemies and give a small amount of damage.")
  379.                 else:
  380.                     armor = 1.4
  381.                     print("The skeleton has a strong chestplate and shield. Your armor is now increased to 1.4. You can now use \"shield\" to defend yourself from enemies and give a small amount of damage.")
  382.         elif command in ["walk", "run", "continue", "press forward", "move along", "follow ruffin", "follow"]:
  383.             print("You and Ruffin continue into the dark cave.")
  384.             break
  385.         else:
  386.             noentryfunc()
  387.            
  388. part1()
  389.  
  390. #end
  391. logging.info("End Stats:" + "\n" + showstats % ("Player", int(round(health)), armor, strength, attack, stamina, potion, hint))
  392. statfunc()
  393. print("The game isn't done. Don't forget to send me your log if you don't mind (More info about that in the readme file)!")
  394. survey = input("Would you like to take a survey to help me improve my game? The survey answers will be saved in the log file. (y/n)\n>").lower()
  395. if survey == "y":
  396.     surveyfunc()
  397. else:
  398.     logging.info("END OF SESSION; NO SURVEY")
  399.     input("Thank you for playing my game!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement