Проблема в том, что он не блокирует игрока, когда я меняю игрока
Редактировать: я редактировал код.
Эта функция создает корпус доски, это только половина кодапотому что это одинаково для всех фигур:
def cree_case(ligne, colonne):
case = Canvas(frame, width=100, height = 100,highlightthickness=1,highlightbackground="black")
def click(event):
joue(ligne,colonne)
def click2(event):
label_joueur["text"]="cchzohdc"
joue2(ligne,colonne,l,c,joue)
label_joueur["text"]=("choissisez une piece")
case.bind('<Button-1>',click)
case.bind('<Button-3>',click2)
x, y = 55, 55
if board[ligne][colonne][0]== "F" and board[ligne][colonne][2]=="W":
case.create_image(x,y,image=fou_blanc)
elif board[ligne][colonne][0]== "F" and board[ligne][colonne][2]=="N":
case.create_image(x,y,image=fou_noir)
Вот три функции, которые я использую, чтобы сыграть и заставить двигаться, меняя игрока:
def joue(ligne, colonne):
global l,c
print( ligne, colonne)
l,c= ligne,colonne
def player(): # cette fonction permet de jouer et changer de joueur
if joueur == "joueur1":
return "joueur2"
elif joueur=="joueur2":
return "joueur1"
def joue2(ligne,colonne,l,c,joue,):
player()
m=ligne
n=colonne
if not est_valide(joueur,l,c,m,n) or not pion_valide(l,c,m,n,joueur) or not dame_valide(l,c,m,n,joueur) or not fou_valide(l,c,m,n) or not roi_valide(l,c,m,n) or not cavalier_valide(l,c,m,n) or not tour_valide(l,c,m,n,joueur) or not pion_valide(l,c,m,n,joueur) :
print("mauvais")
faux=Toplevel(Fenetre, height= 100, width = 100)
case1 = Canvas(faux, width=100, height 100,highlightthickness=1,highlightbackground="black")
v= 50
w= 50
case1.create_image(v,w,image=stop)
case1.grid()
faux.mainloop()
elif est_victorieux(joueur):
board[m][n]=board[l][c]
board[l][c]="___"
frame.destroy()
label_joueur["text"]=("Echec et mat")
else:
board[m][n]=board[l][c]
board[l][c]="___"
if est_victorieux(joueur):
frame.destroy()
label_joueur["text"]=("Echec et mat")
else:
affiche_grille()
joueur="joueur1"
affiche_grille()