Advertisement
Guest User

Untitled

a guest
May 17th, 2017
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. def monster(): #callable function to find monster
  2. monsterhp = random.randint(600, 1000)
  3. creature = ['War Lord', 'High Prince', 'Frost Ghost'] #selects random creature each time monster is run
  4. monstertype = random.choice(creature)
  5. global attack, xp, level, gold, health, y, time1
  6. print("You hear a noise, RAWWRRRRRRRRR. A level 5", monstertype, "has appeared with", monsterhp, "health."'\n')
  7. time.sleep(1)
  8. attack = input("You are left with no choice to attack. Press enter to fight the monster: ")
  9. health = health - 60
  10. while monsterhp > 0:
  11. if health < 0: #breaks code half way through killing monster to show death
  12. print("You strike the monster")
  13. time.sleep(1)
  14. monsterhp = monsterhp - y #y is the damage of the chosen sword
  15. print("War Lord Health:", monsterhp)
  16. if monsterhp < 400:
  17. print("")
  18. print("You have been killed. You respawn with 100 health and your items back.")
  19. health = int(100)
  20. break
  21. elif health > 0:
  22.  
  23. timeout = time1
  24. t = Timer(time1, print, ['You ran out of time.'])
  25. t.start()
  26. print(" ")
  27. prompt = "You have %d seconds Type 'attack' to hit the monster\nType here: " % timeout
  28. answer = input(prompt)
  29.  
  30. t.cancel()
  31.  
  32. if answer == "attack":
  33. print("You strike the monster")
  34. time.sleep(1)
  35. monsterhp = monsterhp - y
  36. print("War Lord Health:", monsterhp)
  37. elif answer != "attack" and answer != None:
  38. print("Incorrect answer. No damage dealt.")
  39.  
  40. if monsterhp < 0:
  41. print("War Lord Health:", 0)
  42. print("You have slain the monster!")
  43. print("You lost 60 health in the battle"'\n')
  44. print("You are now left with", health, "health.")
  45. gold = gold + 800
  46. print("You have earnt 800 gold."'\n')
  47. xpgain = random.randint(1100, 1200)
  48. print("You have earnt", xpgain, "xp.")
  49. xp = xp + xpgain # adds xpgained to xp variable
  50. time.sleep(1)
  51.  
  52. xp_required = int(500) * round(level) #the basis of how much xp each level consists off
  53. if xp >= xp_required:
  54. level = xp / xp_required + level #calculation of level
  55. print("You are now level", round(level), "."'\n')
  56. if level == 3:
  57. print("Now that you have reached level 3. Your weapon gained an enchantment which gives it 30 more damage!"'\n')
  58. y = y + 30
  59. time.sleep(1)
  60. xp_requiredv2 = int(500) * round(level) + 500 #calculation off how much xp in total is required for next level
  61. print("You are " + str(xp + 500) + "/" + str(xp_requiredv2) + " xp to level", (round(level) + 1))
  62. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement