[Echecs] Ajout de messages d'erreur
This commit is contained in:
parent
f71bf87a1f
commit
35afd29340
|
@ -1,20 +1,17 @@
|
||||||
CASES_COTE = 8
|
CASES_COTE = 8
|
||||||
|
|
||||||
MVT_INCONNU = -42
|
MVT_INCONNU = 'Cause inconnu'
|
||||||
MVT_OK = 1
|
MVT_OK = 'Valide'
|
||||||
MVT_ROQUE = 2
|
MVT_ROQUE = 'Roque'
|
||||||
MVT_SELECTION = -1
|
MVT_SELECTION = 'Mauvais tour'
|
||||||
MVT_SUR_PLACE = -2
|
MVT_SUR_PLACE = 'Immobile'
|
||||||
MVT_SAUT_AMI = -3
|
MVT_SAUT_AMI = 'Saut ami'
|
||||||
MVT_PION_INC = -4
|
MVT_PION_INC = 'Pion inconnu'
|
||||||
MVT_N_AUTORISE = -5
|
MVT_N_AUTORISE = 'Non-autorisé'
|
||||||
MVT_OBSTRUCTION = -501
|
MVT_OBSTRUCTION = 'Pion en chemin'
|
||||||
|
|
||||||
class LogiqueEchecs:
|
class LogiqueEchecs:
|
||||||
|
|
||||||
# grille = None
|
|
||||||
# joueur = True
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.grille = []
|
self.grille = []
|
||||||
self.cGrille()
|
self.cGrille()
|
||||||
|
@ -75,14 +72,14 @@ class LogiqueEchecs:
|
||||||
if x1 == x2 and self.grille[x2][y2] <= 0: # Avance
|
if x1 == x2 and self.grille[x2][y2] <= 0: # Avance
|
||||||
if self.joueur:
|
if self.joueur:
|
||||||
if y2 == y1 - 1:
|
if y2 == y1 - 1:
|
||||||
return 1
|
return MVT_OK
|
||||||
elif y1 == 6 and y2 == 4 and self.grille[x1][5] == 0:
|
elif y1 == 6 and y2 == 4 and self.grille[x1][5] == 0:
|
||||||
return MVT_OK
|
return MVT_OK
|
||||||
else:
|
else:
|
||||||
return MVT_N_AUTORISE
|
return MVT_N_AUTORISE
|
||||||
else:
|
else:
|
||||||
if y2 == y1 + 1:
|
if y2 == y1 + 1:
|
||||||
return 1
|
return MVT_OK
|
||||||
elif y1 == 1 and y2 == 3 and self.grille[x1][2] == 0:
|
elif y1 == 1 and y2 == 3 and self.grille[x1][2] == 0:
|
||||||
return MVT_OK
|
return MVT_OK
|
||||||
else:
|
else:
|
||||||
|
@ -192,7 +189,7 @@ class LogiqueEchecs:
|
||||||
test = self.mvtPossible(x1, y1, x2, y2)
|
test = self.mvtPossible(x1, y1, x2, y2)
|
||||||
if test == MVT_OK:
|
if test == MVT_OK:
|
||||||
self.grille[x1][y1], self.grille[x2][y2] = 0, self.grille[x1][y1]
|
self.grille[x1][y1], self.grille[x2][y2] = 0, self.grille[x1][y1]
|
||||||
# self.joueur = not self.joueur
|
self.joueur = not self.joueur
|
||||||
return test
|
return test
|
||||||
|
|
||||||
# GUI
|
# GUI
|
||||||
|
@ -446,8 +443,7 @@ class PlateauTk:
|
||||||
self.grillePions[x2][y2])
|
self.grillePions[x2][y2])
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
# TODO Messages corrects
|
self.statut('Déplacment impossible ! (' + str(test) + ')')
|
||||||
self.statut('Impossible ! (' + str(test) + ')')
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def dClic(self, x, y):
|
def dClic(self, x, y):
|
||||||
|
|
Reference in a new issue