#""" #------------------------------------------------- # Project: Pickup Game # Standard: TE PUNGA - Programming Assessment # School: Tauranga Boys' College # Author: Raiden de villiers # Date: March 19 2024 # Python: 3.7.4 #------------------------------------------------- #""" # all the values which are used in code player1turn = 1 chips = 21 rounds = 1 player2 = False player1 = True addplayer1score = 0 addplayer2score = 0 maxrounds = 0 pl1orpl2 = () #Asks for your name and uses that for the rest of the game while True: name1 = str(input("What is your name? (Player One) ")) if name1.isalpha() == True: break else: print("Your actual name bro...") #Asks for player 2s name while True: name2 = str(input("What is your name? (Player Two) ")) if name2.isalpha() == True: break else: print("Your actual name bro...") #Checks if you want to play a valid amount of rounds while True: try: maxrounds = int(input("How many rounds do you want to play? ")) if maxrounds < 1 or maxrounds > 5: print("Sorry you can only play a minimum of 1 round and a maximum of 5") else: break #Stops you from entering numbers that are not 1-5 except: print("Please enter a proper number from 1-5") #Checks if there are enough chips and if you have played (set) amount of rounds while True: maxchips = 21 if rounds > 1 or rounds <= maxrounds: if chips < 0 or chips == 0: print("There are not enough chips") if player1 == True: addplayer2score += 1 print (str("{} Has {} Points".format(name2, addplayer2score))) else: addplayer1score += 1 print (str("{} Has {} Points".format(name1, addplayer1score))) print("Round {} has come to an end".format(rounds)) print("Starting round {}".format(rounds + 1)) rounds += 1 print ("") print ("") chips = 21 continue else: #Tells you how many chips are left before letting you take any while True: if player1 == True and chips > 0: print("There are {} chips left".format(chips)) try: #You play the game and take 1-3 chips then it skips to the next persons turn player1turn = (input("How many chips do you want to take? 1-3 ({})".format(name1))) #Checks if the player chose a valid input of chips to prevent over taking or under taking if int(player1turn) > 0 and int(player1turn) < 4: chips -= int(player1turn) player1 = False else: #What it tells you when you try to take an invaild amount of chips e.g (100 chips) print("Take a fair amont of chips you greedy bastard") #Prevents the code from breaking if player types (-,/,*,!,$,etc) except ValueError: print("Please enter an actual number") #copy of player ones code with the slight variation of it working on player two instead elif player1 == False and chips > 0: print("There are {} chips left".format(chips)) try: player2turn = int(input("How many chips do you want to take? 1-3 ({})".format(name2))) if int(player2turn) > 0 and int(player2turn) < 4: chips -= player2turn player1 = True else: print("Take a fair amont of chips you greedy bastard") except ValueError: print("Please enter an actual number") else: break else: break