Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def monster(): #callable function to find monster
- monsterhp = random.randint(600, 1000)
- creature = ['War Lord', 'High Prince', 'Frost Ghost'] #selects random creature each time monster is run
- monstertype = random.choice(creature)
- global attack, xp, level, gold, health, y, time1
- print("You hear a noise, RAWWRRRRRRRRR. A level 5", monstertype, "has appeared with", monsterhp, "health."'\n')
- time.sleep(1)
- attack = input("You are left with no choice to attack. Press enter to fight the monster: ")
- health = health - 60
- while monsterhp > 0:
- if health < 0: #breaks code half way through killing monster to show death
- print("You strike the monster")
- time.sleep(1)
- monsterhp = monsterhp - y #y is the damage of the chosen sword
- print("War Lord Health:", monsterhp)
- if monsterhp < 400:
- print("")
- print("You have been killed. You respawn with 100 health and your items back.")
- health = int(100)
- break
- elif health > 0:
- timeout = time1
- t = Timer(time1, print, ['You ran out of time.'])
- t.start()
- print(" ")
- prompt = "You have %d seconds Type 'attack' to hit the monster\nType here: " % timeout
- answer = input(prompt)
- t.cancel()
- if answer == "attack":
- print("You strike the monster")
- time.sleep(1)
- monsterhp = monsterhp - y
- print("War Lord Health:", monsterhp)
- elif answer != "attack" and answer != None:
- print("Incorrect answer. No damage dealt.")
- if monsterhp < 0:
- print("War Lord Health:", 0)
- print("You have slain the monster!")
- print("You lost 60 health in the battle"'\n')
- print("You are now left with", health, "health.")
- gold = gold + 800
- print("You have earnt 800 gold."'\n')
- xpgain = random.randint(1100, 1200)
- print("You have earnt", xpgain, "xp.")
- xp = xp + xpgain # adds xpgained to xp variable
- time.sleep(1)
- xp_required = int(500) * round(level) #the basis of how much xp each level consists off
- if xp >= xp_required:
- level = xp / xp_required + level #calculation of level
- print("You are now level", round(level), "."'\n')
- if level == 3:
- print("Now that you have reached level 3. Your weapon gained an enchantment which gives it 30 more damage!"'\n')
- y = y + 30
- time.sleep(1)
- xp_requiredv2 = int(500) * round(level) + 500 #calculation off how much xp in total is required for next level
- print("You are " + str(xp + 500) + "/" + str(xp_requiredv2) + " xp to level", (round(level) + 1))
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement