-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain3499.py
133 lines (109 loc) · 3.82 KB
/
main3499.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import classes as m
import json
from os.path import exists
game_mode = "Max_letters"
def guidelines():
"""
>Κλάσεις: Player, Human, Computer, Game, SakClass
>Η Human και η Computer κληρονομούν την κλάση Player
>Οι μέθοδοι Human και Computer μέσω του constructor τους καλούν την init
της μητρικής τους κλάσης Player
>Στο αρχείο classes.py, έγινε χρήση @staticmethod Decorator στις μεθόδους word_val,
word_in_dict, word_size και word_val2
>Οι λέξεις της γλώσσας στην αρχή του παιχνιδιού φορτώνονται σε ενα λεξικό
το οποίο χρησιμοποιείται για όποια αναζήτηση γίνεται στη συνέχεια
>Για τον ηλ. Υπολογιστή υλοποιήθηκαν οι: min_letters, max_letters, smart.
Ως default είναι ορισμένη η max_letters.
"""
return
def menu():
print("[1] Score")
print("[2] Settings")
print("[3] Game")
print("[q] Quit")
def settings():
print("Settings")
print("[1] Min_letters")
print("[2] Max_letters")
print("[3] Smart")
def initialize_score_file():
if exists('score_file.json'):
data = {"games": []}
with open("score_file.json", "r+") as file:
one_char = file.read(1)
if len(one_char) > 0:
return
else:
json.dump(data, file)
else:
data = {"games": []}
with open("score_file.json", "a") as file:
json.dump(data, file)
def option1():
try:
with open("score_file.json", "r") as read_file:
data = json.load(read_file)
cnt = 0
for i in data["games"]:
cnt += 1
rounds = i["rounds"]
name = i["name"]
score_h = i["score_h"]
score_c = i["score_c"]
print("--------------------------------------------")
print("Game", cnt)
print("Played by: ", name)
print("Final score in ", rounds, "rounds:")
print(name, ": ", score_h, " vs computer: ", score_c)
print("--------------------------------------------")
if cnt == 0:
print("There isn't any history of games!")
except:
print("There isn't any history of games!")
def option2():
settings()
global game_mode
print("Current mode is: ", game_mode)
a = input()
while a != "1" and a != "2" and a != "3":
print("Select a valid game mode")
a = input()
if a == "1":
game_mode = "Min_letters"
elif a == "2":
game_mode = "Max_letters"
elif a == "3":
game_mode = "Smart"
print("Mode set to: ", game_mode)
def option3():
new_game = m.Game(game_mode)
print("""
========================================
Welcome to
.---..---..---..---..---..---..---..---.
| S || C || R || A || B || B || L || E |
'---''---''---''---''---''---''---''---'
========================================
"""
)
menu()
initialize_score_file()
option = input("Enter your option: ")
while option != "q":
if option == "1":
option1()
if option == "2":
option2()
if option == "3":
option3()
menu()
option = input("Enter your option: ")
print("""
========================================
Thanks For Playing
.---..---..---..---..---..---..---..---.
| _ || _ || B || Y || E || ! || _ || _ |
'---''---''---''---''---''---''---''---'
========================================
"""
)