Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- choice=input("Welcome to the adventure. Do you want to create a party or import an existing party?: ").lower() #Choice
- while choice != "create" and choice != "import":
- print("You did not give a valid answer. Type create or import please.")
- choice=input("Do you want to create a party or import an existing party: ")
- if choice == "import": #If they choose import
- print("\nYou have chosen to import a party")
- while True:
- filename=input("Please tell us the file name you believe the file is called: ")
- try:
- myfile=open(filename+".txt","r") #Checks if it's a valid file
- print("\nYou gave a valid filename")
- break
- except FileNotFoundError:
- print("You did not give a valid filename. Please try again.")
- contents=myfile.read()
- party=contents.splitlines()
- for i in range(0,len(party)):
- try:
- party.insert(i,int(party[i])) #Turns numbers into integers
- party.pop(i+1)
- except ValueError:
- ()
- if len(party) == 6: #Decides how many characters need to be created
- z=3
- print("You will need to create 3 characters")
- if len(party) == 12:
- z=2
- print("You will need to create 2 characters")
- if len(party) == 18:
- z=1
- print("You will need to create a character")
- if len(party) == 24:
- z=0
- print("Your party is missing no characters")
- for i in range(0,z): #Repeats certain amount of times for 4 different scores
- name=input("\nPlease input the name of character "+str(i+1)+" please: ")
- while len(name) == 0 or name[0] == " ":
- print("You did not enter a letter or had a space as your first character. Please try again")
- name=input("\nPlease input the name of character "+str(i+1)+" please: ")
- scores=[]
- for x in range(0,4): #4 dice rolles
- dices=[]
- for i in range(0,4):
- i=random.randint(1,6)
- dices.append(i)
- dices.sort(reverse=True)
- score=dices[0]+dices[1]+dices[2] #Adds up best 3
- scores.append(score)
- scores.sort(reverse=True)
- 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()
- while choice2 != "yes" and choice2 != "no": #Option to reroll lowest score
- print("You did not give a valid answer. Type yes or no")
- choice2=input("Do you want to reroll your lowest score of "+str(scores[3])+" yes or no?: ")
- if choice2 == "no":
- print("\nYou have chosen no")
- if choice2 == "yes":
- print("\nYou have chosen yes") #If yes
- scores.pop(3)
- dices=[]
- for i in range(0,4): #New score
- i=random.randint(1,6)
- dices.append(i)
- dices.sort(reverse=True)
- score=dices[0]+dices[1]+dices[2]
- print("The new score is",score)
- scores.append(score)
- scores.sort(reverse=True)
- print("The values for your 4 attributes are",scores[0],scores[1],scores[2],scores[3])
- print("Please assign the values to the attributes: Strength, Agility, Magic & Luck for the character",name)
- strength=input("\nWhich score would you like the attribute Strength be assigned too?: ")
- while strength != str(scores[0]) and strength != str(scores[1]) and strength != str(scores[2]) and strength != str(scores[3]): #Validation
- print("You did not enter a valid answer. Try again")
- strength=input("\nWhich score would you like the attribute Strength be assigned too?: ")
- strength=int(strength)
- scores.remove(strength)
- print("\nThe remaining scores are",scores[0],scores[1],scores[2])
- agility=input("Which score would you like the attribute Agility be assigned too: ")
- while agility != str(scores[0]) and agility != str(scores[1]) and agility != str(scores[2]): #Validation
- print("You did not enter a valid answer. Try again")
- agility=input("\nWhich score would you like the attribute Agilityu be assigned too: ")
- agility=int(agility)
- scores.remove(agility)
- print("\nThe remaining scores are",scores[0],scores[1])
- magic=input("Which score would you like the attribute Magic to be assigned too: ")
- while magic != str(scores[0]) and magic != str(scores[1]): #Validation
- print("You did not enter a valid answer. Try again")
- magic=input("\nWhich score would you like the attribute Magic to be assigned too: ")
- magic=int(magic)
- scores.remove(magic)
- print("This means the remaining score",scores[0],"will be assigned to Luck")
- luck=int(scores[0])
- print("The characters Hit Point will always start off with 2")
- hitpoint=2
- party.append(name)
- party.append(strength)
- party.append(agility)
- party.append(magic)
- party.append(luck)
- party.append(hitpoint) #Adds values to a list
- if choice == "create": #if they choose to create
- print("You have chosen to create a party")
- party=[]
- for i in range(0,4): #Repeats 4 times for 4 different scores
- name=input("\nPlease input the name of character "+str(i+1)+" please: ")
- while len(name) == 0 or name[0] == " ":
- print("You did not enter a letter or had a space as your first character. Please try again")
- name=input("\nPlease input the name of character "+str(i+1)+" please: ")
- scores=[]
- for x in range(0,4): #4 dice rolles
- dices=[]
- for i in range(0,4):
- i=random.randint(1,6)
- dices.append(i)
- dices.sort(reverse=True)
- score=dices[0]+dices[1]+dices[2] #Adds up best 3
- scores.append(score)
- scores.sort(reverse=True)
- 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()
- while choice2 != "yes" and choice2 != "no": #Option to reroll lowest score
- print("You did not give a valid answer. Type yes or no")
- choice2=input("Do you want to reroll your lowest score of "+str(scores[3])+" yes or no?: ")
- if choice2 == "no":
- print("\nYou have chosen no")
- if choice2 == "yes":
- print("\nYou have chosen yes") #If yes
- scores.pop(3)
- dices=[]
- for i in range(0,4): #New score
- i=random.randint(1,6)
- dices.append(i)
- dices.sort(reverse=True)
- score=dices[0]+dices[1]+dices[2]
- print("The new score is",score)
- scores.append(score)
- scores.sort(reverse=True)
- print("The values for your 4 attributes are",scores[0],scores[1],scores[2],scores[3])
- print("Please assign the values to the attributes: Strength, Agility, Magic & Luck for the character",name)
- strength=input("\nWhich score would you like the attribute Strength be assigned too?: ")
- while strength != str(scores[0]) and strength != str(scores[1]) and strength != str(scores[2]) and strength != str(scores[3]): #Validation
- print("You did not enter a valid answer. Try again")
- strength=input("\nWhich score would you like the attribute Strength be assigned too?: ")
- strength=int(strength)
- scores.remove(strength)
- print("\nThe remaining scores are",scores[0],scores[1],scores[2])
- agility=input("Which score would you like the attribute Agility be assigned too: ")
- while agility != str(scores[0]) and agility != str(scores[1]) and agility != str(scores[2]): #Validation
- print("You did not enter a valid answer. Try again")
- agility=input("\nWhich score would you like the attribute Agilityu be assigned too: ")
- agility=int(agility)
- scores.remove(agility)
- print("\nThe remaining scores are",scores[0],scores[1])
- magic=input("Which score would you like the attribute Magic to be assigned too: ")
- while magic != str(scores[0]) and magic != str(scores[1]): #Validation
- print("You did not enter a valid answer. Try again")
- magic=input("\nWhich score would you like the attribute Magic to be assigned too: ")
- magic=int(magic)
- scores.remove(magic)
- print("This means the remaining score",scores[0],"will be assigned to Luck")
- luck=int(scores[0])
- print("The characters Hit Point will always start off with 2")
- hitpoint=2
- party.append(name)
- party.append(strength)
- party.append(agility)
- party.append(magic)
- party.append(luck)
- party.append(hitpoint) #Adds values to a list
- print("\nYour party is:") #Displays the party
- print(party[0],"\nStrength:",party[1],"\nAgility:",party[2],"\nMagic:",party[3],"\nLuck:",party[4],"\nHit Point:",party[5],"\n")
- print(party[6],"\nStrength:",party[7],"\nAgility:",party[8],"\nMagic:",party[9],"\nLuck:",party[10],"\nHit Point:",party[11],"\n")
- print(party[12],"\nStrength:",party[13],"\nAgility:",party[14],"\nMagic:",party[15],"\nLuck:",party[16],"\nHit Point:",party[17],"\n")
- print(party[18],"\nStrength:",party[19],"\nAgility:",party[20],"\nMagic:",party[21],"\nLuck:",party[22],"\nHit Point:",party[23],"\n")
- blacklist=[]
- attributes=["strength","agility","magic","luck"]
- 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?")
- dice=random.randint(0,3)
- challengerating=random.randint(5,15)
- chosenattribute=attributes[dice]
- print("This is a",chosenattribute,"challenge and the challenge level is",challengerating)
- choice=input("\nPlease choose which character name you wish to challenge the dragon: ")
- if len(party) == 6: #Validation
- while choice != party[0]:
- print("You did not give us a valid answer try again.")
- choice=input("Please choose which character name you wish to challenge the dragon: ")
- if len(party) == 12:
- while choice != party[0] and choice != party[6]:
- print("You did not give us a valid answer try again.")
- choice=input("Please choose which character name you wish to challenge the dragon: ")
- if len(party) == 18:
- while choice != party[0] and choice != party[6] and choice != party[12]:
- print("You did not give us a valid answer try again.")
- choice=input("Please choose which character name you wish to challenge the dragon: ")
- if len(party) == 24:
- while choice != party[0] and choice != party[6] and choice != party[12] and choice != party[18]:
- print("You did not give us a valid answer try again.")
- choice=input("\nPlease choose which character name you wish to challenge the dragon: ")
- blacklist=[]
- for i in range(0,len(party)):
- if choice == party[i]: #Gets required values from the party
- chosenname=party[i]
- if chosenattribute=="strength":
- chosenvalue=party[i+1]
- if chosenattribute=="agility":
- chosenvalue=party[i+2]
- if chosenattribute=="magic":
- chosenvalue=party[i+3]
- if chosenattribute=="luck":
- chosenvalue=party[i+4]
- chosenhitpoint=party[i+5] #each one - description, choice descriptionx4
- break
- print("\nThe character you have chosen is",chosenname)
- dice2=random.randint(1,20)
- challengetotal=dice2+challengerating
- print("The challenge total of this challenge is",challengetotal)
- dice3=random.randint(1,20)
- charactertotal=chosenvalue+dice3
- print("Your characters total is",charactertotal)
- if charactertotal >= challengetotal: #Compares values
- print("\nYour character has beaten the challenge and passes the Dragon")
- if chosenhitpoint == 4:
- print("The characters hit point has reached the max level of 4. We cannot add anymore hit points to the character")
- blacklist.append(chosenname)
- if chosenhitpoint < 4:
- party.insert(i+5,chosenhitpoint+1)
- party.pop(i+6)
- print("We have added 1 to the characters hit point value to make it equal to",chosenhitpoint+1)
- print("Your character is fatigued and cannot be used in the next fight")
- blacklist.append(chosenname)
- if charactertotal < challengetotal:
- print("\nYour character has lost the challenge but the dragon has ran away.")
- if chosenhitpoint == 1:
- print("Your character has died and is no longer in your party")
- blacklist.append(chosenname)
- party.pop(i) #Removes character
- party.pop(i)
- party.pop(i)
- party.pop(i)
- party.pop(i)
- party.pop(i)
- if chosenhitpoint > 1:
- print("Your character will lose a hitpoint")
- party.insert(i+5,chosenhitpoint-1)
- party.pop(i+6)
- print("\nYour character is fatigued and cannot be used in the next fight")
- blacklist.append(chosenname)
- print("\nYour party now is:") #Displays the party
- if len(party) < 6:
- print("Your party is now completely dead")
- if len(party) >= 6:
- print(party[0],"\nStrength:",party[1],"\nAgility:",party[2],"\nMagic:",party[3],"\nLuck:",party[4],"\nHit Point:",party[5],"\n")
- if len(party) >= 12:
- print(party[6],"\nStrength:",party[7],"\nAgility:",party[8],"\nMagic:",party[9],"\nLuck:",party[10],"\nHit Point:",party[11],"\n")
- if len(party) >= 18:
- print(party[12],"\nStrength:",party[13],"\nAgility:",party[14],"\nMagic:",party[15],"\nLuck:",party[16],"\nHit Point:",party[17],"\n")
- if len(party) == 24:
- print(party[18],"\nStrength:",party[19],"\nAgility:",party[20],"\nMagic:",party[21],"\nLuck:",party[22],"\nHit Point:",party[23],"\n")
- 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.")
- dice=random.randint(0,3)
- challengerating=random.randint(5,15)
- chosenattribute=attributes[dice]
- print("This is a",chosenattribute,"challenge and the challenge level is",challengerating)
- choice=input("\nPlease choose which character name you wish to challenge the dog: ")
- if len(party) == 6: #Validation
- while choice != party[0] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the dog: ")
- if len(party) == 12:
- while choice != party[0] and choice != party[6] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the dog: ")
- if len(party) == 18:
- while choice != party[0] and choice != party[6] and choice != party[12] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the dog: ")
- if len(party) == 24:
- while choice != party[0] and choice != party[6] and choice != party[12] and choice != party[18] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("\nPlease choose which character name you wish to challenge the dog: ")
- blacklist=[]
- for i in range(0,len(party)):
- if choice == party[i]: #Gets required values from the party
- chosenname=party[i]
- if chosenattribute=="strength":
- chosenvalue=party[i+1]
- if chosenattribute=="agility":
- chosenvalue=party[i+2]
- if chosenattribute=="magic":
- chosenvalue=party[i+3]
- if chosenattribute=="luck":
- chosenvalue=party[i+4]
- chosenhitpoint=party[i+5] #each one - description, choice descriptionx4
- break
- print("\nThe character you have chosen is",chosenname)
- dice2=random.randint(1,20)
- challengetotal=dice2+challengerating
- print("The challenge total of this challenge is",challengetotal)
- dice3=random.randint(1,20)
- charactertotal=chosenvalue+dice3
- print("Your characters total is",charactertotal)
- if charactertotal >= challengetotal: #Compares values
- print("\nYour character has beaten the challenge and you pass the dog")
- if chosenhitpoint == 4:
- print("The characters hit point has reached the max level of 4. We cannot add anymore hit points to the character")
- blacklist.append(chosenname)
- if chosenhitpoint < 4:
- party.insert(i+5,chosenhitpoint+1)
- party.pop(i+6)
- print("We have added 1 to the characters hit point value to make it equal to",chosenhitpoint+1)
- print("Your character is fatigued and cannot be used in the next fight")
- blacklist.append(chosenname)
- if charactertotal < challengetotal:
- print("\nYour character has lost the challenge but the dog has ran away")
- if chosenhitpoint == 1:
- print("Your character has died and is no longer in your party")
- blacklist.append(chosenname)
- party.pop(i) #Removes character from the party
- party.pop(i)
- party.pop(i)
- party.pop(i)
- party.pop(i)
- party.pop(i)
- if chosenhitpoint > 1:
- print("Your character will lose a hitpoint")
- party.insert(i+5,chosenhitpoint-1)
- party.pop(i+6)
- print("\nYour character is fatigued and cannot be used in the next fight")
- blacklist.append(chosenname)
- print("\nYour party now is:") #Displays the party
- if len(party) <= 6:
- print("Your party is now completely dead")
- if len(party) >= 6:
- print(party[0],"\nStrength:",party[1],"\nAgility:",party[2],"\nMagic:",party[3],"\nLuck:",party[4],"\nHit Point:",party[5],"\n")
- if len(party) >= 12:
- print(party[6],"\nStrength:",party[7],"\nAgility:",party[8],"\nMagic:",party[9],"\nLuck:",party[10],"\nHit Point:",party[11],"\n")
- if len(party) >= 18:
- print(party[12],"\nStrength:",party[13],"\nAgility:",party[14],"\nMagic:",party[15],"\nLuck:",party[16],"\nHit Point:",party[17],"\n")
- if len(party) == 24:
- print(party[18],"\nStrength:",party[19],"\nAgility:",party[20],"\nMagic:",party[21],"\nLuck:",party[22],"\nHit Point:",party[23],"\n")
- 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?")
- dice=random.randint(0,3)
- challengerating=random.randint(5,15)
- chosenattribute=attributes[dice]
- print("\nThis is a",chosenattribute,"challenge and the challenge level is",challengerating)
- choice=input("Please choose which character name you wish to challenge the robots: ")
- if len(party) == 6: #Validation
- while choice != party[0] or choice == blacklist[0]:
- print("\nYou did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the robots: ")
- if len(party) == 12:
- while choice != party[0] and choice != party[6] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the robots: ")
- if len(party) == 18:
- while choice != party[0] and choice != party[6] and choice != party[12] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the robots: ")
- if len(party) == 24:
- while choice != party[0] and choice != party[6] and choice != party[12] and choice != party[18] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the robots: ")
- blacklist=[]
- for i in range(0,len(party)):
- if choice == party[i]:
- chosenname=party[i] #Required values from the party
- if chosenattribute=="strength":
- chosenvalue=party[i+1]
- if chosenattribute=="agility":
- chosenvalue=party[i+2]
- if chosenattribute=="magic":
- chosenvalue=party[i+3]
- if chosenattribute=="luck":
- chosenvalue=party[i+4]
- chosenhitpoint=party[i+5] #each one - description, choice descriptionx4
- break
- print("\nThe character you have chosen is",chosenname)
- dice2=random.randint(1,20)
- challengetotal=dice2+challengerating
- print("The challenge total of this challenge is",challengetotal)
- dice3=random.randint(1,20)
- charactertotal=chosenvalue+dice3
- print("Your characters total is",charactertotal)
- if charactertotal >= challengetotal: #Compares values
- print("\nYour character has beaten the challenge and passes the robots")
- if chosenhitpoint == 4:
- print("The characters hit point has reached the max level of 4. We cannot add anymore hit points to the character")
- blacklist.append(chosenname)
- if chosenhitpoint < 4:
- party.insert(i+5,chosenhitpoint+1)
- party.pop(i+6)
- print("We have added 1 to the characters hit point value to make it equal to",chosenhitpoint+1)
- print("Your character is fatigued and cannot be used in the next fight")
- blacklist.append(chosenname)
- if charactertotal < challengetotal:
- print("\nYour character has lost the challenge but the robots have broken down")
- if chosenhitpoint == 1:
- print("Your character has died and is no longer in your party")
- blacklist.append(chosenname)
- party.pop(i) #Removes character from the list
- party.pop(i)
- party.pop(i)
- party.pop(i)
- party.pop(i)
- party.pop(i)
- if chosenhitpoint > 1:
- print("Your character will lose a hitpoint")
- party.insert(i+5,chosenhitpoint-1)
- party.pop(i+6)
- print("\nYour character is fatigued and cannot be used in the next fight")
- blacklist.append(chosenname)
- print("\nYour party now is:") #Displays the party
- if len(party) <= 6:
- print("Your party is now completely dead")
- if len(party) >= 6:
- print(party[0],"\nStrength:",party[1],"\nAgility:",party[2],"\nMagic:",party[3],"\nLuck:",party[4],"\nHit Point:",party[5],"\n")
- if len(party) >= 12:
- print(party[6],"\nStrength:",party[7],"\nAgility:",party[8],"\nMagic:",party[9],"\nLuck:",party[10],"\nHit Point:",party[11],"\n")
- if len(party) >= 18:
- print(party[12],"\nStrength:",party[13],"\nAgility:",party[14],"\nMagic:",party[15],"\nLuck:",party[16],"\nHit Point:",party[17],"\n")
- if len(party) == 24:
- print(party[18],"\nStrength:",party[19],"\nAgility:",party[20],"\nMagic:",party[21],"\nLuck:",party[22],"\nHit Point:",party[23],"\n")
- 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?")
- dice=random.randint(0,3)
- challengerating=random.randint(5,15)
- chosenattribute=attributes[dice]
- print("This is a",chosenattribute,"challenge and the challenge level is",challengerating)
- if len(party) == 6: #Validation
- print("As you only have 1 character left, he is no longer fatigued and can fight for you")
- choice=input("\nPlease choose which character name you wish to challenge the dragon: ")
- if len(party) == 6:
- while choice != party[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the warrior: ")
- if len(party) == 12:
- while choice != party[0] and choice != party[6] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the warrior: ")
- if len(party) == 18:
- while choice != party[0] and choice != party[6] and choice != party[12] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the warrior: ")
- if len(party) == 24:
- while choice != party[0] and choice != party[6] and choice != party[12] and choice != party[18] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("\nPlease choose which character name you wish to challenge the warrior: ")
- blacklist=[]
- for i in range(0,len(party)):
- if choice == party[i]: #Required values from the party
- chosenname=party[i]
- if chosenattribute=="strength":
- chosenvalue=party[i+1]
- if chosenattribute=="agility":
- chosenvalue=party[i+2]
- if chosenattribute=="magic":
- chosenvalue=party[i+3]
- if chosenattribute=="luck":
- chosenvalue=party[i+4]
- chosenhitpoint=party[i+5] #each one - description, choice descriptionx4
- break
- print("\nThe character you have chosen is",chosenname)
- dice2=random.randint(1,20)
- challengetotal=dice2+challengerating
- print("The challenge total of this challenge is",challengetotal)
- dice3=random.randint(1,20)
- charactertotal=chosenvalue+dice3
- print("Your characters total is",charactertotal)
- if charactertotal >= challengetotal:
- print("\nYour character has beaten the challenge and the warrior has died")
- if chosenhitpoint == 4:
- print("The characters hit point has reached the max level of 4. We cannot add anymore hit points to the character")
- blacklist.append(chosenname)
- if chosenhitpoint < 4: #Compares values
- party.insert(i+5,chosenhitpoint+1)
- party.pop(i+6)
- print("We have added 1 to the characters hit point value to make it equal to",chosenhitpoint+1)
- print("Your character is fatigued and cannot be used in the next fight")
- blacklist.append(chosenname)
- if charactertotal < challengetotal:
- print("\nYour character has lost the challenge but the warrior is weakend from his wounds and runs away")
- if chosenhitpoint == 1:
- print("Your character has died and is no longer in your party")
- blacklist.append(chosenname)
- party.pop(i) #Removes character from the list
- party.pop(i)
- party.pop(i)
- party.pop(i)
- party.pop(i)
- party.pop(i)
- if chosenhitpoint > 1:
- print("Your character will lose a hitpoint")
- party.insert(i+5,chosenhitpoint-1)
- party.pop(i+6)
- print("\nYour character is fatigued and cannot be used in the next fight")
- blacklist.append(chosenname)
- print("\nYour party now is:") #Displays the party
- if len(party) <= 6:
- print("Your party is now completely dead")
- if len(party) >= 6:
- print(party[0],"\nStrength:",party[1],"\nAgility:",party[2],"\nMagic:",party[3],"\nLuck:",party[4],"\nHit Point:",party[5],"\n")
- if len(party) >= 12:
- print(party[6],"\nStrength:",party[7],"\nAgility:",party[8],"\nMagic:",party[9],"\nLuck:",party[10],"\nHit Point:",party[11],"\n")
- if len(party) >= 18:
- print(party[12],"\nStrength:",party[13],"\nAgility:",party[14],"\nMagic:",party[15],"\nLuck:",party[16],"\nHit Point:",party[17],"\n")
- if len(party) == 24:
- print(party[18],"\nStrength:",party[19],"\nAgility:",party[20],"\nMagic:",party[21],"\nLuck:",party[22],"\nHit Point:",party[23],"\n")
- 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.")
- dice=random.randint(0,3)
- challengerating=random.randint(5,15)
- chosenattribute=attributes[dice]
- print("\nThis is a",chosenattribute,"challenge and the challenge level is",challengerating)
- if len(party) == 0: #Extra validation incase all the characters are no longer alive
- print("You have lost all your characters and can't take part in this challenge")
- if len(party)==6:
- print("As you only have 1 character left, he is no longer fatigued and can fight for you")
- if len(party) == 6: #Validation
- choice=input("Please choose which character name you wish to challenge the elephant: ")
- while choice != party[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the elephant: ")
- if len(party) == 12:
- choice=input("Please choose which character name you wish to challenge the elephant: ")
- while choice != party[0] and choice != party[6] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the elephant: ")
- if len(party) == 18:
- choice=input("Please choose which character name you wish to challenge the elephant: ")
- while choice != party[0] and choice != party[6] and choice != party[12] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the elephant: ")
- if len(party) == 24:
- choice=input("Please choose which character name you wish to challenge the elephant: ")
- while choice != party[0] and choice != party[6] and choice != party[12] and choice != party[18] or choice == blacklist[0]:
- print("You did not give us a valid answer try again. Remember, you cannot choose",blacklist[0])
- choice=input("Please choose which character name you wish to challenge the elephant: ")
- blacklist=[]
- if len(party) != 0:
- print("test")
- for i in range(0,len(party)):
- if len(party) == 0:
- break
- if choice == party[i]: #Required values from the party
- chosenname=party[i]
- if chosenattribute=="strength":
- chosenvalue=party[i+1]
- if chosenattribute=="agility":
- chosenvalue=party[i+2]
- if chosenattribute=="magic":
- chosenvalue=party[i+3]
- if chosenattribute=="luck":
- chosenvalue=party[i+4]
- chosenhitpoint=party[i+5] #each one - description, choice descriptionx4
- break
- print("\nThe character you have chosen is",chosenname)
- dice2=random.randint(1,20)
- challengetotal=dice2+challengerating
- print("The challenge total of this challenge is",challengetotal)
- dice3=random.randint(1,20)
- charactertotal=chosenvalue+dice3
- print("Your characters total is",charactertotal)
- if charactertotal >= challengetotal: #Compares values
- print("\nYour character has beaten the challenge and the elephant has fallen to the ground")
- if chosenhitpoint == 4:
- print("The characters hit point has reached the max level of 4. We cannot add anymore hit points to the character")
- blacklist.append(chosenname)
- if chosenhitpoint < 4:
- party.insert(i+5,chosenhitpoint+1)
- party.pop(i+6)
- print("We have added 1 to the characters hit point value to make it equal to",chosenhitpoint+1)
- print("Your character is fatigued and cannot be used in the next fight")
- blacklist.append(chosenname)
- if charactertotal < challengetotal:
- print("\nYour character has lost the challenge but the elephant is tired and goes to sleep")
- if chosenhitpoint == 1:
- print("Your character has died and is no longer in your party")
- blacklist.append(chosenname)
- party.pop(i) #Removes character from the party
- party.pop(i)
- party.pop(i)
- party.pop(i)
- party.pop(i)
- party.pop(i)
- if chosenhitpoint > 1:
- print("Your character will lose a hitpoint")
- party.insert(i+5,(chosenhitpoint-1))
- party.pop(i+6)
- print("\nYour character is fatigued and cannot be used in the next fight")
- blacklist.append(chosenname)
- print("\nYour party now is:") #Displays the party
- if len(party) <= 6:
- print("Your party is now completely dead")
- if len(party) >= 6:
- print(party[0],"\nStrength:",party[1],"\nAgility:",party[2],"\nMagic:",party[3],"\nLuck:",party[4],"\nHit Point:",party[5],"\n")
- if len(party) >= 12:
- print(party[6],"\nStrength:",party[7],"\nAgility:",party[8],"\nMagic:",party[9],"\nLuck:",party[10],"\nHit Point:",party[11],"\n")
- if len(party) >= 18:
- print(party[12],"\nStrength:",party[13],"\nAgility:",party[14],"\nMagic:",party[15],"\nLuck:",party[16],"\nHit Point:",party[17],"\n")
- if len(party) == 24:
- print(party[18],"\nStrength:",party[19],"\nAgility:",party[20],"\nMagic:",party[21],"\nLuck:",party[22],"\nHit Point:",party[23],"\n")
- print("\nThe adventure is over. You have found the magic treasure.")
- choice=input("Do you want to save your party incase you want to use it again? Yes or no: ").lower()
- while choice != "yes" and choice != "no": #Option to save the party
- print("You did not give a valid answer. Try again")
- choice=input("Do you want to save your party incase you want to use it again? Yes or no: ").lower()
- if choice == "no":
- print("\nYou have chosen no. Have a good day")
- if choice == "yes":
- print("\nYou have chosen yes")
- if len(party) == 0: #Validation
- print("Your whole party is dead therefore we cannnot save it")
- if len(party) >= 6:
- chosenname=input("\nPlease give us the name you want the party to be saved under: ")
- while len(chosenname) == 0 or chosenname[0] == " ":
- print("You did not enter a letter or had a space as your first character. Please try again")
- chosenname=input("\nPlease give us the name you want the party to be saved under: ")
- while True:
- try:
- myfile=open(chosenname+".txt","r") #Test to see if there is already a file with the name
- myfile.close()
- print("There is already a file with this name.")
- 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
- while choice != "yes" and choice != "no": #Validation
- print("You did not give a valid answer. Try again")
- choice=input("Do you want to use this filename and overwrite the file or create a new file? Yes or no? ").lower()
- if choice == "yes":
- print("You have chosen yes so the file will be overwritten")
- break
- if choice == "no":
- print("You have chosen no. Please choose another filename to save your party.")
- chosenname=input("Please give us another name you want the party to be saved under: ")
- while len(chosenname) == 0 or chosenname[0] == " ":
- print("You did not enter a letter or had a space as your first character. Please try again")
- chosenname=input("\nPlease give us the name you want the party to be saved under: ")
- except:
- ValueError
- print("\nThis is a unique save name and the party will be saved")
- break
- myfile=open(chosenname+".txt","w") #Writes the party to the file
- myfile.write(party[0]+"\n")
- myfile.write(str(party[1])+"\n")
- myfile.write(str(party[2])+"\n")
- myfile.write(str(party[3])+"\n")
- myfile.write(str(party[4])+"\n")
- myfile.write(str(party[5])+"\n")
- if len(party) >= 12:
- myfile.write(party[6]+"\n")
- myfile.write(str(party[7])+"\n")
- myfile.write(str(party[8])+"\n")
- myfile.write(str(party[9])+"\n")
- myfile.write(str(party[10])+"\n")
- myfile.write(str(party[11])+"\n")
- if len(party) >= 18:
- myfile.write(party[12]+"\n")
- myfile.write(str(party[13])+"\n")
- myfile.write(str(party[14])+"\n")
- myfile.write(str(party[15])+"\n")
- myfile.write(str(party[16])+"\n")
- myfile.write(str(party[17])+"\n")
- if len(party) == 24:
- myfile.write(party[18]+"\n")
- myfile.write(str(party[19])+"\n")
- myfile.write(str(party[20])+"\n")
- myfile.write(str(party[21])+"\n")
- myfile.write(str(party[22])+"\n")
- myfile.write(str(party[23]))
- myfile.close()
- print("Your party has been saved")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement