""" ------------------------------------------------- Project: Take-Away Game Standard: 91883 (AS1.7) v.1 School: Tauranga Boys' College Author: Rod William Santiago Date: THE DATE YOU COMPLETED THE CODE Python: 3.5 ------------------------------------------------- """ # Constants and initial variables MAX_CHIPS = 21 playerOneScore = 0 playerTwoScore = 0 # Intro duction about the game and explination print("-=~~=--=~~=--=~~=--=~~=--=~~=-") print ("🅣 🅐 🅚 🅔 🅐 🅦 🅐 🅨 🅖 🅐 🅜 🅔") print("Welcome to Take Away Game") print("You will have 21 cards to take away.") print("The last player who takes the last number Wins!") print("Take away until you WIN!") # Getting the players names playerOneName = input("Enter Player One's name: ") playerTwoName = input("Enter Player Two's name: ") # Checking for valid integer input for rounds (1-5) while True: try: rounds = int(input("How many rounds do you want to play (1-5)? ")) if rounds < 1 or rounds > 5: # if the user inputs a number above 5 or below 1, it asks again print("Please choose a number between 1 and 5.") else: break # if the input is valid, break out of the loop except ValueError: # If the user doesn't input a number, it asks again and gets mad at the player. print("Put a number you dum fool") print("How hard is pick between 1-5?") # Game loop for the specified number of rounds while rounds > 0: chipsLeft = MAX_CHIPS # Loop for how many rounds they choosen to play while chipsLeft > 0: print(f"Chips left: {chipsLeft}") # Player One turn to take how many cards as they want. player1Chips = int(input(f"{playerOneName}, how many chips do you want to take? ")) chipsLeft -= player1Chips if chipsLeft <= 0: # Player 1 wins if chipsLeft is zero or less playerOneScore += 1 print(f"{playerOneName} wins this round!") break # Player two turn to take away a card. print(f"Chips left: {chipsLeft}") player2Chips = int(input(f"{playerTwoName}, how many chips do you want to take? ")) chipsLeft -= player2Chips if chipsLeft <= 0: # Player 2 wins if chipsLeft is zero or less playerTwoScore += 1 print(f"{playerTwoName} wins this round!") break rounds -= 1 # Reduce the number of rounds # Final scores print(f"Final Score: {playerOneName}: {playerOneScore}, {playerTwoName}: {playerTwoScore}") # Determine the winnir iof the game if playerOneScore > playerTwoScore: print(f"{playerOneName} 🅦 🅘 🅝' 🅢 🅣 🅗 🅔 🅖 🅐 🅜 🅔!") elif playerTwoScore > playerOneScore: print(f"{playerTwoName} 🅦 🅘 🅝' 🅢 🅣 🅗 🅔 🅖 🅐 🅜 🅔!") else: print("It's a tie!")