"""
-------------------------------------------------
   Project: Take-Away Game
  Standard: 91883 (AS1.7) v.1
    School: Tauranga Boys' College
    Author: Logan Baldwin
      Date: THE DATE YOU COMPLETED THE CODE
    Python: 3.5
-------------------------------------------------
"""
import random

reset_guesses = 0 
rounds = 3
user_score = 0
AI_score = 0
round_won = True
total_rounds = 3
max_tries = 10

#Intro---
print("Take-Away Game")

print("")

player = input("What is your name?")
print("Welcome to the game, do you have what it take? The aim of the game is too try and guess the number before 10 guesses, (between 1 and a 1000) it is best to 3.")


# Main game loop
while rounds <= total_rounds:
    print(f"\n---- Round {rounds} ---")
    number = random.randint(1, 1000)  # The number to guess
    round_won = False
    guesses_left = max_tries

    print(f"Guess the number between 1 and 1000. Or die in a hole... You have {guesses_left} tries")

    # Loop for 10 guesses
    while guesses_left > 0:
        guess = int(input(f"You have {guesses_left} guesses left. Trash can enter a guess or die: "))
        guesses_left -= 1

        if guess < number:
            print("Too low shitter Try again.")
        elif guess > number:
            print("Too high shitter Try again.")
        else:
            print("Nice one shit can, you actually got it")
            round_won = True
            break

    # Check if the player won the round
    if round_won:
        print(f"Well done, {player}! You guessed the number in {max_tries - guesses_left} tries.")
        user_score += 1  
    else:
        print(f"Sorry, {player}. The correct number was {number}. You lost this round.")
        AI_score += 1 

    rounds += 1

# Final score after 3 rounds
print("\n--- Game Over ---")
print(f"{player}'s Final Score: {user_score} | AI Score: {AI_score}")

if user_score > AI_score:
    print(f"Congratulations, {player}! You won the game!")
elif user_score < AI_score:
    print(f"Better luck next time, {player}. The AI won this time.")
else:
    print(f"It's a tie! Both {player} and AI have the same score.")