"""
=================================
Games Computer Play (Spring 2026)

examples of very simple guessing games

"""


from random import randrange


def worst_guessing_game():
    print('Warning: This is a really bad game!')
    print()
    guess = input('Now it is time to guess the magic word: ')
    print()
    print('... wrong! I told you this game was bad.')


def bad_guessing_game():
    print('''
Warning: This is not a good game.
You may not want to play it more than once or twice.
Or ever.
    ''')
    guess = input('guess the magic word: ')
    if guess == 'bad':
        print('Amazing! You got it!')
    else:
        print('Wrong!')


def bad_not_awful():
    guess = input('guess the magic word: ')
    if guess == 'bad' or guess == 'awful':
        print('Amazing! You got it!')
    else:
        print('Wrong!')


def add_one():
    n = read_int('enter a number: ')
    m = n + 1
    print(f'one more than the number you entered is: {m}')


def simple_guesser_1():
    secret = randrange(1, 5)
    guess = read_int('guess a number between 1 and 4: ')
    if guess == secret:
        print('You are a magician!')
    else:
        print('Go back to mind-reading school.')


# Read Evaluate Print Loop (REPL)

def simple_guesser():
    secret = randrange(1, 10)
    while True:
        guess = read_int('guess a number between 1 and 9: ')
        if guess == secret:
            print('You are a magician!')
            break
        else:
            print('Try again.')


# ===========================================================================
# there be dragons below


def read_int(prompt):
    text = input(prompt)
    try:
        return int(text)
    except ValueError:
        print(f'"{text}" is not an integer!')
        return None
