Advertisement
Guest User

Help

a guest
Sep 14th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. Ok, here is my full code. I have problems with line 42, I will indicate where it is at the end. I am basically trying to code a text based rpg. I've got the main functions but how can I make a combat system? I mean that I can ecounter an enemy, attack but how can I repeat that sequence without any errors?
  2.  
  3. import random
  4. myhp = 50
  5. mo_basichp = 20
  6. mo_mediumhp = 50
  7. mo_hardhp = 100
  8. bosshp = 120
  9. mydmg = random.randrange(1,10)
  10. mo_basicdmg = random.randrange(1,5)
  11. mo_mediumdmg = random.randrange(2,12)
  12. mo_harddmg = random.randrange(5,20)
  13. bossdmg = random.randrange(5,30)
  14. mo_basic = ["Orc", "Skeleton", "Warrior", "Dwarf"]
  15.  
  16. print("The Legend of King's College")
  17. import time
  18. time.sleep(2)
  19. print("Start" + " " + "Exit")
  20. gameop = input()
  21. if gameop == "Start" or "start":
  22. import sys
  23. from time import sleep
  24.  
  25. words = "Once upon a time, in a far away land known as Murcia, there was a castle, that castle was King's College. There lived a mighty hero; Lucas. Now, he must face what destiny has to offer."
  26. for char in words:
  27. sleep(0.1)
  28. sys.stdout.write(char)
  29. sys.stdout.flush()
  30. time.sleep(2)
  31. //Down here are the problems
  32. mo_basic2 = random.choice(mo_basic)
  33. player_inbattle = False
  34. player_action = [" running around.", " in a cave.", " eating lunch.", " leveling up.", " fighting goblins."]
  35. while True:
  36. print ("Lucas has encountered a " + random.choice(mo_basic))
  37. print ("Fight or Flight?")
  38. answer1 = input()
  39. if answer1 == "Fight":
  40. player_inbattle = True
  41. print ("Attack" + "Defend")
  42. answerat = input()
  43. if answerat == "Attack" or "attack":
  44. while mo_basichp > 0:
  45. print ("Monster has " + mo_basichp - mydmg + " hp left")
  46. print ("The monster attacked you!")
  47. print ("You have " + myhp - mo_basicdmg + " hp left.")
  48. break
  49. else:
  50. print ("Lucas is" + random.choice(player_action))
  51. time.sleep(6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement