Advertisement
KevinStillman

Rock Paper Scissors v1.4

Oct 14th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.21 KB | None | 0 0
  1. @author ~Kevin Stillman~
  2.  
  3. import random
  4. from random import choice
  5.  
  6. options = ["rock", "paper", "scissors"]
  7.  
  8. # This is where the user will input their name
  9. player1name = input("Hello and welcome to the game! Please type in your name! \n")
  10. # This is where you will choose if you want to play against the robot or another player
  11. gametype = input(f"Hello {player1name}! Would you like to play against another PLAYER or against the COMPUTER?").lower()
  12. #this is where the while statement begins
  13. if gametype.startswith("p"):
  14.     player2name = input("Player 2, please enter your name!")
  15. playagain = True
  16. ################################################
  17. #################functions#####################
  18. def player1wins():
  19.     global player1wincount
  20.     player1wincount += 1
  21.     return player1wincount
  22.  
  23. def player2wins():
  24.     global player2wincount
  25.     player2wincount += 1
  26.     return player2wincount
  27.  
  28. def computerwins():
  29.     global computerwincount
  30.     computerwincount += 1
  31.     return computerwincount
  32.  
  33.  
  34.  
  35. def playagainprompt():
  36.     global playagain
  37.     playagain = input("Would you like to play again?\n")
  38.     if playagain.lower().startswith("y"):
  39.         playagain = True
  40.     elif playagain.lower().startswith("n"):
  41.         playagain = False
  42. player1wincount = 0
  43. player2wincount = 0
  44. computerwincount = 0
  45. while playagain == True:
  46.     if gametype.startswith("p"):
  47.         print(
  48.             f"Okay {player1name}, please have player 2 enter their name!\n")  # The player has chosen pvp, ask to enter name
  49.         print(f"{player1name.upper()} VS {player2name.upper()}! \n Good luck!")
  50.     # here is where the next nest will go containing the game itself
  51.         p1choice = input(
  52.             f"Alright {player1name}, please enter your choice. \n ...ROCK...\n ...PAPER... \n ...SCISSORS...\n")
  53.         p1choice = p1choice.lower()
  54.         print("***ANTICHEAT***\n" * 75)
  55.         p2choice = input(
  56.             f"Alright {player2name}, please enter your choice. \n ...ROCK...\n ...PAPER... \n ...SCISSORS...\n")
  57.         p2choice = p2choice.lower()
  58.         if p1choice.startswith("r"):
  59.             if p2choice.startswith("r"):
  60.                 print("It's a draw!")
  61.             elif p2choice.startswith("p"):
  62.                 print(f"{player2name} wins! Paper covers Rock!")
  63.                 player2wins()
  64.             elif p2choice.startswith("s"):
  65.                 print(f"{player1name} wins! Rock breaks Scissors!")
  66.                 player1wins()
  67.         elif p1choice.startswith("p"):
  68.             if p2choice.startswith("r"):
  69.                 print(f"{player1name} wins! Paper covers Rock!")
  70.                 player1wins()
  71.             elif p2choice.startswith("p"):
  72.                 print("It's a draw!")
  73.             elif p2choice.startswith("s"):
  74.                 print(f"{player2name} wins! Scissors cuts Paper!")
  75.                 player2wins()
  76.         elif p1choice.startswith("s"):
  77.             if p2choice.startswith("r"):
  78.                 print(f"{player2name} wins! Rock breaks Scissors!")
  79.                 player2wins()
  80.             elif p2choice.startswith("p"):
  81.                 print(f"{player1name} wins! Scissors cuts paper!")
  82.                 player1wins()
  83.             elif p2choice.startswith("s"):
  84.                 print("It's a draw!")
  85.         else:
  86.             print(
  87.             "You absolutely SHOULD NOT see this. WHAT DID YOU DO?! \n ...You probably didn't type in a correct game option.. silly goose.")
  88.         print(f"{player1name} wins: {player1wincount}")
  89.         print(f"{player2name} wins: {player2wincount}")
  90.     elif gametype.startswith("c"):
  91.        # print("You have chosen the computer! Good luck!")
  92.     # Here is where the next nest will go containing the game itself
  93.         playerchoice = input(f"Okay {player1name}, please choose. \n ...ROCK...\n ...PAPER... \n ...SCISSORS...\n")
  94.         playerchoice = playerchoice.lower()
  95.         print(f"{player1name} has chosen {playerchoice.upper()}.")
  96.         computerchoice = random.choice(options)
  97.         print(f"The Computer has chosen {computerchoice.upper()}!")
  98.         if playerchoice.startswith("r"):
  99.             if computerchoice == "rock":
  100.                 print("It's a draw!")
  101.             elif computerchoice == "paper":
  102.                 print("The computer wins! Paper covers Rock!")
  103.             elif computerchoice == "scissors":
  104.                 print(f"{player1name} wins! Rock crushes Scissors!")
  105.         elif playerchoice.startswith("p"):
  106.             if computerchoice == "rock":
  107.                 print(f"{player1name} wins! Paper covers Rock!")
  108.             elif computerchoice == "paper":
  109.                 print("It's a draw!")
  110.             elif computerchoice == "scissors":
  111.                 print("The computer wins! Scissors cuts Paper!")
  112.         elif playerchoice.startswith("s"):
  113.             if computerchoice == "rock":
  114.                 print("Computer wins! Paper covers rock!")
  115.             elif computerchoice == "paper":
  116.                 print(f"{player1name} wins! Scissors cuts paper!")
  117.             elif computerchoice == "scissors":
  118.                 print("It's a draw!")
  119.         print(f"{player1name} wins: {player1wincount}")
  120.         print(f"Computer wins: {computerwincount}")
  121.     playagainprompt()
  122.  
  123.  
  124.  
  125. else:
  126.     print("Thank you for playing!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement