diff --git a/Makefile b/Makefile index b3a4a6b..56b27d3 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,9 @@ install: brain-games: uv run brain-games +brain-calc: + uv run brain-calc + build: uv build diff --git a/brain_games/__pycache__/cli.cpython-313.pyc b/brain_games/__pycache__/cli.cpython-313.pyc index b19eca0..9d58345 100644 Binary files a/brain_games/__pycache__/cli.cpython-313.pyc and b/brain_games/__pycache__/cli.cpython-313.pyc differ diff --git a/brain_games/__pycache__/wrong_answer_output.cpython-313.pyc b/brain_games/__pycache__/wrong_answer_output.cpython-313.pyc index acb14be..34cec55 100644 Binary files a/brain_games/__pycache__/wrong_answer_output.cpython-313.pyc and b/brain_games/__pycache__/wrong_answer_output.cpython-313.pyc differ diff --git a/brain_games/cli.py b/brain_games/cli.py index d63416f..dda9181 100644 --- a/brain_games/cli.py +++ b/brain_games/cli.py @@ -4,5 +4,6 @@ def welcome_user(): print('Welcome to the Brain Games!') name = prompt.string('May I have your name? ') - print(f'Hello, {name}!\n') + print(f'Hello, {name}!') + return name \ No newline at end of file diff --git a/brain_games/scripts/games/__init_.py b/brain_games/scripts/games/__init_.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/brain_games/scripts/games/__init_.py @@ -0,0 +1 @@ + diff --git a/brain_games/scripts/games/__pycache__/brain_calc.cpython-313.pyc b/brain_games/scripts/games/__pycache__/brain_calc.cpython-313.pyc index a277652..c0f1e88 100644 Binary files a/brain_games/scripts/games/__pycache__/brain_calc.cpython-313.pyc and b/brain_games/scripts/games/__pycache__/brain_calc.cpython-313.pyc differ diff --git a/brain_games/scripts/games/__pycache__/brain_even.cpython-313.pyc b/brain_games/scripts/games/__pycache__/brain_even.cpython-313.pyc index 3abb443..4363030 100644 Binary files a/brain_games/scripts/games/__pycache__/brain_even.cpython-313.pyc and b/brain_games/scripts/games/__pycache__/brain_even.cpython-313.pyc differ diff --git a/brain_games/scripts/games/__pycache__/brain_games.cpython-313.pyc b/brain_games/scripts/games/__pycache__/brain_games.cpython-313.pyc index fcc5829..ac76e78 100644 Binary files a/brain_games/scripts/games/__pycache__/brain_games.cpython-313.pyc and b/brain_games/scripts/games/__pycache__/brain_games.cpython-313.pyc differ diff --git a/brain_games/scripts/games/__pycache__/brain_gcd.cpython-313.pyc b/brain_games/scripts/games/__pycache__/brain_gcd.cpython-313.pyc index e276cae..563fe04 100644 Binary files a/brain_games/scripts/games/__pycache__/brain_gcd.cpython-313.pyc and b/brain_games/scripts/games/__pycache__/brain_gcd.cpython-313.pyc differ diff --git a/brain_games/scripts/games/__pycache__/brain_prime.cpython-313.pyc b/brain_games/scripts/games/__pycache__/brain_prime.cpython-313.pyc index a4ea32d..a2b3e36 100644 Binary files a/brain_games/scripts/games/__pycache__/brain_prime.cpython-313.pyc and b/brain_games/scripts/games/__pycache__/brain_prime.cpython-313.pyc differ diff --git a/brain_games/scripts/games/__pycache__/brain_progression.cpython-313.pyc b/brain_games/scripts/games/__pycache__/brain_progression.cpython-313.pyc index bff75de..c37d3c1 100644 Binary files a/brain_games/scripts/games/__pycache__/brain_progression.cpython-313.pyc and b/brain_games/scripts/games/__pycache__/brain_progression.cpython-313.pyc differ diff --git a/brain_games/scripts/games/brain_calc.py b/brain_games/scripts/games/brain_calc.py index 416ce7e..9d90614 100644 --- a/brain_games/scripts/games/brain_calc.py +++ b/brain_games/scripts/games/brain_calc.py @@ -1,6 +1,5 @@ import operator from random import choice, randint -from time import sleep from prompt import string @@ -16,9 +15,7 @@ def calc_game(name): "*": operator.mul, } - sleep(1) print('What is the result of the expression?') - sleep(1) correct_guesses = 0 @@ -33,12 +30,9 @@ def calc_game(name): if answer != correct_answer: wrong_answer_output(answer, correct_answer, name) - sleep(2) - - continue + return print('Correct!\n') - sleep(1) correct_guesses += 1 diff --git a/brain_games/scripts/games/brain_even.py b/brain_games/scripts/games/brain_even.py index 537f5dc..ed0a702 100644 --- a/brain_games/scripts/games/brain_even.py +++ b/brain_games/scripts/games/brain_even.py @@ -1,5 +1,4 @@ from random import randint -from time import sleep from prompt import string @@ -8,10 +7,8 @@ def is_even_game(name): - sleep(1) - print('Answer "yes" if the number is even, otherwise answer "no".\n') - sleep(1) - + print('Answer "yes" if the number is even, otherwise answer "no".') + correct_guesses = 0 while correct_guesses < 3: @@ -23,18 +20,13 @@ def is_even_game(name): if answer != correct_answer: wrong_answer_output(answer, correct_answer, name) - sleep(2) - - correct_guesses = 0 - - continue + return - print('Correct!\n') - sleep(1) + print('Correct!') correct_guesses += 1 - print(f'Congratulations, {name}!\n') + print(f'Congratulations, {name}!') return diff --git a/brain_games/scripts/games/brain_games.py b/brain_games/scripts/games/brain_games.py index e07a689..7cef6dc 100644 --- a/brain_games/scripts/games/brain_games.py +++ b/brain_games/scripts/games/brain_games.py @@ -1,19 +1,8 @@ from brain_games.cli import welcome_user -from brain_games.scripts.games.brain_calc import calc_game -from brain_games.scripts.games.brain_even import is_even_game -from brain_games.scripts.games.brain_gcd import gcd_game -from brain_games.scripts.games.brain_progression import progression_game -from brain_games.scripts.games.brain_prime import is_prime_game def main(): - name = welcome_user() - is_even_game(name) - calc_game(name) - gcd_game(name) - progression_game(name) - is_prime_game(name) - + welcome_user() if __name__ == "__main__": diff --git a/brain_games/scripts/games/brain_gcd.py b/brain_games/scripts/games/brain_gcd.py index 3d88436..b4db46f 100644 --- a/brain_games/scripts/games/brain_gcd.py +++ b/brain_games/scripts/games/brain_gcd.py @@ -1,5 +1,4 @@ from random import randint -from time import sleep from prompt import string @@ -16,9 +15,7 @@ def get_gcd(a, b): def gcd_game(name): - sleep(1) print('Find the greatest common divisor of given numbers.\n') - sleep(1) correct_guesses = 0 @@ -37,12 +34,9 @@ def gcd_game(name): if answer != correct_answer: wrong_answer_output(answer, correct_answer, name) - sleep(2) - - continue + return print('Correct!\n') - sleep(1) correct_guesses += 1 diff --git a/brain_games/scripts/games/brain_prime.py b/brain_games/scripts/games/brain_prime.py index b8aecd7..a116479 100644 --- a/brain_games/scripts/games/brain_prime.py +++ b/brain_games/scripts/games/brain_prime.py @@ -1,5 +1,4 @@ from random import choice, randint -from time import sleep from prompt import string @@ -28,9 +27,7 @@ def prime_generator(num): def is_prime_game(name): - sleep(1) print('Answer "yes" if given number is prime. Otherwise answer "no".\n') - sleep(1) correct_guesses = 0 @@ -46,12 +43,9 @@ def is_prime_game(name): if answer != correct_answer: wrong_answer_output(answer, correct_answer, name) - sleep(2) - - continue + return print('Correct!\n') - sleep(1) correct_guesses += 1 diff --git a/brain_games/scripts/games/brain_progression.py b/brain_games/scripts/games/brain_progression.py index b74a49e..6cbd7bc 100644 --- a/brain_games/scripts/games/brain_progression.py +++ b/brain_games/scripts/games/brain_progression.py @@ -1,5 +1,4 @@ from random import randint -from time import sleep from prompt import string @@ -8,9 +7,7 @@ def progression_game(name): - sleep(1) print('What number is missing in the progression?\n') - sleep(1) correct_guesses = 0 @@ -29,12 +26,9 @@ def progression_game(name): if answer != correct_answer: wrong_answer_output(answer, correct_answer, name) - sleep(2) - - continue + return print('Correct!\n') - sleep(1) correct_guesses += 1 diff --git a/brain_games/wrong_answer_output.py b/brain_games/wrong_answer_output.py index 7a3db15..561f8f6 100644 --- a/brain_games/wrong_answer_output.py +++ b/brain_games/wrong_answer_output.py @@ -4,7 +4,7 @@ def wrong_answer_output(answer, correct_answer, name): print( f"'{answer}' is wrong answer ;(. " f"Correct answer was '{correct_answer}'.\n" - f"Let's try again, {name}!\n\n\n" + f"Let's try again, {name}!\n" ) return \ No newline at end of file