File tree Expand file tree Collapse file tree 1 file changed +20
-12
lines changed Expand file tree Collapse file tree 1 file changed +20
-12
lines changed Original file line number Diff line number Diff line change 4
4
import random
5
5
#Simple function to clean all terminal and detects your OS
6
6
def clear_console ():
7
- match os .name :
8
- case "nt" :
9
- os .system ('clear' )
10
- case _ :
11
- os .system ('clear' )
7
+ if os .name == "nt" :
8
+ os .system ("cls" )
9
+ else :
10
+ os .system ("clear" )
12
11
#SECTION WHEN "TURNING DICE" AND GIVES A RESULT
13
12
def turning_and_result (predict :int ):
14
13
clear_console ()
@@ -33,6 +32,11 @@ def Game_Step1():
33
32
print (ASCII_ASSETS ["ready?" ])
34
33
try :
35
34
input_number = int (input ('Choise a number from 1 to 6\n \n > ' ))
35
+ if input_number > 6 or input_number < 0 :
36
+ clear_console ()
37
+ print (" ⚠ That's not a number... redirecting to menu" )
38
+ time .sleep (3 )
39
+ menu ()
36
40
turning_and_result (input_number )
37
41
except ValueError :
38
42
clear_console ()
@@ -46,13 +50,17 @@ def menu():
46
50
print (ASCII_ASSETS ["TextMenu" ])
47
51
print (ASCII_ASSETS ["Menu_Image" ])
48
52
input_menu = input ('\n Press Enter to play or type "exit" to leave the game\n \n > ' )
49
- match input_menu :
50
- case "exit" :
51
- exit ()
52
- case '' :
53
- Game_Step1 ()
54
-
53
+ if input_menu == "" :
54
+ Game_Step1 ()
55
+ elif input_menu == "exit" :
56
+ exit ()
55
57
56
58
57
59
if __name__ == '__main__' :
58
- menu ()
60
+ try :
61
+ menu ()
62
+ except KeyboardInterrupt :
63
+ clear_console ()
64
+ print (" ⚠ Leaving the game..." )
65
+ time .sleep (1 )
66
+ exit ()
You can’t perform that action at this time.
0 commit comments