Skip to content

Commit

Permalink
slight refactored to exclude game logic from run files
Browse files Browse the repository at this point in the history
Signed-off-by: hikarikumo <[email protected]>
  • Loading branch information
hikarikumo committed Dec 17, 2023
1 parent c6e2614 commit 9bd9bed
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 61 deletions.
13 changes: 13 additions & 0 deletions brain_games/calc_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import random
import prompt
from cli import greet_first, welcome_user


def calc_greet_first():
Expand Down Expand Up @@ -91,3 +92,15 @@ def calc_game_logic(name):
elif counter == 3:
print('Congratulations, ', name, '!', sep='')
counter += 1


def main():
"""Run brain-calc game."""
greet_first()
calc_greet_first()
name = welcome_user()
calc_game_logic(name)


if __name__ == '__main__':
main()
12 changes: 12 additions & 0 deletions brain_games/even_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import prompt
import random
import general_module
from cli import greet_first, welcome_user


def check_if_even(number):
Expand Down Expand Up @@ -55,3 +56,14 @@ def even_game_logic(name):
general_module.try_again(name)
break
counter += 1


def main():
"""Run brain-even game."""
greet_first()
name = welcome_user()
even_game_logic(name)


if __name__ == '__main__':
main()
18 changes: 18 additions & 0 deletions brain_games/gcd_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import random
import prompt
from cli import greet_first, welcome_user


def question_gcd():
Expand Down Expand Up @@ -72,3 +73,20 @@ def gcd_game(name):
print("Let's try again, ", name, '!', sep='')
return False
counter += 1


def main():
"""
Run brain-gcd game.
returns:
Correct answer on the screen with result and username.
"""
greet_first()
gcd_goal_message()
name = welcome_user()
gcd_game(name)


if __name__ == '__main__':
main()
13 changes: 13 additions & 0 deletions brain_games/prime_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import prompt
import random
from cli import greet_first, welcome_user


def question_prime():
Expand Down Expand Up @@ -65,3 +66,15 @@ def prime_game(name):
print("Let's try again, ", name, '!', sep='')
return False
counter += 1


def main():
"""Run brain-prime game."""
greet_first()
prime_goal()
name = welcome_user()
prime_game(name)


if __name__ == '__main__':
main()
18 changes: 18 additions & 0 deletions brain_games/progression_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import random
import prompt
from cli import greet_first, welcome_user


def progression_goal():
Expand Down Expand Up @@ -90,3 +91,20 @@ def progression_calc(random_step, random_initial):
progression.append(progression_member)
counter += 1
return progression


def main():
"""
Run brain-progression game.
Returns:
Return and verify the proper elemen inside of the ariphmetic progressio.
"""
greet_first()
progression_goal()
name = welcome_user()
progression_game(name)


if __name__ == '__main__':
main()
12 changes: 1 addition & 11 deletions brain_games/scripts/brain_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,7 @@
current_script_dir = os.path.dirname(__file__)
brain_games_path = os.path.join(current_script_dir, '..')
sys.path.append(brain_games_path)
from cli import greet_first, welcome_user
from calc_game import calc_greet_first, calc_game_logic



def main():
"""Run brain-calc game."""
greet_first()
calc_greet_first()
name = welcome_user()
calc_game_logic(name)
from calc_game import main


if __name__ == '__main__':
Expand Down
10 changes: 1 addition & 9 deletions brain_games/scripts/brain_even.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@
current_script_dir = os.path.dirname(__file__)
brain_games_path = os.path.join(current_script_dir, '..')
sys.path.append(brain_games_path)
from cli import greet_first, welcome_user
from even_game import even_game_logic


def main():
"""Run brain-even game."""
greet_first()
name = welcome_user()
even_game_logic(name)
from even_game import main


if __name__ == '__main__':
Expand Down
16 changes: 1 addition & 15 deletions brain_games/scripts/brain_gcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,7 @@
current_script_dir = os.path.dirname(__file__)
brain_games_path = os.path.join(current_script_dir, '..')
sys.path.append(brain_games_path)
from cli import greet_first, welcome_user
from gcd_game import gcd_game, gcd_goal_message


def main():
"""
Run brain-gcd game.
returns:
Correct answer on the screen with result and username.
"""
greet_first()
gcd_goal_message()
name = welcome_user()
gcd_game(name)
from gcd_game import main


if __name__ == '__main__':
Expand Down
11 changes: 1 addition & 10 deletions brain_games/scripts/brain_prime.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@
current_script_dir = os.path.dirname(__file__)
brain_games_path = os.path.join(current_script_dir, '..')
sys.path.append(brain_games_path)
from cli import greet_first, welcome_user
from prime_game import prime_game, prime_goal


def main():
"""Run brain-prime game."""
greet_first()
prime_goal()
name = welcome_user()
prime_game(name)
from prime_game import main


if __name__ == '__main__':
Expand Down
16 changes: 1 addition & 15 deletions brain_games/scripts/brain_progression.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,7 @@
current_script_dir = os.path.dirname(__file__)
brain_games_path = os.path.join(current_script_dir, '..')
sys.path.append(brain_games_path)
from cli import greet_first, welcome_user
from progression_game import progression_game, progression_goal


def main():
"""
Run brain-progression game.
Returns:
Return and verify the proper elemen inside of the ariphmetic progressio.
"""
greet_first()
progression_goal()
name = welcome_user()
progression_game(name)
from progression_game import main


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hikarikumo_brain_games"
version = "0.1.11"
version = "0.1.12"
description = ""
authors = ["hikarikumo"]

Expand Down

0 comments on commit 9bd9bed

Please sign in to comment.