/
game.py
51 lines (46 loc) · 1.04 KB
/
game.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
from objects import *
from scoring import *
def StartNew(n):
Game(n).new_game()
def StartFromFile():
if os.path.isfile("saved.p"):
f = open("saved.p", "rb")
g = pickle.load(f)
g.play_game()
f.close
else:
print("\n\nERROR: No Game File Found")
def ViewHiScores():
print("\n\n")
if os.path.isfile("scores.p"):
f = open("scores.p", "rb")
scorekeeper = pickle.load(f)
scorekeeper.disp_scores()
f.close
else:
print("ERROR: No Score File Found")
print("\n\n")
pause()
def pause():
input("Press any key to continue: ")
if __name__ == "__main__":
while 1:
f = open("info.txt", "r")
print(f.read())
f.close
command = input("N S V X: ")
if command.lower() not in "nsvx":
print("INVALID COMMAND PLEASE TRY AGAIN")
pause()
else:
if command.lower() == "n":
n = input("What size board? ")
if n in '1023456789':
StartNew(int(n))
else: print("Invalid number entered, please try again")
elif command.lower() == "s":
StartFromFile()
elif command.lower() == "v":
ViewHiScores()
else:
break