From 6fede49915f097af82af47f1534115c02100a69a Mon Sep 17 00:00:00 2001 From: manogames Date: Fri, 5 Apr 2024 22:12:21 -0600 Subject: [PATCH 1/4] Delete .idea directory --- .idea/.gitignore | 3 --- .idea/Python-Projects.iml | 12 --------- .idea/inspectionProfiles/Project_Default.xml | 26 ------------------- .../inspectionProfiles/profiles_settings.xml | 6 ----- .idea/misc.xml | 7 ----- .idea/modules.xml | 8 ------ .idea/vcs.xml | 6 ----- 7 files changed, 68 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/Python-Projects.iml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d33521..00000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/Python-Projects.iml b/.idea/Python-Projects.iml deleted file mode 100644 index 07abf202..00000000 --- a/.idea/Python-Projects.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index dc64fad4..00000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2da..00000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index db8786c0..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index c1b104bb..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddf..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 302f085fedbc31757cbbb89881be385754aa482a Mon Sep 17 00:00:00 2001 From: manogames Date: Fri, 5 Apr 2024 23:39:31 -0600 Subject: [PATCH 2/4] Adding dice game --- Dice_game/assets.py | 71 +++++++++++++++++++++++++++++++++++++++++++++ Dice_game/game.py | 58 ++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 Dice_game/assets.py create mode 100644 Dice_game/game.py diff --git a/Dice_game/assets.py b/Dice_game/assets.py new file mode 100644 index 00000000..6779f9e9 --- /dev/null +++ b/Dice_game/assets.py @@ -0,0 +1,71 @@ +ASCII_ASSETS = { #ALL ASCII ASSETS + 1 : """ +----- +| | +| o | +| | +----- + """, + 2 : """ +----- +|o | +| | +| o| +----- + """, + 3: """ +----- +|o | +| o | +| o| +----- + """, + 4: """ + +----- +|o o| +| | +|o o| +----- + + """, + 5: """ +----- +|o o| +| o | +|o o| +----- + """, + 6: """ +----- +|o o| +|o o| +|o o| +----- + """, + "Menu_Image" : """ + _______ + /\ \ + /()\ () \ +/ \_______\ +\ /() / + \()/ () / + \/_____()/ + """, + "TextMenu": """ + _____ _____ _____ ______ _____ __ __ ______ + | __ \_ _/ ____| ____| / ____| /\ | \/ | ____| + | | | || || | | |__ | | __ / \ | \ / | |__ + | | | || || | | __| | | |_ | / /\ \ | |\/| | __| + | |__| || || |____| |____ | |__| |/ ____ \| | | | |____ + |_____/_____\_____|______| \_____/_/ \_\_| |_|______| + """, + "ready?" : """ +┌─────────? +│ ● ● │ +│ ready? │ +│ ● ● │ +└─────────? + """ +} +print(ASCII_ASSETS["ready?"]) \ No newline at end of file diff --git a/Dice_game/game.py b/Dice_game/game.py new file mode 100644 index 00000000..1125e82b --- /dev/null +++ b/Dice_game/game.py @@ -0,0 +1,58 @@ +from assets import ASCII_ASSETS +import os +import time +import random +#Simple function to clean all terminal and detects your OS +def clear_console(): + match os.name: + case "nt": + os.system('clear') + case _ : + os.system('clear') +#SECTION WHEN "TURNING DICE" AND GIVES A RESULT +def turning_and_result(predict:int): + clear_console() + print(ASCII_ASSETS["Menu_Image"]) + print("\n\nTurning...") + result = random.randint(1,6) + time.sleep(2) + clear_console() + print(ASCII_ASSETS[result]) + print(result) + print("\nRESULT!!!") + if result == predict: + print('\n\nYOU WON!!!') + else: + print('\n\nYOU LOST... :(') + print("\n\n ⚠ Redirecting to menu...") + time.sleep(4) + menu() +#SECTION WHEN CLIENT CHOISE A NUMBER +def Game_Step1(): + clear_console() + print(ASCII_ASSETS["ready?"]) + try: + input_number = int(input('Choise a number from 1 to 6\n\n> ')) + turning_and_result(input_number) + except ValueError: + clear_console() + print(" ⚠ That's not a number... redirecting to menu") + time.sleep(3) + menu() + +#MENU SECTION +def menu(): + clear_console() + print(ASCII_ASSETS["TextMenu"]) + print(ASCII_ASSETS["Menu_Image"]) + input_menu = input('\nPress Enter to play or type "exit" to leave the game\n\n> ') + match input_menu: + case "exit": + exit() + case '' : + Game_Step1() + + + +if __name__ == '__main__': + menu() \ No newline at end of file From f70e324066a145b1bc9f4800177e20494d1604a7 Mon Sep 17 00:00:00 2001 From: manogames Date: Sat, 6 Apr 2024 12:44:34 -0600 Subject: [PATCH 3/4] Update assets.py --- Dice_game/assets.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Dice_game/assets.py b/Dice_game/assets.py index 6779f9e9..aee2dd3c 100644 --- a/Dice_game/assets.py +++ b/Dice_game/assets.py @@ -68,4 +68,3 @@ └─────────? """ } -print(ASCII_ASSETS["ready?"]) \ No newline at end of file From 8b2c97e7fa11199ed98aefbb021cca99219fe521 Mon Sep 17 00:00:00 2001 From: manogames Date: Sat, 6 Apr 2024 13:32:50 -0600 Subject: [PATCH 4/4] fixed bugs --- Dice_game/game.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Dice_game/game.py b/Dice_game/game.py index 1125e82b..007b2c1c 100644 --- a/Dice_game/game.py +++ b/Dice_game/game.py @@ -4,11 +4,10 @@ import random #Simple function to clean all terminal and detects your OS def clear_console(): - match os.name: - case "nt": - os.system('clear') - case _ : - os.system('clear') + if os.name == "nt": + os.system("cls") + else: + os.system("clear") #SECTION WHEN "TURNING DICE" AND GIVES A RESULT def turning_and_result(predict:int): clear_console() @@ -33,6 +32,11 @@ def Game_Step1(): print(ASCII_ASSETS["ready?"]) try: input_number = int(input('Choise a number from 1 to 6\n\n> ')) + if input_number > 6 or input_number < 0: + clear_console() + print(" ⚠ That's not a number... redirecting to menu") + time.sleep(3) + menu() turning_and_result(input_number) except ValueError: clear_console() @@ -46,13 +50,17 @@ def menu(): print(ASCII_ASSETS["TextMenu"]) print(ASCII_ASSETS["Menu_Image"]) input_menu = input('\nPress Enter to play or type "exit" to leave the game\n\n> ') - match input_menu: - case "exit": - exit() - case '' : - Game_Step1() - + if input_menu == "": + Game_Step1() + elif input_menu == "exit": + exit() if __name__ == '__main__': - menu() \ No newline at end of file + try: + menu() + except KeyboardInterrupt: + clear_console() + print(" ⚠ Leaving the game...") + time.sleep(1) + exit() \ No newline at end of file