def start_game(game): cli.welcome() print(game.RULE) print() name = cli.take_name() for _ in range(NUMBER_OF_ROUND): question, correct_answer = game.creating_quiestion_and_answer() print("Question: " + question) answer = input("Your answer: ") if answer != correct_answer: print("'{}' is wrong answer ;(. Correct answer was '{}'." "Let's try again, {}!".format(answer, correct_answer, name)) break print('Correct!') else: print("Congratulations, {}!".format(name))
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))
def start_game(game, number_of_rounds=3): welcome() print(game.RULES) print() name = welcome_user() count = 0 while count < number_of_rounds: value, right_answer = game.play_round() print(f'Question: {value}') answer = prompt.string('Your answer: ') if answer != right_answer: print( f"'{fg.bold(fg.red(answer))}' is wrong answer ;(. Correct answer was '{fg.bold(fg.green(right_answer))}'." ) # noqa E501 try_again(name) break print(fg.green('Correct!')) count += 1 else: congratulate_user(name)
def run(game): """ This is a game engine for Brain Games. Parameteres: game (module): module with implementation of the game which user chosed """ cli.welcome() # print welcome to brain games game.show_description() # print game description imported from game file name = cli.get_name() # request user name wins = 0 # counter for wins while wins < 3: question, answer = game.get_question() # generate question cli.ask(question) # print the question for the user guess = cli.get_guess() # receive guess from the user if guess != answer: cli.inform_about_wrong_answer(guess, answer, name) # show message when the answer is wrong return cli.inform_about_correct_answer() # show message when the answer is correct wins += 1 cli.congratulate(name) # print congratulations for user
def main(): cli.welcome() cli.get_name()
def main(): """Brain game for odd even main logic.""" cli.welcome() name = cli.get_name() print('Answer "yes" if the number is even, otherwise answer "no".') game_logic.logic('even', name)
def main(): """Brain game for common divider.""" cli.welcome() name = cli.get_name() print('Find the greatest common divisor of given numbers.') game_logic.logic('gcd', name)
def main(): """Brain game for missing piece of progression.""" cli.welcome() name = cli.get_name() print('What number is missing in the progression?') game_logic.logic('progr', name)
def main(): welcome() welcome_user()
def main(): """Brain game for calc main logic.""" cli.welcome() name = cli.get_name() print('What is the result of the expression?') game_logic.logic('calc', name)
def main(): cli.welcome() cli.run()