diff --git a/brain_games/games/engine.py b/brain_games/engine.py similarity index 75% rename from brain_games/games/engine.py rename to brain_games/engine.py index 1119d42..4e25257 100644 --- a/brain_games/games/engine.py +++ b/brain_games/engine.py @@ -1,13 +1,14 @@ from brain_games.const import ENTER_NAME, GREETING_MESSAGE, ROUNDS_NUMBERS -def play_game(game_round, game_rules: str): +def play_game(get_question_and_answer, game_rules: str): """ The logic of the game, which repeats the questions until the user answers correctly several times in a row Args: - game_round (Callable): A function that describes one round of the game. + get_question_and_answer (Callable): A function that describes one round + of the game. game_rules (str): The rules of the game that will be displayed before the start """ @@ -17,7 +18,7 @@ def play_game(game_round, game_rules: str): print(game_rules) for _ in range(ROUNDS_NUMBERS): - question, correct_answer = game_round() + question, correct_answer = get_question_and_answer() print(f"Question: {question}") answer = input("Your answer: ").strip().lower() @@ -27,8 +28,7 @@ def play_game(game_round, game_rules: str): print( f'"{answer}" is wrong answer ;(. ' f'Correct answer was "{correct_answer}".' - ) - print(f"Let's try again, {username}!") + f'Let\'s try again, {username}!') return print(f"Congratulations, {username}!") diff --git a/brain_games/games/__pycache__/engine.cpython-310.pyc b/brain_games/games/__pycache__/engine.cpython-310.pyc deleted file mode 100644 index 5de5ea9..0000000 Binary files a/brain_games/games/__pycache__/engine.cpython-310.pyc and /dev/null differ diff --git a/brain_games/games/calc.py b/brain_games/games/calc.py index 8b70f59..ac6eae2 100644 --- a/brain_games/games/calc.py +++ b/brain_games/games/calc.py @@ -1,7 +1,7 @@ import random from brain_games.const import CALC_RULES -from brain_games.games.engine import play_game +from brain_games.engine import play_game from brain_games.utils import get_random_number diff --git a/brain_games/games/even.py b/brain_games/games/even.py index e83e590..667ee1f 100644 --- a/brain_games/games/even.py +++ b/brain_games/games/even.py @@ -1,5 +1,5 @@ from brain_games.const import EVEN_RULES -from brain_games.games.engine import play_game +from brain_games.engine import play_game from brain_games.utils import get_random_number diff --git a/brain_games/games/gcd.py b/brain_games/games/gcd.py index 3d6a8c2..686274d 100644 --- a/brain_games/games/gcd.py +++ b/brain_games/games/gcd.py @@ -1,7 +1,7 @@ import math from brain_games.const import GCD_RULES -from brain_games.games.engine import play_game +from brain_games.engine import play_game from brain_games.utils import get_random_number diff --git a/brain_games/games/prime.py b/brain_games/games/prime.py index 40ea769..ff59ef6 100644 --- a/brain_games/games/prime.py +++ b/brain_games/games/prime.py @@ -1,5 +1,5 @@ from brain_games.const import PRIME_RULES -from brain_games.games.engine import play_game +from brain_games.engine import play_game from brain_games.utils import get_random_number diff --git a/brain_games/games/progression.py b/brain_games/games/progression.py index d2ebf46..5de33df 100644 --- a/brain_games/games/progression.py +++ b/brain_games/games/progression.py @@ -1,5 +1,5 @@ from brain_games.const import PROGRESSION_RULES -from brain_games.games.engine import play_game +from brain_games.engine import play_game from brain_games.utils import get_random_number