Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @author ~Kevin Stillman~
- import random
- from random import choice
- options = ["rock", "paper", "scissors"]
- # This is where the user will input their name
- player1name = input("Hello and welcome to the game! Please type in your name! \n")
- # This is where you will choose if you want to play against the robot or another player
- gametype = input(f"Hello {player1name}! Would you like to play against another PLAYER or against the COMPUTER?").lower()
- #this is where the while statement begins
- if gametype.startswith("p"):
- player2name = input("Player 2, please enter your name!")
- playagain = True
- ################################################
- #################functions#####################
- def player1wins():
- global player1wincount
- player1wincount += 1
- return player1wincount
- def player2wins():
- global player2wincount
- player2wincount += 1
- return player2wincount
- def computerwins():
- global computerwincount
- computerwincount += 1
- return computerwincount
- def playagainprompt():
- global playagain
- playagain = input("Would you like to play again?\n")
- if playagain.lower().startswith("y"):
- playagain = True
- elif playagain.lower().startswith("n"):
- playagain = False
- player1wincount = 0
- player2wincount = 0
- computerwincount = 0
- while playagain == True:
- if gametype.startswith("p"):
- print(
- f"Okay {player1name}, please have player 2 enter their name!\n") # The player has chosen pvp, ask to enter name
- print(f"{player1name.upper()} VS {player2name.upper()}! \n Good luck!")
- # here is where the next nest will go containing the game itself
- p1choice = input(
- f"Alright {player1name}, please enter your choice. \n ...ROCK...\n ...PAPER... \n ...SCISSORS...\n")
- p1choice = p1choice.lower()
- print("***ANTICHEAT***\n" * 75)
- p2choice = input(
- f"Alright {player2name}, please enter your choice. \n ...ROCK...\n ...PAPER... \n ...SCISSORS...\n")
- p2choice = p2choice.lower()
- if p1choice.startswith("r"):
- if p2choice.startswith("r"):
- print("It's a draw!")
- elif p2choice.startswith("p"):
- print(f"{player2name} wins! Paper covers Rock!")
- player2wins()
- elif p2choice.startswith("s"):
- print(f"{player1name} wins! Rock breaks Scissors!")
- player1wins()
- elif p1choice.startswith("p"):
- if p2choice.startswith("r"):
- print(f"{player1name} wins! Paper covers Rock!")
- player1wins()
- elif p2choice.startswith("p"):
- print("It's a draw!")
- elif p2choice.startswith("s"):
- print(f"{player2name} wins! Scissors cuts Paper!")
- player2wins()
- elif p1choice.startswith("s"):
- if p2choice.startswith("r"):
- print(f"{player2name} wins! Rock breaks Scissors!")
- player2wins()
- elif p2choice.startswith("p"):
- print(f"{player1name} wins! Scissors cuts paper!")
- player1wins()
- elif p2choice.startswith("s"):
- print("It's a draw!")
- else:
- print(
- "You absolutely SHOULD NOT see this. WHAT DID YOU DO?! \n ...You probably didn't type in a correct game option.. silly goose.")
- print(f"{player1name} wins: {player1wincount}")
- print(f"{player2name} wins: {player2wincount}")
- elif gametype.startswith("c"):
- # print("You have chosen the computer! Good luck!")
- # Here is where the next nest will go containing the game itself
- playerchoice = input(f"Okay {player1name}, please choose. \n ...ROCK...\n ...PAPER... \n ...SCISSORS...\n")
- playerchoice = playerchoice.lower()
- print(f"{player1name} has chosen {playerchoice.upper()}.")
- computerchoice = random.choice(options)
- print(f"The Computer has chosen {computerchoice.upper()}!")
- if playerchoice.startswith("r"):
- if computerchoice == "rock":
- print("It's a draw!")
- elif computerchoice == "paper":
- print("The computer wins! Paper covers Rock!")
- elif computerchoice == "scissors":
- print(f"{player1name} wins! Rock crushes Scissors!")
- elif playerchoice.startswith("p"):
- if computerchoice == "rock":
- print(f"{player1name} wins! Paper covers Rock!")
- elif computerchoice == "paper":
- print("It's a draw!")
- elif computerchoice == "scissors":
- print("The computer wins! Scissors cuts Paper!")
- elif playerchoice.startswith("s"):
- if computerchoice == "rock":
- print("Computer wins! Paper covers rock!")
- elif computerchoice == "paper":
- print(f"{player1name} wins! Scissors cuts paper!")
- elif computerchoice == "scissors":
- print("It's a draw!")
- print(f"{player1name} wins: {player1wincount}")
- print(f"Computer wins: {computerwincount}")
- playagainprompt()
- else:
- print("Thank you for playing!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement