Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import time
- P_win = 0
- C_win = 0
- print('''welcome to the battle arena
- In this game you will be asked to choose 10 warriors from a selection of 3 classes
- you can choose however many of each class you want
- The rules are relatively simple
- footmen beats archer
- horsemen beats footmen
- archer beats horsemen
- its essentially a rock paper scissors triangle with a twist
- The game is decided with two battles.
- the first battle eliminates numbers based on this rock paper scissors triangle.
- The second battle focuses on total remaining forces and the player with the most left wins.
- if there is a tie in forces for the second battle it comes down to a luck draw. as battles will always have a winner.
- have fun''')
- time.sleep(5)
- while True:
- P_footmen = 0
- P_horsemen = 0
- P_archers = 0
- C_footmen = 0
- C_horsemen = 0
- C_archers = 0
- print("choose your warriors")
- time.sleep(2)
- while True:
- p = 10
- P_footmen = int(input("Number of footmen? "))
- p -= P_footmen
- print("you have", p, "men left to pick")
- if p == 0:
- break
- time.sleep(1)
- P_horsemen = int(input("Number of horsemen? "))
- p -= P_horsemen
- print("you have", p, "men left to pick")
- if p == 0:
- break
- time.sleep(1)
- P_archers = int(input("number of archers? "))
- p -= P_archers
- if p < 0:
- print("you picked too many warriors. 10 maximum")
- elif p == 0:
- break
- elif p > 0:
- ("you didn't choose enough warriors")
- time.sleep(1)
- print("you choose", P_footmen , "footmen")
- time.sleep(1)
- print(P_horsemen, "horsemen")
- time.sleep(1)
- print("and", P_archers , "archers")
- while True:
- c = 10
- v = random.randint(1,3)
- #in order to make this part of the code much less predictable I added a choose order variable
- #this allows multiple choose orders so the first two choosen aren't the most likely to get more choosen
- #this makes the random element more uniformly random.
- #as well I origionally planned on doing all 9 possible orentations of choose orders but that would have been dreadfully tedious and boring
- if v == 1:
- C_footmen = random.randint(0,c)
- c -= C_footmen
- if c == 0:
- break
- C_horsemen = random.randint(0,c)
- c -= C_horsemen
- if c == 0:
- break
- C_archers = c #the last part of every pick order will always be c. because it is the last to be picked. and must fill the last requirements
- c -= C_archers
- if c == 0:
- break
- elif v == 2:
- C_archers = random.randint(0,c)
- c -= C_archers
- if c == 0:
- break
- C_footmen = random.randint(0,c)
- c -= C_footmen
- if c == 0:
- break
- C_horsemen = c
- c -= C_horsemen
- if c == 0:
- break
- elif v == 3:
- C_horsemen = random.randint(0,c)
- c -= C_horsemen
- if c == 0:
- break
- C_archers = random.randint(0,c)
- c -= C_archers
- if c == 0:
- break
- C_footmen = c
- c -= C_footmen
- if c == 0:
- break
- time.sleep(1)
- print("computer is choosing.....")
- time.sleep(1)
- print("soldiers selected, let the battle begin!")
- print(" ")
- time.sleep(1)
- print("player sends out", P_footmen, "footmen.", P_horsemen, "horsemen, and", P_archers, "archers")
- time.sleep(1)
- print("against the computer's forces of", C_footmen, "Footmen,", C_horsemen, "horsemen, and", C_archers, "archers")
- #These variables stand for hte remaining of each unit on each team
- PR_footmen = P_footmen - C_horsemen
- PR_horsemen = P_horsemen - C_archers
- PR_archers = P_archers - C_footmen
- CR_footmen = C_footmen - P_horsemen
- CR_horsemen = C_horsemen - P_archers
- CR_archers = C_archers - P_footmen
- #I don't wish for hte game to display negitive numbers so this setup is to solve that
- if PR_footmen < 0:
- PR_footmen = 0
- if PR_horsemen < 0:
- PR_horsemen = 0
- if PR_archers < 0:
- PR_archers =0
- if CR_footmen < 0:
- CR_footmen = 0
- if CR_horsemen < 0:
- CR_horsemen = 0
- if CR_archers < 0:
- CR_archers =0
- time.sleep(3)
- print("battle results are...!")
- print(" ")
- time.sleep(3)
- print("the player with", PR_footmen, "footmen", PR_horsemen, "horsemen, and", PR_archers, " archers remaining")
- time.sleep(3)
- print("and the computer with", CR_footmen, "footmen", CR_horsemen, "horsemen, and", CR_archers, "archers remaining")
- print(" ")
- time.sleep(3)
- while True:
- if PR_footmen == 0 and PR_horsemen == 0 and PR_archers == 0:
- print("The player has lost before the second battle. Computer wins!")
- P_win += 1
- break
- elif CR_footmen == 0 and CR_horsemen == 0 and CR_archers == 0:
- print("the computer has lost before the second battle. Player wins!")
- C_win += 1
- break
- print("the second battle begins!!!")
- print(" ")
- time.sleep(3)
- print("the battle results are...!!")
- time.sleep(3)
- P_total = PR_footmen + PR_horsemen + PR_archers
- C_total = CR_footmen + CR_horsemen + CR_archers
- if P_total > C_total:
- print("player wins with a total force count of", P_total, "versus the computer's", C_total)
- P_win += 1
- break
- elif C_total > P_total:
- print("the computer wins with a total force count of", C_total, "versus the player's", P_total)
- C_win += 1
- break
- elif C_total == P_total:
- print("the forces left over are equal on each side. the battle comes down to a draw of luck!")
- time.sleep(3)
- #I am not allowing a tie as this is a battle, and it is very unlikeley that a tie would occur in a battle.
- #so it comes down to a bit of extra luck if end forces are infact equal
- L = random.randint(1,2)
- if L == 1:
- print("By a stroke of luck the player is victorious!")
- P_win += 1
- elif L == 2:
- print("By a stroke of luck the computer is victorious!")
- C_win += 1
- time.sleep(2)
- end = input("would you like to play again? y/n")
- if end == "n":
- break
- elif end == "y":
- print("player has currently won", P_win, "rounds, and computer", C_win, "rounds")
- else:
- while True:
- end = input("incorrect input. type y or n ")
- if end == "y" or end == "n":
- break
- r = P_win + C_win
- print("you've ended the game after", r, "rounds")
- time.sleep(2)
- print("player won", P_win, "rounds, and the computer has won", C_win, "rounds")
- time.sleep(2)
- if P_win > C_win:
- print("Player is the overal winner!")
- elif C_win > P_win:
- print("computer is the overal winner!")
- elif C_win == P_win:
- print("the overal game is a tie!")
- print("game over")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement