Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.65 KB | None | 0 0
  1. # This is a Python file to practice classes for the RPG I am writing.
  2.  
  3. # Probably going to screw this up terribly but hey it's worth a shot.
  4.  
  5. class pInfo(object):
  6. """Info section for creating a character.
  7.  
  8. I need the following info:
  9. Name (pName)
  10. Age (pAge)
  11. Location (pLoc)
  12. Class (pClass)
  13. Health (pHealth)
  14. """
  15.  
  16. def __init__(self, pName, pAge, pLoc, pClass):
  17. self.pName = pName
  18. self.pAge = pAge
  19. self.pLoc = pLoc
  20. self.pClass = pClass
  21. self.pHealth = 10
  22. self.pMana = 3
  23. self.pSpeed = 5
  24.  
  25. while True:
  26. pName = input("Enter your name: ")
  27. if all(i.isalpha() or i.isspace() for i in pName) \
  28. and pName != "":
  29. print("Nice to meet you, " + pName + "!\n")
  30. break
  31. else:
  32. print("That doesn't look like a valid name, you silly goose!\n"
  33. "Let's try that again.\n")
  34.  
  35. while True:
  36. try:
  37. pAge = int(input("Enter your age: "))
  38. except ValueError:
  39. print("I don't believe that's a number.\n"
  40. "Let's try that again.\n")
  41. else:
  42. if pAge >= 10 and pAge <= 21:
  43. print(str(pAge) + " years old?! " + "Eager for adventure, are we?\n"
  44. "Hope you know how to handle a proper weapon or else you're\n"
  45. "going to end up as worm food sooner than you think.\n")
  46. break
  47. elif pAge > 21 and pAge <= 60:
  48. print("You look like a seasoned adventurer for a " + str(pAge) + " year old.\n"
  49. "Just don't get too cocky or else you'll end up with a steel\n"
  50. "necklace ear to ear. Get my drift?\n")
  51. break
  52. elif pAge > 60 and pAge <= 99:
  53. print("Still traveling around the world at " + str(pAge) + "?\n"
  54. "I'm impressed! Just remember that thieves and monsters\n"
  55. "won't go easy on you just because you're an old timer.\n")
  56. break
  57. else:
  58. print("No way you expect me to believe that.\n"
  59. "Let's try that again.\n")
  60.  
  61. while True:
  62. print("In Aleria, there are 3 ruling kingdoms: Menith, Pajbal, and Orleaus.\n"
  63. "Each kingdom has its own unique background and offers different benefits.\n")
  64. LocMenu = ["Menith", "Pajbal", "Orleaus"]
  65. for i in enumerate(LocMenu, start=1):
  66. print(f"{i[0]} - {i[1]}")
  67. try:
  68. pLoc = int(input("Enter the number of your location: "))
  69. except ValueError:
  70. print("Was that one of the choices? I think not. Let's try again.\n")
  71. else:
  72. if pLoc == 1:
  73. print("Menith is a militant order with a history saturated in conflict.\n"
  74. "Their government is a ruled by a small council of highly decorated\n"
  75. "officers who have absolute authority over every issue. As a citizen\n"
  76. "of Menith, you were required to serve in their army at a young age\n"
  77. "for several years. Through your service in their military, you are\n"
  78. "trained in martial fighting and have a keen mind for combat tactics.\n")
  79. break
  80. elif pLoc == 2:
  81. print("Pajbal, widely referred to as ""The Sapphire of the Sands,""is a\n"
  82. "wonderous city located in the center of the Almathian Desert. Pajbal\n"
  83. "is home to the Aetherian Academy, a world renowned institution for\n"
  84. "academic research in magic. Your life in Pajbal made you curious about\n"
  85. "magic and you decided to apply your interest to the Academy, where you\n"
  86. "learned a great deal about magic. As a result, you developed the abilities\n"
  87. "to cast powerful spells and read ancient scriptures.")
  88. break
  89. elif pLoc == 3:
  90. print("Orleaus\n")
  91. break
  92. else:
  93. print("What did you even write? Let's try again.\n")
  94.  
  95. while True:
  96. ClassMenu = ["Fighter", "Mage", "Thief"]
  97. for i in enumerate(ClassMenu, start=1):
  98. print(f"{i[0]} - {i[1]}")
  99. try:
  100. pClass = int(input("Select your class: "))
  101. except ValueError:
  102. print("That's not a class, my friend. Let's try again.\n")
  103. else:
  104. if pClass == 1:
  105. print("You're a fighter, not a lover!\n")
  106. break
  107. elif pClass == 2:
  108. print("Yer a wizard, " + pName + "! Er, I mean Mage.\n")
  109. break
  110. elif pClass == 3:
  111. print("Sneaky sneaky, stabby stabby.\n")
  112. break
  113. else:
  114. print("You can't be that because it doesn't exist. Let's try again.\n")
  115.  
  116. player = pInfo(pName, pAge, pLoc, pClass)
  117.  
  118. while True:
  119. print("Alright so let's make sure we got all the right info:")
  120. print("Your name is " + str(player.pName) + ".")
  121. print("Your age is " + str(player.pAge) + ".")
  122. print("Your location is " + str(LocMenu[pLoc - 1]) + ".")
  123. print("Your class is " + str(ClassMenu[pClass - 1]) + ".")
  124. try:
  125. verifyPlayer = input("We good? ")
  126. except ValueError:
  127. print("What you say?\n")
  128. else:
  129. if verifyPlayer == "Y":
  130. print("Excellent!")
  131. print("Your total health is " + str(player.pHealth) + ".")
  132. print("Your total mana is " + str(player.pMana) + ".")
  133. print("You have " + str(player.pSpeed) + " speed points.")
  134. break
  135. elif verifyPlayer == "N":
  136. print("D'oh! Well let's start over then.")
  137. # I want to make the user start over
  138. break
  139. else:
  140. print("Not a valid answer!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement