-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverif.py
148 lines (125 loc) · 3.9 KB
/
verif.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import os
from os import system, name
from time import sleep
from var import *
from verifpiece import *
from time import sleep
from verifmove import *
#from chess import *
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
def platePrint(plate):
clear()
# for i in range(8):
# print("|", 8 - i, "||", end=" ")
# for v in range(8):
# print(plate[i][v], end=" | ")
# print("")
# if not i == 7:
# print("--------------------------------------")
# print("--------------------------------------")
#print("| 0 || a | b | c | d | e | f | g | h |")
def PlateUpdate(chesspi, plate, alpha):
holdPlate = []
newPlate = []
holdPlate = list(plate[8 - int(chesspi[0][1])])
holdPlate[chesspi[0][0]] = "#"
newPlate = list(plate[8 - int(chesspi[1][1])])
newPlate[chesspi[1][0]] = chesspi[2]
plate[8 - int(chesspi[0][1])] = holdPlate
plate[8 - int(chesspi[1][1])] = newPlate
platePrint(plate)
return False
def getMove(turns):
print("ex: a1,a3,T: move tower a1 to a3")
if not error("get") == 0:
print("Error : ", allError)
print(turns)
def verif(chesspi, piece, pieceAdv, turns):
chesspi.append(plate[-int(chesspi[0][1])][chesspi[0][0]])
if not chesspi[2] in piece:
if chesspi[2] in pieceAdv:
error('pieceIsNotYour')
else:
error('pieceNotExist')
if not plate[8 - (int(chesspi[0][1]))][chesspi[0][0]] in piece:
error('pieceIsNotFind',)
if not 1 <= int(chesspi[1][1]) <= 8 and 1 <= (chesspi[1][0]) <= 8:
error('localisationNotInPlate')
if error("get") == 0:
pieceMove(chesspi, turns)
def error(errors):
if errors == "get":
return len(allError)
elif errors == "clear":
allError.clear()
else:
print(errors)
allError.append(errors)
def pieceMove(chesspi, turns):
y = int(chesspi[0][1])
x = chesspi[0][0]
ny = int(chesspi[1][1])
nx = chesspi[1][0]
zy = ny - y
zx = nx - x
piMo = chesspi[2]
try:
if piMo == "r"or piMo == "R":
if turns == "Black":
piece = pieceN
elif turns == "White":
piece = pieceB
Roi(y, x, ny, nx, zy, zx, piece, plate)
except IndexError:
error('moveIsImpossible')
try:
if piMo == "p"or piMo == "P":
Pion(turns, y, x, ny, nx, plate, pieceN, pieceB)
except IndexError:
error("moveIsImpossible")
try:
if piMo == "d"or piMo == "D":
Dame(y, x, ny, nx, zy, zx)
except IndexError:
error('moveIsImpossible')
try:
if piMo == "f"or piMo == "F":
Fou(y, x, ny, nx, zy, zx)
except IndexError:
error('moveIsImpossible')
try:
if piMo == "c"or piMo == "C":
if turns == "Black":
piece = pieceN
elif turns == "White":
piece = pieceB
Cavalier(y, x, ny, nx, plate, piece)
except IndexError:
error('moveIsImpossible')
try:
if piMo == "t"or piMo == "T":
Tour(y, x, ny, nx, zy, zx)
except IndexError:
error('moveIsImpossible')
if error("get") == 0:
moveobs(piMo, zx, zy, x, y, nx, ny, plate, pieceB, pieceN, outEquation, chesspi, turns)
def moveobs(piMo, zx, zy, x, y, nx, ny, plate, pieceB, pieceN, outEquation, chesspi, turns):
erreur = True
if turns == "Black":
piece = pieceN
pieceAdv = pieceB
elif turns == "White":
piece = pieceB
pieceAdv = pieceN
if piMo == "D" or piMo == "d":
erreur = DameMoveVerif(zx, zy, x, y, nx, ny, plate, piece, pieceAdv, outEquation)
if piMo == "T" or piMo == "t":
erreur = TourMoveVerif(zx, zy, x, y, nx, ny, plate, piece, pieceAdv, outEquation)
if piMo == "F" or piMo == "f":
erreur = FouMoveVerif(zx, zy, x, y, nx, ny, plate, piece, pieceAdv)
print(erreur)
if erreur == False:
error('CantMove(obstacle)')
if error("get") == 0:
PlateUpdate(chesspi, plate, alpha)