Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from colorama import Fore
- from random import randint
- def main():
- welcomeScreen()
- scoreBoard = multiRoundGame()
- gameOverScreen(scoreBoard)
- def welcomeScreen():
- clear()
- print("ROCK, PAPER, SCISSORS")
- print("\n\n...The games rock, paper, scissor, you should know the rules...")
- wait = input("\n\nPress ENTER to play")
- def gameOverScreen(scoreboard):
- clear()
- print("ROCK, PAPER, SCISSORS")
- print("\nFINAL SCORE: ")
- print("\nYour score: ", scoreboard[0])
- print("\nComputer score: ", scoreboard[1])
- print("\nTies: ", scoreboard[2])
- wait = input("\n\nPress ENTER to play again or Q to quit..")
- def multiRoundGame():
- clear()
- print("ROCK, PAPER, SCISSORS")
- winningScore = int(input("\n\nEnter the number of rounds needed to win the game: "))
- scoreboard = [0,0,0]
- keepPlaying = True
- roundNumber = 0
- while keepPlaying:
- clear()
- roundNumber += 1
- print("ROCK, PAPER, SCISSORS")
- print("\n\nFirst player to win", winningScore, "rounds is the winner!")
- print("\nRound #", roundNumber)
- print("\n\nThe current score:")
- print("\nYour score:", scoreboard[0])
- print("Computer score:" , scoreboard[1])
- print("Tie games:" , scoreboard[1])
- gameResult = rockPaperScissors(scoreboard)
- scoreboard[gameResult] += 1
- wait = input(Fore.WHITE + "\nPress ENTER to continue")
- if scoreboard[0] == winningScore or scoreboard[1] == winningScore:
- keepPlaying = False
- return scoreboard
- def rockPaperScissors(scoreboard):
- rpsDictionary = {'r':'ROCK', 'p': 'PAPER', 's': 'Scissors'}
- computerDictionary = {0: 'r', 1 : 'p', 2 : 's'}
- clear()
- print("ROCK, PAPER, SCISSORS")
- print("\nYour score ->", scoreboard[0])
- print("The computers score ->", scoreboard[1])
- print("Ties->", scoreboard[2])
- print("\nYour turn ->")
- userChoice = rpsInputCheck()
- userWord = rpsDictionary[userChoice]
- computerKey = randint(0, 2)
- computerChoice = computerDictionary[computerKey]
- rockWin = "ROCK busts a fat whallop on the SZAs!"
- scissorWin = "SCISSORS slice up the PAPER real good!"
- paperWin = "PAPER bags ROCK!"
- userWinner = "Hip-hip hooray! You win this round!"
- computerWinner = "Holy shift! The computer wins this round!"
- tieRound = "What the function?! That round's a tie!"
- if userChoice == 'r' and computerChoice == 'p':
- print(paperWin)
- print(computerWinner)
- gameResult = 1
- elif userChoice == 'p' and computerChoice == 'r':
- print(paperWin)
- print(userWinner)
- gameResult = 0
- elif userChoice == 's' and computerChoice == 'p':
- print(scissorWin)
- print(userWinner)
- gameResult = 0
- elif userChoice == 'p' and computerChoice == 's':
- print(scissorWin)
- print(computerWinner)
- gameResult = 1
- elif userChoice == 'r' and computerChoice == 'p':
- print(paperWin)
- print(computerWinner)
- gameResult = 1
- elif userChoice == 'r' and computerChoice == 's':
- print(rockWin)
- print(userWinner)
- gameResult = 0
- elif userChoice == 's' and computerChoice == 'r':
- print(rockWin)
- print(computerWinner)
- gameResult = 1
- elif userChoice == 'r' and computerChoice == 'r':
- print(tieRound)
- gameResult = 2
- elif userChoice == 's' and computerChoice == 's':
- print(tieRound)
- gameResult = 2
- elif userChoice == 'p' and computerChoice == 'p':
- print(tieRound)
- gameResult = 2
- return gameResult
- def rpsInputCheck():
- goodChoice = ['r' , 'p', 's']
- keepAsking = True
- while keepAsking:
- userChoice = input(Fore.WHITE + '\nChoose R for ROCK, P for PAPER, or S for SCISSORS: ' + Fore.LIGHTYELLOW_EX)
- userChoice = userChoice.lower()
- if userChoice in goodChoice:
- keepAsking = False
- return userChoice
- else:
- print(Fore.RED + "You little heck, choose again!" + Fore.WHITE)
- def clear():
- print("\x1bc")
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement