-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.py
108 lines (86 loc) · 2.18 KB
/
main.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
"""
This is the main module for my chess game.
"""
import random
import Canvas
import utils
import board
import Player
import globVar
import colors
import pathlib
from save import *
import sys
def main():
if len(sys.argv):
parse_args(sys.argv)
path = pathlib.Path("chess.save")
if path.exists():
Canvas.loadSave()
running = True
else:
running = Canvas.startScreen()
while(running):
running = state()
utils.delete_save()
def state():
playing = True
while playing:
if (globVar.playerCount % 2) == 0:
globVar.player = "W"
else:
globVar.player = "b"
Player.turn()
globVar.playerCount += 1
playing = not utils.checkWin()
if globVar.numPlayers > 0:
utils.clearSave()
write.writeSave()
return playing
def parse_args(args):
args.pop(0) # remove script arg
s = "".join(args)
globVar.show_all_menus = ("m" in s)
## GRAPHICS
if ("a" in s):
globVar.unicode = False
globVar.limited_unicode = False
if ("l" in s):
globVar.unicode = False
globVar.limited_unicode = True
if ("u" in s):
globVar.unicode = True
globVar.limited_unicode = False
if globVar.limited_unicode:
colors.limited_pieces()
# Game speed
globVar.slow_speed = not ("f" in s)
if ("s" in s):
globVar.slow_speed = True
# AI
if ("n" in s):
globVar.chill = False
globVar.aggressive = False
if ("c" in s):
globVar.chill = True
globVar.aggressive = False
if ("g" in s):
globVar.chill = False
globVar.aggressive = True
# GAME MODES
if ("0" in s):
globVar.numPlayers = 0
elif ("1" in s):
globVar.numPlayers = 1
elif ("2" in s):
globVar.numPlayers = 2
if ("i" in s):
globVar.simulation = True
globVar.numPlayers = 0
Canvas.simulateMenu()
exit()
if ("h" in s):
Canvas.help()
exit()
if __name__ == "__main__":
main()