I am creating a Rock, Paper, Scissors game for a class. as part of the game I need to have a weapon menu display to the screen for the user to select from. Then the computer will randomly select a weapon from a list. The problem I am facing (I believe) is that the list items range from [0,2] where my menu items list [1,3]. I have searched around for hours, but I don't understand the complex things I have been reading online so I'm not certain how to apply them.
# random integer
from random import randint
# list for weapon
WEAPON = ["Rock", "Paper", "Scissors"]
# one player mode
def onePlayer():
scoreP = 0
scoreC = 0
again = ""
player = False
print("---------------------------------------------")
print("\n\tPlayer VS Computer")
while player == False:
print("Weapons:")
print("1. Rock")
print("2. Paper")
print("3. Scissors")
print("4. Quit")
player = input("\nSelect your weapon: ")
if player == "quit" or player == "q" or player == "4":
player = True
main()
else:
try:
player = int(player)
if player == 1:
player = WEAPON[0]
elif player == 2:
player = WEAPON[1]
elif player == 3:
player = WEAPON[2]
except:
print("please enter a number 1 through 4\n")
computer = WEAPON[randint(0,2)]
if player == computer:
print(player," vs ",computer)
print("It's a tie!\n")
print("Player:",scoreP,"\nComputer:",scoreC)
print("")
elif player == 1:
# computer == paper
if computer == 1:
print(player," vs ",computer)
print("Paper covers rock! You lose!\n")
scoreC = scoreC + 1
print("Player:",scoreP,"\nComputer:",scoreC)
print("")
else:
print("Rock smashes scissors. You win!\n")
scoreP = scoreP + 1
print("Player:",scoreP,"\nComputer:",scoreC)
print("")
elif player == 2:
if computer == 2:
print(player," vs ",computer)
print("Scissors cut paper! You lose!\n")
scoreC = scoreC + 1
print("Player:",scoreP,"\nComputer:",scoreC)
print("")
else:
print("Paper covers rock. You win!\n")
scoreP = scoreP + 1
print("Player:",scoreP,"\nComputer:",scoreC)
print("")
elif player == 3:
if computer == 0:
print(player," vs ",computer)
print("Rock smashes scissors! You lose!\n")
scoreC = scoreC + 1
print("Player:",scoreP,"\nComputer:",scoreC)
print("")
else:
print("Scissors cut paper. You win!\n")
scoreP = scoreP + 1
print("Player:",scoreP,"\nComputer:",scoreC)
print("")
#else:
# print("Please select a valid play option\n")
player = False
Please don't mind the print statements inside the if/else statements. I realize these will need to be changed. My main issue is the logic of comparing user input to the computer's random list selection.