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 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(): """Welcome user of game.""" print('Welcome to the Brain Games! ') cli.get_name()
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(): """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)