#  Name :       21 Assesment
#  Purpose :    11DGT
#  Author:      Taylan Russell
#  Created :    19/03/2024
#  Copyright :  © Taylan Russell 19/03/2024

#input of players names includes spaces and nubers.

import time

print("Welcome, in this game you will start with 21 chips and every turn you will pick a number between 1-3, first person to zero, wins!!!. ")
print("GOOD LUCK!!!")
time.sleep(3)
def play_game():
    #input of players names includes spaces and numbers.
    player1 = input("Player 1, what is your name: ")
    player2 = input("Player 2, what is your name: ")

    #Asking for the number of rounds
    round_number = int(input("how many rounds would you like to play? "))

    #Initialize scores
    player1_score = 0
    player2_score = 0

    for round_num in range(1, round_number + 1):
        print(f"\nRound {round_num} begins!")

        #amount of chips taken away from each round
        chips = 21

        while chips > 0:
            # Player 1 turn
            print(f"\n{player1}'s turn. Chips remaining: {chips}")
            chips_taken = int(input("Pick how many chips to take (1-3): "))
            while chips_taken < 1 or chips_taken > 3:
                print("Wrong number of chips. Please pick 1, 2, or 3")
                chips_taken = int(input("Pick how many chips to take (1-3): "))
            chips -= chips_taken

            if chips <= 0:
                print(f"\n{player1} wins this round!")
                player1_score += 1
                break

            # Player 2 turn
            print(f"\n{player2}'s turn. Chips remaining: {chips}")
            chips_taken = int(input("Pick how many chips to take (1-3): "))
            while chips_taken < 1 or chips_taken > 3:
                print("Wrong number of chips. Please pick 1, 2, or 3.")
                chips_taken = int(input("Pick how many chips to take (1-3): "))
            chips -= chips_taken

            if chips <= 0:
                print(f"\n{player2} wins this round!")
                player2_score += 1
                break

    #final scores
    print("\nGame over!")
    print(f"Final scores:")
    print(f"{player1}: {player1_score}")
    print(f"{player2}: {player2_score}")

#Start the game
play_game()