[Echecs] Ajout de messages d'erreur

This commit is contained in:
Geoffrey Frogeye 2014-12-06 23:28:12 +01:00
parent f71bf87a1f
commit 35afd29340

View file

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