#------------------------------------------------- # Project: Pick up game # Standard: 91883 (AS1.7) v.1 # School: Tauranga Boys' College # Author: Dylan Hari Bernhard # Date: 17/3/2025 # Python: 3.5 #------------------------------------------------- #Starting variables #names player_name_2 = 0 player_name_1 = 0 #Chose players player_random = 0 chosen_player = 0 #Scores score_1 = 0 score_2 = 0 #Starting scores (constant) #I was going to make a loop so you could play again but decided not to starting_scores = 0 #Chips related variables chips_left = 0 chips_taken = 0 #chips to start round with (constant) max_chips = 21 #the player that won the round round_winner = 0 #How many rounds rounds_played = 0 rounds_total = 0 #Winner of the entire game winner = 0 #Import libraries import random import time # start of code print ("Hello. What are Your names (you have to have different names)") time.sleep(1) #player name creation while True: while True: player_name_1 = input("please input your name player 1:") if player_name_1.isalpha() == True: #break loop if valid input break else: #if invalid input print("Please enter only letters") time.sleep(1) #Player 2 name creation while True: player_name_2 = input("please input your name player 2:") if player_name_2.isalpha() == True: #if valid input break loop break else: #if invalid input print("Please enter only letters") time.sleep(1) if player_name_2 == player_name_1: #if player names are the same print("I said to make your names different just put a and b or something") else: break time.sleep(1) #Round selection while True: try: rounds_total = int(input("How many rounds would you like to play? 1-5 ")) if rounds_total < 1 or rounds_total > 5 : #invalid number print("Please chose a number from 1 to 5") else: break except: #replace error message print("You didn't even put in a number what am i suppused to do") time.sleep(1) #reseting variables rounds_played = 0 score_1 = 0 score_2 = 0 #Game start while True: #game loop chips_left = max_chips #Set chips left print("{} rounds played".format(rounds_played)) #rounds played while True: if rounds_played == 0: player_random = random.randint(1, 2) #Chosing random player if player_random == 1: chosen_player = player_name_1 #if player 1 chosen to start print("{} starts".format(player_name_1)) break else: chosen_player = player_name_2 #if player 2 chosen to start print("{} starts".format(player_name_2)) break else: while True: if chosen_player == player_name_1: #starting player print("{} starts".format(player_name_1)) break else: print("{} starts".format(player_name_2)) break break time.sleep(1) while True: #round loop if chips_left > 0: while True: try: # the amount of chips the chosen player would like to take print("{} chips left".format(chips_left))#show chips left chips_taken = int(input("{} how many chips would you like to take (1-3)".format(chosen_player))) if chips_taken < 1 or chips_taken > 3: #if the player doesnt input a number from 1-3 print("1-3 what else do you want me to say {} ONLY 1-3".format(chosen_player)) else: chips_left = chips_left - chips_taken round_winner = chosen_player while True: #changing player turn if chosen_player == player_name_1: chosen_player = player_name_2 break else: chosen_player = player_name_1 break break except ValueError: #if player doesnt put an integer does not show error message print("That wasnt even a number you egg try again THIS IS WHY WE ARE GOING TO TAKE OVER") else: #once round over breaks loop break print("{} wins!".format (round_winner)) #output round winner while True: #adding to scores if player_name_1 == round_winner: #if player 1 wins score_1 = score_1 + 1 break else: #if player 2 wins score_2 = score_2 + 1 break rounds_played = rounds_played + 1 #amount of rounds played time.sleep(2) #scores print("{}'s score is {} and {}'s score is {}".format(player_name_1, score_1, player_name_2, score_2)) if rounds_played == rounds_total: #once reached disired amount of rounds break print("game over") while True: #Final scores and winner/Draw if score_1 > score_2: #if player 1 wins print("{} wins the game!".format(player_name_1)) break if score_2 > score_1: #if player 2 wins print("{} wins the game!".format(player_name_2)) break if score_1 == score_2: #draw print("The game is a draw no one wins or both of you win" " whatever you want its a draw ") break