Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.84 KB | None | 0 0
  1. import random
  2.  
  3. choice=input("Welcome to the adventure. Do you want to create a party or import an existing party?: ").lower() #Choice
  4. while choice != "create" and choice != "import":
  5. print("You did not give a valid answer. Type create or import please.")
  6. choice=input("Do you want to create a party or import an existing party: ")
  7.  
  8. if choice == "import": #If they choose import
  9. print("\nYou have chosen to import a party")
  10. while True:
  11. filename=input("Please tell us the file name you believe the file is called: ")
  12. try:
  13. myfile=open(filename+".txt","r") #Checks if it's a valid file
  14. print("\nYou gave a valid filename")
  15. break
  16. except FileNotFoundError:
  17. print("You did not give a valid filename. Please try again.")
  18. contents=myfile.read()
  19. party=contents.splitlines()
  20. for i in range(0,len(party)):
  21. try:
  22. party.insert(i,int(party[i])) #Turns numbers into integers
  23. party.pop(i+1)
  24. except ValueError:
  25. ()
  26. if len(party) == 6: #Decides how many characters need to be created
  27. z=3
  28. print("You will need to create 3 characters")
  29. if len(party) == 12:
  30. z=2
  31. print("You will need to create 2 characters")
  32. if len(party) == 18:
  33. z=1
  34. print("You will need to create a character")
  35. if len(party) == 24:
  36. z=0
  37. print("Your party is missing no characters")
  38. for i in range(0,z): #Repeats certain amount of times for 4 different scores
  39. name=input("\nPlease input the name of character "+str(i+1)+" please: ")
  40. while len(name) == 0 or name[0] == " ":
  41. print("You did not enter a letter or had a space as your first character. Please try again")
  42. name=input("\nPlease input the name of character "+str(i+1)+" please: ")
  43. scores=[]
  44. for x in range(0,4): #4 dice rolles
  45. dices=[]
  46. for i in range(0,4):
  47. i=random.randint(1,6)
  48. dices.append(i)
  49. dices.sort(reverse=True)
  50. score=dices[0]+dices[1]+dices[2] #Adds up best 3
  51. scores.append(score)
  52. scores.sort(reverse=True)
  53. choice2=input("Do you want to reroll your lowest score of "+str(scores[3])+" to try and get a better score. No matter what you will need to stick to this score. Yes or no? ").lower()
  54. while choice2 != "yes" and choice2 != "no": #Option to reroll lowest score
  55. print("You did not give a valid answer. Type yes or no")
  56. choice2=input("Do you want to reroll your lowest score of "+str(scores[3])+" yes or no?: ")
  57. if choice2 == "no":
  58. print("\nYou have chosen no")
  59. if choice2 == "yes":
  60. print("\nYou have chosen yes") #If yes
  61. scores.pop(3)
  62. dices=[]
  63. for i in range(0,4): #New score
  64. i=random.randint(1,6)
  65. dices.append(i)
  66. dices.sort(reverse=True)
  67. score=dices[0]+dices[1]+dices[2]
  68. print("The new score is",score)
  69. scores.append(score)
  70. scores.sort(reverse=True)
  71. print("The values for your 4 attributes are",scores[0],scores[1],scores[2],scores[3])
  72. print("Please assign the values to the attributes: Strength, Agility, Magic & Luck for the character",name)
  73. strength=input("\nWhich score would you like the attribute Strength be assigned too?: ")
  74. while strength != str(scores[0]) and strength != str(scores[1]) and strength != str(scores[2]) and strength != str(scores[3]): #Validation
  75. print("You did not enter a valid answer. Try again")
  76. strength=input("\nWhich score would you like the attribute Strength be assigned too?: ")
  77. strength=int(strength)
  78. scores.remove(strength)
  79. print("\nThe remaining scores are",scores[0],scores[1],scores[2])
  80. agility=input("Which score would you like the attribute Agility be assigned too: ")
  81. while agility != str(scores[0]) and agility != str(scores[1]) and agility != str(scores[2]): #Validation
  82. print("You did not enter a valid answer. Try again")
  83. agility=input("\nWhich score would you like the attribute Agilityu be assigned too: ")
  84. agility=int(agility)
  85. scores.remove(agility)
  86. print("\nThe remaining scores are",scores[0],scores[1])
  87. magic=input("Which score would you like the attribute Magic to be assigned too: ")
  88. while magic != str(scores[0]) and magic != str(scores[1]): #Validation
  89. print("You did not enter a valid answer. Try again")
  90. magic=input("\nWhich score would you like the attribute Magic to be assigned too: ")
  91. magic=int(magic)
  92. scores.remove(magic)
  93. print("This means the remaining score",scores[0],"will be assigned to Luck")
  94. luck=int(scores[0])
  95. print("The characters Hit Point will always start off with 2")
  96. hitpoint=2
  97. party.append(name)
  98. party.append(strength)
  99. party.append(agility)
  100. party.append(magic)
  101. party.append(luck)
  102. party.append(hitpoint) #Adds values to a list
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. if choice == "create": #if they choose to create
  112. print("You have chosen to create a party")
  113. party=[]
  114. for i in range(0,4): #Repeats 4 times for 4 different scores
  115. name=input("\nPlease input the name of character "+str(i+1)+" please: ")
  116. while len(name) == 0 or name[0] == " ":
  117. print("You did not enter a letter or had a space as your first character. Please try again")
  118. name=input("\nPlease input the name of character "+str(i+1)+" please: ")
  119. scores=[]
  120. for x in range(0,4): #4 dice rolles
  121. dices=[]
  122. for i in range(0,4):
  123. i=random.randint(1,6)
  124. dices.append(i)
  125. dices.sort(reverse=True)
  126. score=dices[0]+dices[1]+dices[2] #Adds up best 3
  127. scores.append(score)
  128. scores.sort(reverse=True)
  129. choice2=input("Do you want to reroll your lowest score of "+str(scores[3])+" to try and get a better score. No matter what you will need to stick to this score. Yes or no? ").lower()
  130. while choice2 != "yes" and choice2 != "no": #Option to reroll lowest score
  131. print("You did not give a valid answer. Type yes or no")
  132. choice2=input("Do you want to reroll your lowest score of "+str(scores[3])+" yes or no?: ")
  133. if choice2 == "no":
  134. print("\nYou have chosen no")
  135. if choice2 == "yes":
  136. print("\nYou have chosen yes") #If yes
  137. scores.pop(3)
  138. dices=[]
  139. for i in range(0,4): #New score
  140. i=random.randint(1,6)
  141. dices.append(i)
  142. dices.sort(reverse=True)
  143. score=dices[0]+dices[1]+dices[2]
  144. print("The new score is",score)
  145. scores.append(score)
  146. scores.sort(reverse=True)
  147. print("The values for your 4 attributes are",scores[0],scores[1],scores[2],scores[3])
  148. print("Please assign the values to the attributes: Strength, Agility, Magic & Luck for the character",name)
  149. strength=input("\nWhich score would you like the attribute Strength be assigned too?: ")
  150. while strength != str(scores[0]) and strength != str(scores[1]) and strength != str(scores[2]) and strength != str(scores[3]): #Validation
  151. print("You did not enter a valid answer. Try again")
  152. strength=input("\nWhich score would you like the attribute Strength be assigned too?: ")
  153. strength=int(strength)
  154. scores.remove(strength)
  155. print("\nThe remaining scores are",scores[0],scores[1],scores[2])
  156. agility=input("Which score would you like the attribute Agility be assigned too: ")
  157. while agility != str(scores[0]) and agility != str(scores[1]) and agility != str(scores[2]): #Validation
  158. print("You did not enter a valid answer. Try again")
  159. agility=input("\nWhich score would you like the attribute Agilityu be assigned too: ")
  160. agility=int(agility)
  161. scores.remove(agility)
  162. print("\nThe remaining scores are",scores[0],scores[1])
  163. magic=input("Which score would you like the attribute Magic to be assigned too: ")
  164. while magic != str(scores[0]) and magic != str(scores[1]): #Validation
  165. print("You did not enter a valid answer. Try again")
  166. magic=input("\nWhich score would you like the attribute Magic to be assigned too: ")
  167. magic=int(magic)
  168. scores.remove(magic)
  169. print("This means the remaining score",scores[0],"will be assigned to Luck")
  170. luck=int(scores[0])
  171. print("The characters Hit Point will always start off with 2")
  172. hitpoint=2
  173. party.append(name)
  174. party.append(strength)
  175. party.append(agility)
  176. party.append(magic)
  177. party.append(luck)
  178. party.append(hitpoint) #Adds values to a list
  179.  
  180. print("\nYour party is:") #Displays the party
  181. print(party[0],"\nStrength:",party[1],"\nAgility:",party[2],"\nMagic:",party[3],"\nLuck:",party[4],"\nHit Point:",party[5],"\n")
  182. print(party[6],"\nStrength:",party[7],"\nAgility:",party[8],"\nMagic:",party[9],"\nLuck:",party[10],"\nHit Point:",party[11],"\n")
  183. print(party[12],"\nStrength:",party[13],"\nAgility:",party[14],"\nMagic:",party[15],"\nLuck:",party[16],"\nHit Point:",party[17],"\n")
  184. print(party[18],"\nStrength:",party[19],"\nAgility:",party[20],"\nMagic:",party[21],"\nLuck:",party[22],"\nHit Point:",party[23],"\n")
  185. blacklist=[]
  186. attributes=["strength","agility","magic","luck"]
  187.  
  188.  
  189. print("\nThe adventure begins, Your party stands ahead of a Dragon that wishes to kill you. One of your party members must duel the dragon to have a chance of passing the Dragon to reach the end-game. Who will you choose to challenge the dragon?")
  190. dice=random.randint(0,3)
  191. challengerating=random.randint(5,15)
  192. chosenattribute=attributes[dice]
  193. print("This is a",chosenattribute,"challenge and the challenge level is",challengerating)
  194. choice=input("\nPlease choose which character name you wish to challenge the dragon: ")
  195. if len(party) == 6: #Validation
  196. while choice != party[0]:
  197. print("You did not give us a valid answer try again.")
  198. choice=input("Please choose which character name you wish to challenge the dragon: ")
  199. if len(party) == 12:
  200. while choice != party[0] and choice != party[6]:
  201. print("You did not give us a valid answer try again.")
  202. choice=input("Please choose which character name you wish to challenge the dragon: ")
  203. if len(party) == 18:
  204. while choice != party[0] and choice != party[6] and choice != party[12]:
  205. print("You did not give us a valid answer try again.")
  206. choice=input("Please choose which character name you wish to challenge the dragon: ")
  207. if len(party) == 24:
  208. while choice != party[0] and choice != party[6] and choice != party[12] and choice != party[18]:
  209. print("You did not give us a valid answer try again.")
  210. choice=input("\nPlease choose which character name you wish to challenge the dragon: ")
  211. blacklist=[]
  212. for i in range(0,len(party)):
  213. if choice == party[i]: #Gets required values from the party
  214. chosenname=party[i]
  215. if chosenattribute=="strength":
  216. chosenvalue=party[i+1]
  217. if chosenattribute=="agility":
  218. chosenvalue=party[i+2]
  219. if chosenattribute=="magic":
  220. chosenvalue=party[i+3]
  221. if chosenattribute=="luck":
  222. chosenvalue=party[i+4]
  223. chosenhitpoint=party[i+5] #each one - description, choice descriptionx4
  224. break
  225. print("\nThe character you have chosen is",chosenname)
  226. dice2=random.randint(1,20)
  227. challengetotal=dice2+challengerating
  228. print("The challenge total of this challenge is",challengetotal)
  229. dice3=random.randint(1,20)
  230. charactertotal=chosenvalue+dice3
  231. print("Your characters total is",charactertotal)
  232. if charactertotal >= challengetotal: #Compares values
  233. print("\nYour character has beaten the challenge and passes the Dragon")
  234. if chosenhitpoint == 4:
  235. print("The characters hit point has reached the max level of 4. We cannot add anymore hit points to the character")
  236. blacklist.append(chosenname)
  237. if chosenhitpoint < 4:
  238. party.insert(i+5,chosenhitpoint+1)
  239. party.pop(i+6)
  240. print("We have added 1 to the characters hit point value to make it equal to",chosenhitpoint+1)
  241. print("Your character is fatigued and cannot be used in the next fight")
  242. blacklist.append(chosenname)
  243. if charactertotal < challengetotal:
  244. print("\nYour character has lost the challenge but the dragon has ran away.")
  245. if chosenhitpoint == 1:
  246. print("Your character has died and is no longer in your party")
  247. blacklist.append(chosenname)
  248. party.pop(i) #Removes character
  249. party.pop(i)
  250. party.pop(i)
  251. party.pop(i)
  252. party.pop(i)
  253. party.pop(i)
  254. if chosenhitpoint > 1:
  255. print("Your character will lose a hitpoint")
  256. party.insert(i+5,chosenhitpoint-1)
  257. party.pop(i+6)
  258. print("\nYour character is fatigued and cannot be used in the next fight")
  259. blacklist.append(chosenname)
  260.  
  261. print("\nYour party now is:") #Displays the party
  262. if len(party) < 6:
  263. print("Your party is now completely dead")
  264. if len(party) >= 6:
  265. print(party[0],"\nStrength:",party[1],"\nAgility:",party[2],"\nMagic:",party[3],"\nLuck:",party[4],"\nHit Point:",party[5],"\n")
  266. if len(party) >= 12:
  267. print(party[6],"\nStrength:",party[7],"\nAgility:",party[8],"\nMagic:",party[9],"\nLuck:",party[10],"\nHit Point:",party[11],"\n")
  268. if len(party) >= 18:
  269. print(party[12],"\nStrength:",party[13],"\nAgility:",party[14],"\nMagic:",party[15],"\nLuck:",party[16],"\nHit Point:",party[17],"\n")
  270. if len(party) == 24:
  271. print(party[18],"\nStrength:",party[19],"\nAgility:",party[20],"\nMagic:",party[21],"\nLuck:",party[22],"\nHit Point:",party[23],"\n")
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279. print("\nThe next challenge is the mighty dog besides the Great Wall. One of your party members must challenge the duel to climb the Great Wall.")
  280. dice=random.randint(0,3)
  281. challengerating=random.randint(5,15)
  282. chosenattribute=attributes[dice]
  283. print("This is a",chosenattribute,"challenge and the challenge level is",challengerating)
  284. choice=input("\nPlease choose which character name you wish to challenge the dog: ")
  285. if len(party) == 6: #Validation
  286. while choice != party[0] or choice == blacklist[0]:
  287. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  288. choice=input("Please choose which character name you wish to challenge the dog: ")
  289. if len(party) == 12:
  290. while choice != party[0] and choice != party[6] or choice == blacklist[0]:
  291. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  292. choice=input("Please choose which character name you wish to challenge the dog: ")
  293. if len(party) == 18:
  294. while choice != party[0] and choice != party[6] and choice != party[12] or choice == blacklist[0]:
  295. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  296. choice=input("Please choose which character name you wish to challenge the dog: ")
  297. if len(party) == 24:
  298. while choice != party[0] and choice != party[6] and choice != party[12] and choice != party[18] or choice == blacklist[0]:
  299. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  300. choice=input("\nPlease choose which character name you wish to challenge the dog: ")
  301. blacklist=[]
  302. for i in range(0,len(party)):
  303. if choice == party[i]: #Gets required values from the party
  304. chosenname=party[i]
  305. if chosenattribute=="strength":
  306. chosenvalue=party[i+1]
  307. if chosenattribute=="agility":
  308. chosenvalue=party[i+2]
  309. if chosenattribute=="magic":
  310. chosenvalue=party[i+3]
  311. if chosenattribute=="luck":
  312. chosenvalue=party[i+4]
  313. chosenhitpoint=party[i+5] #each one - description, choice descriptionx4
  314. break
  315. print("\nThe character you have chosen is",chosenname)
  316. dice2=random.randint(1,20)
  317. challengetotal=dice2+challengerating
  318. print("The challenge total of this challenge is",challengetotal)
  319. dice3=random.randint(1,20)
  320. charactertotal=chosenvalue+dice3
  321. print("Your characters total is",charactertotal)
  322. if charactertotal >= challengetotal: #Compares values
  323. print("\nYour character has beaten the challenge and you pass the dog")
  324. if chosenhitpoint == 4:
  325. print("The characters hit point has reached the max level of 4. We cannot add anymore hit points to the character")
  326. blacklist.append(chosenname)
  327. if chosenhitpoint < 4:
  328. party.insert(i+5,chosenhitpoint+1)
  329. party.pop(i+6)
  330. print("We have added 1 to the characters hit point value to make it equal to",chosenhitpoint+1)
  331. print("Your character is fatigued and cannot be used in the next fight")
  332. blacklist.append(chosenname)
  333. if charactertotal < challengetotal:
  334. print("\nYour character has lost the challenge but the dog has ran away")
  335. if chosenhitpoint == 1:
  336. print("Your character has died and is no longer in your party")
  337. blacklist.append(chosenname)
  338. party.pop(i) #Removes character from the party
  339. party.pop(i)
  340. party.pop(i)
  341. party.pop(i)
  342. party.pop(i)
  343. party.pop(i)
  344. if chosenhitpoint > 1:
  345. print("Your character will lose a hitpoint")
  346. party.insert(i+5,chosenhitpoint-1)
  347. party.pop(i+6)
  348. print("\nYour character is fatigued and cannot be used in the next fight")
  349. blacklist.append(chosenname)
  350.  
  351. print("\nYour party now is:") #Displays the party
  352. if len(party) <= 6:
  353. print("Your party is now completely dead")
  354. if len(party) >= 6:
  355. print(party[0],"\nStrength:",party[1],"\nAgility:",party[2],"\nMagic:",party[3],"\nLuck:",party[4],"\nHit Point:",party[5],"\n")
  356. if len(party) >= 12:
  357. print(party[6],"\nStrength:",party[7],"\nAgility:",party[8],"\nMagic:",party[9],"\nLuck:",party[10],"\nHit Point:",party[11],"\n")
  358. if len(party) >= 18:
  359. print(party[12],"\nStrength:",party[13],"\nAgility:",party[14],"\nMagic:",party[15],"\nLuck:",party[16],"\nHit Point:",party[17],"\n")
  360. if len(party) == 24:
  361. print(party[18],"\nStrength:",party[19],"\nAgility:",party[20],"\nMagic:",party[21],"\nLuck:",party[22],"\nHit Point:",party[23],"\n")
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369. print("\nYou have now passed the Dog as you must pass the 2 robots on the wall. Which party member will challenge them this time?")
  370. dice=random.randint(0,3)
  371. challengerating=random.randint(5,15)
  372. chosenattribute=attributes[dice]
  373. print("\nThis is a",chosenattribute,"challenge and the challenge level is",challengerating)
  374. choice=input("Please choose which character name you wish to challenge the robots: ")
  375. if len(party) == 6: #Validation
  376. while choice != party[0] or choice == blacklist[0]:
  377. print("\nYou did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  378. choice=input("Please choose which character name you wish to challenge the robots: ")
  379. if len(party) == 12:
  380. while choice != party[0] and choice != party[6] or choice == blacklist[0]:
  381. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  382. choice=input("Please choose which character name you wish to challenge the robots: ")
  383. if len(party) == 18:
  384. while choice != party[0] and choice != party[6] and choice != party[12] or choice == blacklist[0]:
  385. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  386. choice=input("Please choose which character name you wish to challenge the robots: ")
  387. if len(party) == 24:
  388. while choice != party[0] and choice != party[6] and choice != party[12] and choice != party[18] or choice == blacklist[0]:
  389. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  390. choice=input("Please choose which character name you wish to challenge the robots: ")
  391. blacklist=[]
  392. for i in range(0,len(party)):
  393. if choice == party[i]:
  394. chosenname=party[i] #Required values from the party
  395. if chosenattribute=="strength":
  396. chosenvalue=party[i+1]
  397. if chosenattribute=="agility":
  398. chosenvalue=party[i+2]
  399. if chosenattribute=="magic":
  400. chosenvalue=party[i+3]
  401. if chosenattribute=="luck":
  402. chosenvalue=party[i+4]
  403. chosenhitpoint=party[i+5] #each one - description, choice descriptionx4
  404. break
  405. print("\nThe character you have chosen is",chosenname)
  406. dice2=random.randint(1,20)
  407. challengetotal=dice2+challengerating
  408. print("The challenge total of this challenge is",challengetotal)
  409. dice3=random.randint(1,20)
  410. charactertotal=chosenvalue+dice3
  411. print("Your characters total is",charactertotal)
  412. if charactertotal >= challengetotal: #Compares values
  413. print("\nYour character has beaten the challenge and passes the robots")
  414. if chosenhitpoint == 4:
  415. print("The characters hit point has reached the max level of 4. We cannot add anymore hit points to the character")
  416. blacklist.append(chosenname)
  417. if chosenhitpoint < 4:
  418. party.insert(i+5,chosenhitpoint+1)
  419. party.pop(i+6)
  420. print("We have added 1 to the characters hit point value to make it equal to",chosenhitpoint+1)
  421. print("Your character is fatigued and cannot be used in the next fight")
  422. blacklist.append(chosenname)
  423. if charactertotal < challengetotal:
  424. print("\nYour character has lost the challenge but the robots have broken down")
  425. if chosenhitpoint == 1:
  426. print("Your character has died and is no longer in your party")
  427. blacklist.append(chosenname)
  428. party.pop(i) #Removes character from the list
  429. party.pop(i)
  430. party.pop(i)
  431. party.pop(i)
  432. party.pop(i)
  433. party.pop(i)
  434. if chosenhitpoint > 1:
  435. print("Your character will lose a hitpoint")
  436. party.insert(i+5,chosenhitpoint-1)
  437. party.pop(i+6)
  438. print("\nYour character is fatigued and cannot be used in the next fight")
  439. blacklist.append(chosenname)
  440.  
  441. print("\nYour party now is:") #Displays the party
  442. if len(party) <= 6:
  443. print("Your party is now completely dead")
  444. if len(party) >= 6:
  445. print(party[0],"\nStrength:",party[1],"\nAgility:",party[2],"\nMagic:",party[3],"\nLuck:",party[4],"\nHit Point:",party[5],"\n")
  446. if len(party) >= 12:
  447. print(party[6],"\nStrength:",party[7],"\nAgility:",party[8],"\nMagic:",party[9],"\nLuck:",party[10],"\nHit Point:",party[11],"\n")
  448. if len(party) >= 18:
  449. print(party[12],"\nStrength:",party[13],"\nAgility:",party[14],"\nMagic:",party[15],"\nLuck:",party[16],"\nHit Point:",party[17],"\n")
  450. if len(party) == 24:
  451. print(party[18],"\nStrength:",party[19],"\nAgility:",party[20],"\nMagic:",party[21],"\nLuck:",party[22],"\nHit Point:",party[23],"\n")
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459. print("\nIn this challenge you must pass the warrior with the giant sword roaming the garden. Which party member will you choose to challenge him?")
  460. dice=random.randint(0,3)
  461. challengerating=random.randint(5,15)
  462. chosenattribute=attributes[dice]
  463. print("This is a",chosenattribute,"challenge and the challenge level is",challengerating)
  464. if len(party) == 6: #Validation
  465. print("As you only have 1 character left, he is no longer fatigued and can fight for you")
  466. choice=input("\nPlease choose which character name you wish to challenge the dragon: ")
  467. if len(party) == 6:
  468. while choice != party[0]:
  469. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  470. choice=input("Please choose which character name you wish to challenge the warrior: ")
  471. if len(party) == 12:
  472. while choice != party[0] and choice != party[6] or choice == blacklist[0]:
  473. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  474. choice=input("Please choose which character name you wish to challenge the warrior: ")
  475. if len(party) == 18:
  476. while choice != party[0] and choice != party[6] and choice != party[12] or choice == blacklist[0]:
  477. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  478. choice=input("Please choose which character name you wish to challenge the warrior: ")
  479. if len(party) == 24:
  480. while choice != party[0] and choice != party[6] and choice != party[12] and choice != party[18] or choice == blacklist[0]:
  481. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  482. choice=input("\nPlease choose which character name you wish to challenge the warrior: ")
  483. blacklist=[]
  484. for i in range(0,len(party)):
  485. if choice == party[i]: #Required values from the party
  486. chosenname=party[i]
  487. if chosenattribute=="strength":
  488. chosenvalue=party[i+1]
  489. if chosenattribute=="agility":
  490. chosenvalue=party[i+2]
  491. if chosenattribute=="magic":
  492. chosenvalue=party[i+3]
  493. if chosenattribute=="luck":
  494. chosenvalue=party[i+4]
  495. chosenhitpoint=party[i+5] #each one - description, choice descriptionx4
  496. break
  497. print("\nThe character you have chosen is",chosenname)
  498. dice2=random.randint(1,20)
  499. challengetotal=dice2+challengerating
  500. print("The challenge total of this challenge is",challengetotal)
  501. dice3=random.randint(1,20)
  502. charactertotal=chosenvalue+dice3
  503. print("Your characters total is",charactertotal)
  504. if charactertotal >= challengetotal:
  505. print("\nYour character has beaten the challenge and the warrior has died")
  506. if chosenhitpoint == 4:
  507. print("The characters hit point has reached the max level of 4. We cannot add anymore hit points to the character")
  508. blacklist.append(chosenname)
  509. if chosenhitpoint < 4: #Compares values
  510. party.insert(i+5,chosenhitpoint+1)
  511. party.pop(i+6)
  512. print("We have added 1 to the characters hit point value to make it equal to",chosenhitpoint+1)
  513. print("Your character is fatigued and cannot be used in the next fight")
  514. blacklist.append(chosenname)
  515. if charactertotal < challengetotal:
  516. print("\nYour character has lost the challenge but the warrior is weakend from his wounds and runs away")
  517. if chosenhitpoint == 1:
  518. print("Your character has died and is no longer in your party")
  519. blacklist.append(chosenname)
  520. party.pop(i) #Removes character from the list
  521. party.pop(i)
  522. party.pop(i)
  523. party.pop(i)
  524. party.pop(i)
  525. party.pop(i)
  526. if chosenhitpoint > 1:
  527. print("Your character will lose a hitpoint")
  528. party.insert(i+5,chosenhitpoint-1)
  529. party.pop(i+6)
  530. print("\nYour character is fatigued and cannot be used in the next fight")
  531. blacklist.append(chosenname)
  532.  
  533. print("\nYour party now is:") #Displays the party
  534. if len(party) <= 6:
  535. print("Your party is now completely dead")
  536. if len(party) >= 6:
  537. print(party[0],"\nStrength:",party[1],"\nAgility:",party[2],"\nMagic:",party[3],"\nLuck:",party[4],"\nHit Point:",party[5],"\n")
  538. if len(party) >= 12:
  539. print(party[6],"\nStrength:",party[7],"\nAgility:",party[8],"\nMagic:",party[9],"\nLuck:",party[10],"\nHit Point:",party[11],"\n")
  540. if len(party) >= 18:
  541. print(party[12],"\nStrength:",party[13],"\nAgility:",party[14],"\nMagic:",party[15],"\nLuck:",party[16],"\nHit Point:",party[17],"\n")
  542. if len(party) == 24:
  543. print(party[18],"\nStrength:",party[19],"\nAgility:",party[20],"\nMagic:",party[21],"\nLuck:",party[22],"\nHit Point:",party[23],"\n")
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551. print("\nThe final challenge is the giant elephant standing before the room containing the magic treasure. You must select a party member to defeat it.")
  552. dice=random.randint(0,3)
  553. challengerating=random.randint(5,15)
  554. chosenattribute=attributes[dice]
  555. print("\nThis is a",chosenattribute,"challenge and the challenge level is",challengerating)
  556. if len(party) == 0: #Extra validation incase all the characters are no longer alive
  557. print("You have lost all your characters and can't take part in this challenge")
  558. if len(party)==6:
  559. print("As you only have 1 character left, he is no longer fatigued and can fight for you")
  560. if len(party) == 6: #Validation
  561. choice=input("Please choose which character name you wish to challenge the elephant: ")
  562. while choice != party[0]:
  563. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  564. choice=input("Please choose which character name you wish to challenge the elephant: ")
  565. if len(party) == 12:
  566. choice=input("Please choose which character name you wish to challenge the elephant: ")
  567. while choice != party[0] and choice != party[6] or choice == blacklist[0]:
  568. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  569. choice=input("Please choose which character name you wish to challenge the elephant: ")
  570. if len(party) == 18:
  571. choice=input("Please choose which character name you wish to challenge the elephant: ")
  572. while choice != party[0] and choice != party[6] and choice != party[12] or choice == blacklist[0]:
  573. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  574. choice=input("Please choose which character name you wish to challenge the elephant: ")
  575. if len(party) == 24:
  576. choice=input("Please choose which character name you wish to challenge the elephant: ")
  577. while choice != party[0] and choice != party[6] and choice != party[12] and choice != party[18] or choice == blacklist[0]:
  578. print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
  579. choice=input("Please choose which character name you wish to challenge the elephant: ")
  580. blacklist=[]
  581. if len(party) != 0:
  582. print("test")
  583. for i in range(0,len(party)):
  584. if len(party) == 0:
  585. break
  586. if choice == party[i]: #Required values from the party
  587. chosenname=party[i]
  588. if chosenattribute=="strength":
  589. chosenvalue=party[i+1]
  590. if chosenattribute=="agility":
  591. chosenvalue=party[i+2]
  592. if chosenattribute=="magic":
  593. chosenvalue=party[i+3]
  594. if chosenattribute=="luck":
  595. chosenvalue=party[i+4]
  596. chosenhitpoint=party[i+5] #each one - description, choice descriptionx4
  597. break
  598. print("\nThe character you have chosen is",chosenname)
  599. dice2=random.randint(1,20)
  600. challengetotal=dice2+challengerating
  601. print("The challenge total of this challenge is",challengetotal)
  602. dice3=random.randint(1,20)
  603. charactertotal=chosenvalue+dice3
  604. print("Your characters total is",charactertotal)
  605. if charactertotal >= challengetotal: #Compares values
  606. print("\nYour character has beaten the challenge and the elephant has fallen to the ground")
  607. if chosenhitpoint == 4:
  608. print("The characters hit point has reached the max level of 4. We cannot add anymore hit points to the character")
  609. blacklist.append(chosenname)
  610. if chosenhitpoint < 4:
  611. party.insert(i+5,chosenhitpoint+1)
  612. party.pop(i+6)
  613. print("We have added 1 to the characters hit point value to make it equal to",chosenhitpoint+1)
  614. print("Your character is fatigued and cannot be used in the next fight")
  615. blacklist.append(chosenname)
  616. if charactertotal < challengetotal:
  617. print("\nYour character has lost the challenge but the elephant is tired and goes to sleep")
  618. if chosenhitpoint == 1:
  619. print("Your character has died and is no longer in your party")
  620. blacklist.append(chosenname)
  621. party.pop(i) #Removes character from the party
  622. party.pop(i)
  623. party.pop(i)
  624. party.pop(i)
  625. party.pop(i)
  626. party.pop(i)
  627. if chosenhitpoint > 1:
  628. print("Your character will lose a hitpoint")
  629. party.insert(i+5,(chosenhitpoint-1))
  630. party.pop(i+6)
  631. print("\nYour character is fatigued and cannot be used in the next fight")
  632. blacklist.append(chosenname)
  633.  
  634. print("\nYour party now is:") #Displays the party
  635. if len(party) <= 6:
  636. print("Your party is now completely dead")
  637. if len(party) >= 6:
  638. print(party[0],"\nStrength:",party[1],"\nAgility:",party[2],"\nMagic:",party[3],"\nLuck:",party[4],"\nHit Point:",party[5],"\n")
  639. if len(party) >= 12:
  640. print(party[6],"\nStrength:",party[7],"\nAgility:",party[8],"\nMagic:",party[9],"\nLuck:",party[10],"\nHit Point:",party[11],"\n")
  641. if len(party) >= 18:
  642. print(party[12],"\nStrength:",party[13],"\nAgility:",party[14],"\nMagic:",party[15],"\nLuck:",party[16],"\nHit Point:",party[17],"\n")
  643. if len(party) == 24:
  644. print(party[18],"\nStrength:",party[19],"\nAgility:",party[20],"\nMagic:",party[21],"\nLuck:",party[22],"\nHit Point:",party[23],"\n")
  645.  
  646.  
  647. print("\nThe adventure is over. You have found the magic treasure.")
  648. choice=input("Do you want to save your party incase you want to use it again? Yes or no: ").lower()
  649. while choice != "yes" and choice != "no": #Option to save the party
  650. print("You did not give a valid answer. Try again")
  651. choice=input("Do you want to save your party incase you want to use it again? Yes or no: ").lower()
  652.  
  653. if choice == "no":
  654. print("\nYou have chosen no. Have a good day")
  655.  
  656. if choice == "yes":
  657. print("\nYou have chosen yes")
  658. if len(party) == 0: #Validation
  659. print("Your whole party is dead therefore we cannnot save it")
  660. if len(party) >= 6:
  661. chosenname=input("\nPlease give us the name you want the party to be saved under: ")
  662. while len(chosenname) == 0 or chosenname[0] == " ":
  663. print("You did not enter a letter or had a space as your first character. Please try again")
  664. chosenname=input("\nPlease give us the name you want the party to be saved under: ")
  665. while True:
  666. try:
  667. myfile=open(chosenname+".txt","r") #Test to see if there is already a file with the name
  668. myfile.close()
  669. print("There is already a file with this name.")
  670. choice=input("\nDo you want to use this filename and overwrite the file or create a new file? Yes or no? ").lower() #Option to choose whether to overwrite the file
  671. while choice != "yes" and choice != "no": #Validation
  672. print("You did not give a valid answer. Try again")
  673. choice=input("Do you want to use this filename and overwrite the file or create a new file? Yes or no? ").lower()
  674. if choice == "yes":
  675. print("You have chosen yes so the file will be overwritten")
  676. break
  677. if choice == "no":
  678. print("You have chosen no. Please choose another filename to save your party.")
  679. chosenname=input("Please give us another name you want the party to be saved under: ")
  680. while len(chosenname) == 0 or chosenname[0] == " ":
  681. print("You did not enter a letter or had a space as your first character. Please try again")
  682. chosenname=input("\nPlease give us the name you want the party to be saved under: ")
  683. except:
  684. ValueError
  685. print("\nThis is a unique save name and the party will be saved")
  686. break
  687.  
  688.  
  689.  
  690. myfile=open(chosenname+".txt","w") #Writes the party to the file
  691. myfile.write(party[0]+"\n")
  692. myfile.write(str(party[1])+"\n")
  693. myfile.write(str(party[2])+"\n")
  694. myfile.write(str(party[3])+"\n")
  695. myfile.write(str(party[4])+"\n")
  696. myfile.write(str(party[5])+"\n")
  697. if len(party) >= 12:
  698. myfile.write(party[6]+"\n")
  699. myfile.write(str(party[7])+"\n")
  700. myfile.write(str(party[8])+"\n")
  701. myfile.write(str(party[9])+"\n")
  702. myfile.write(str(party[10])+"\n")
  703. myfile.write(str(party[11])+"\n")
  704. if len(party) >= 18:
  705. myfile.write(party[12]+"\n")
  706. myfile.write(str(party[13])+"\n")
  707. myfile.write(str(party[14])+"\n")
  708. myfile.write(str(party[15])+"\n")
  709. myfile.write(str(party[16])+"\n")
  710. myfile.write(str(party[17])+"\n")
  711. if len(party) == 24:
  712. myfile.write(party[18]+"\n")
  713. myfile.write(str(party[19])+"\n")
  714. myfile.write(str(party[20])+"\n")
  715. myfile.write(str(party[21])+"\n")
  716. myfile.write(str(party[22])+"\n")
  717. myfile.write(str(party[23]))
  718. myfile.close()
  719. print("Your party has been saved")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement