def run(game, rounds=3):
    cli.greet()
    name = cli.welcome_user(game.RULES)
    counter = 0
    while counter < rounds:
        question, true_answer = game.get_game()
        user_answer = cli.request_answer(question)
        if user_answer != true_answer:
            cli.show_wrong_answer_message(user_answer, true_answer, name)
            break
        cli.show_right_answer_message()
        counter += 1
    else:
        cli.show_win_game_message(name)
Beispiel #2
0
def run(game):
    cli.greet(game.GAME_DESCRIPTION)
    name = cli.ask_name()
    player_won = True
    counter = 0
    while counter < 3:
        (question, correct_answer) = game.create_question()
        answer = cli.ask_question(question)
        if answer == correct_answer:
            print("Correct!")
            counter = counter + 1
        else:
            print(WRONG_ANSWER_MESSAGE.format(answer, correct_answer))
            player_won = False
            break
    message = WIN_MESSAGE if player_won else LOSE_MESSAGE
    print(message.format(name))
Beispiel #3
0
def play(game):
    greet()

    print_text(game.RULES)

    user_name = get_user_name()

    answer_count = 0
    while answer_count < ROUNDS_COUNT:
        question, answer = game.get_question()
        print_question(question)
        user_answer = get_user_answer()
        if user_answer != answer:
            print_fail_answer(user_answer, answer, user_name)
            return
        print_text(RIGHT_ANSWER_TEXT)
        answer_count += 1
    congratulate(user_name)
Beispiel #4
0
def run(game):
    cli.welcome()
    print(game.DESCRIPTION, '\n')
    name = cli.get_name()
    cli.greet(name)
    print()
    for _ in range(3):
        q, a = game.generate_qa_pair()
        print('Question: {}'.format(q))
        answer = cli.get_answer()
        if (answer == a):
            print('Correct!')
        else:
            print("'{}' is wrong answer ;(. Correct answer was '{}'".format(
                answer, a))
            print("Let's try again, {}!".format(name))
            break
    else:
        print('Congratulations, {}!'.format(name))
Beispiel #5
0
def run(game, round_of_game=3):
    greet()
    print(game.DESCRIPTION)
    print()
    name = welcome_user()
    print()

    counter = 0

    while counter != round_of_game:
        question, correct_answer = game.new_round()
        print("Question: {}".format(question))
        user_answer = prompt.string("Your answer: ")
        if user_answer != correct_answer:
            print("'{}' is wrong answer ;(. Correct answer was '{}'".format(
                user_answer, correct_answer))
            print("Let's try again!")
            break
        counter += 1
        print("Correct!")
    else:
        print("Congratulations, {}".format(name))
Beispiel #6
0
def run(game):
    print('Welcome to the Brain Games!')
    print(game.DESCRIPTION)
    name = cli.greet()
    counter = 1
    while counter <= 3:
        question, right_answer = game.make_round()
        print(cli.QUESTION.format(question))
        answer = prompt.string('Your answer: ')
        if answer != right_answer:
            print(cli.WRONG_ANSWER.format(answer, right_answer))
            print(cli.TRY_AGAIN.format(name))
            break
        print('Correct!')
        counter += 1
    else:
        print(cli.CORRECT_ANSWER.format(name))
Beispiel #7
0
def main():
    greet()
    welcome_user()
def main():
    cli.greet()
    cli.welcome_user()