-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainGame.py
49 lines (34 loc) · 1.28 KB
/
MainGame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Utils
from Live import load_game
from GuessGame import play as gg
from MemoryGame import play as mg
from CurrencyRouletteGame import play as cr
scores_file = Utils.scores_file_name # path to scores.txt
# reset the scores.txt file
def rest_scores():
with open(scores_file,'w', encoding='utf-8') as writer:
writer.write("0")
rest_scores()
game_num, difficulty = load_game()
def start_game(game_num_in, difficulty_in):
if game_num_in == 1:
mg(difficulty_in)
elif game_num_in == 2:
gg(difficulty_in)
elif game_num_in == 3:
cr(difficulty_in)
ask_if_replay(game_num_in, difficulty_in)
# ask if want to replay the game or go back.
def ask_if_replay(game_num_in, difficulty_in):
retry_selection = input("Would you like to retry?\nPress 'Y' to retry or 'N' to go back or 'E' to exit: ").lower()
if retry_selection == 'y':
start_game(game_num_in, difficulty_in)
elif retry_selection == 'n':
local_game_num, local_difficulty = load_game()
start_game(local_game_num, local_difficulty)
elif retry_selection == 'e':
print("Goodbye.")
exit()
else:
print("Invalid selection.", ask_if_replay(difficulty))
start_game(game_num, difficulty)