#------------------------------------------------------------------------------------------# #Project Name: Assessment 1 - 21 # # Author: Emmanuel Drugu # # 18/03/2024 # Copyright: (c) Emmanuel Drugu 2024 # Licence: #------------------------------------------------------------------------------------------ import random import time import os import sys # Varibles # Names so the players won't get confused and can give dialouge. #---------------------- Player_One = "" Player_Two = "" #---------------------- #---------------------- Max_Chips = 21 #This is the max amount of chips Chips_Left = Max_Chips #This will tell players how many chips are in the bag Player_Input = 0 #The player input. #---------------------- #---------------------- Rounds = 1 # Counts up until it reaches the same value of Max_Rounds. Turn_Points = 0 # This will be the point system. Based on how many turns. Player1_Points = 0 # Player 1s point. Player2_Points = 0# Player 2s point. Max_Rounds = 0 #The amount of rounds you want. Response = 0 #Gives a wacky response each time. #---------------------- def Title(): #This is the cool title screen print("██████╗ ██╗") time.sleep(0.75) print("╚════██╗███║") time.sleep(0.75) print(" █████╔╝╚██║") time.sleep(0.75) print("██╔═══╝ ██║") time.sleep(0.75) print("███████╗ ██║") time.sleep(0.75) print("╚══════╝ ╚═╝") def ClearScreen(): os.system('cls' if os.name=='nt' else 'clear') # This will clear the text so the text looks tidy and not clutter. ClearScreen() #--------------------------------------------------------------------------------------- while True: time.sleep(0.5) Player_One = input("Please enter your name player one: ") if Player_One.isalpha() == True: break else: print("That can't be a username. Try again") while True: time.sleep(0.5) Player_Two = input("Please enter your name player two: ") if Player_Two.isalpha() == True: break else: print("That can't be a username. Try again") print("Thank you {} & {}. Please enjoy the game and good luck to both of you." .format(Player_One, Player_Two)) #--------------------------------------------------------------------------------------- This code helps get the names and stuff. time.sleep(2.5) ClearScreen() Title() print() #--------------------------------------------------------------------------------------- Max_Rounds = int(input("How many rounds will you play? ")) print("You have chosen {} rounds good luck and enjoy. " .format(Max_Rounds)) time.sleep(2) #--------------------------------------------------------------------------------------- This gets how much rounds you want to play. ClearScreen() time.sleep(2) #------------------------------------------------------------------------------------------------------------------------------------------------------ while Rounds != Max_Rounds + 1: while Chips_Left > 0: print("It is now {}'s turn!" .format(Player_One)) time.sleep(1) print("There are {} chips left in the bag!" .format(Chips_Left)) time.sleep(1) while True: Player_Input = int(input("You can only take 1 to 3. So how many chips do you wish to take from the bag? ")) if Player_Input >= 4: print("Don't be greedy {}. Think of {}." .format(Player_One, Player_Two)) else: Chips_Left = Chips_Left - Player_Input print("{} has taken {} chips from the bag." .format(Player_One, Player_Input)) break Turn_Points = Turn_Points + 1 if Chips_Left <= 0: Player1_Points = Player1_Points + Turn_Points time.sleep(1) print("{} has won round {}! {} has earned {} points" .format(Player_One, Rounds, Player_One, Turn_Points)) time.sleep(1) print("{} has {} and {} has {}" .format(Player_One, Player1_Points, Player_Two, Player2_Points)) break print("There are {} chips left in the bag!" .format(Chips_Left)) time.sleep(1) print("It is now {}'s turn!" .format(Player_Two)) time.sleep(1) while True: Player_Input = int(input("You can only take 1 to 3. So how many chips do you wish to take from the bag? ")) if Player_Input >= 4: print("Don't be greedy {}. Think of {}." .format(Player_Two, Player_One)) else: Chips_Left = Chips_Left - Player_Input print("{} has taken {} chips from the bag." .format(Player_Two, Player_Input)) break Turn_Points = Turn_Points + 1 if Chips_Left <= 0: Player2_Points = Player2_Points + Turn_Points time.sleep(1) print("{} has won round {}! {} has earned {} points!".format(Player_Two, Rounds, Player_Two, Turn_Points)) time.sleep(1) print("{} has {} and {} has {}" .format(Player_One, Player1_Points, Player_Two, Player2_Points)) break time.sleep(5) ClearScreen() Rounds = Rounds + 1 Chips_Left = Max_Chips #------------------ This is the main game and it asks the players how many chips they want, and if they go over, they skip there a turn. ClearScreen() print("After some doing some intense caculations") #-------------------------------------------------- Response = random.randint(1,3) if Player1_Points > Player2_Points: if Response == 1: print("You nearly had them {}." .format(Player_Two)) elif Response == 2: print("I know it hurts, but you lost, womp womp.") else: print("{} You lost." .format(Player_Two)) elif Player2_Points < Player1_Points: if Response == 1: print("Oh well, maybe next time {}." .format(Player_One)) elif Response == 2: print("Welp maybe pay attention in math class {}." .format(Player_One)) else: print("{} coulden't beat {}." .format(Player_One, Player_Two)) else: print("Draw.") #-------------------------------------------------- This gives the responses for the players wether they won or lost.