[Echecs] Couleur lors de victoire et nettoyage commits précédents
This commit is contained in:
parent
6cdd795602
commit
f1b553d93b
|
@ -19,12 +19,10 @@ class LogiqueEchecs:
|
|||
self.grille = []
|
||||
self.cGrille()
|
||||
self.remplirGrille()
|
||||
self.joueur = True
|
||||
self.joueur = False
|
||||
self.partieFinie = False
|
||||
self.victorieux = None
|
||||
|
||||
self.nvPartie()
|
||||
|
||||
@staticmethod
|
||||
def eNoir(xD, yD):
|
||||
return xD % 2 != yD % 2
|
||||
|
@ -37,19 +35,12 @@ class LogiqueEchecs:
|
|||
self.grille.append(colonne)
|
||||
|
||||
def remplirGrille(self):
|
||||
# speciales = [2, 3, 4, 6, 5, 4, 3, 2]
|
||||
# for i in range(0, 8):
|
||||
# self.grille[i][0] = speciales[i] + 10
|
||||
# self.grille[i][1] = 11
|
||||
# self.grille[i][6] = 1
|
||||
# self.grille[i][7] = speciales[i]
|
||||
self.grille = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 6], [0, 0, 0, 3, 0, 0, 0, 0], [16, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]
|
||||
self.joueur = False
|
||||
|
||||
def nvPartie(self):
|
||||
self.cGrille()
|
||||
self.remplirGrille()
|
||||
self.joueur = True
|
||||
speciales = [2, 3, 4, 6, 5, 4, 3, 2]
|
||||
for i in range(0, 8):
|
||||
self.grille[i][0] = speciales[i] + 10
|
||||
self.grille[i][1] = 11
|
||||
self.grille[i][6] = 1
|
||||
self.grille[i][7] = speciales[i]
|
||||
|
||||
def cPion(self, x, y, piece):
|
||||
"""
|
||||
|
@ -235,7 +226,6 @@ class LogiqueEchecs:
|
|||
for x in range(0, CASES_COTE):
|
||||
for y in range(0, CASES_COTE):
|
||||
if len(self.mvtsPossibles(x, y)) > 0:
|
||||
print(x, y, self.mvtsPossibles(x, y))
|
||||
return False
|
||||
self.partieFinie = True
|
||||
self.victorieux = not self.joueur
|
||||
|
@ -248,7 +238,6 @@ class LogiqueEchecs:
|
|||
'message': test,
|
||||
'deplacer': [], # Pions à déplacer
|
||||
'supprimer': [], # Pions à supprimer
|
||||
'echecMat': False
|
||||
}
|
||||
if test == MVT_OK:
|
||||
retour['valide'] = True
|
||||
|
@ -507,6 +496,14 @@ class PlateauTk:
|
|||
def victoire(self):
|
||||
self.statut('Victoire des ' + self.nomJoueur(self.logique.victorieux) + ' !')
|
||||
self.coulDamier()
|
||||
for x in range(0, CASES_COTE):
|
||||
for y in range(0, CASES_COTE):
|
||||
pion = self.logique.grille[x][y]
|
||||
if pion > 0:
|
||||
if self.logique.ePionNoir(pion) ^ self.logique.victorieux:
|
||||
self.coulCase(x, y, 2)
|
||||
else:
|
||||
self.coulCase(x, y, 3)
|
||||
|
||||
def dPion(self, x1, y1, x2, y2):
|
||||
test = self.logique.dPion(x1, y1, x2, y2)
|
||||
|
@ -519,8 +516,6 @@ class PlateauTk:
|
|||
self.animerD((d[0] + .5) * COTE_CASE, (d[1] + .5) * COTE_CASE, \
|
||||
(d[2] + .5) * COTE_CASE, (d[3] + .5) * COTE_CASE, \
|
||||
self.grillePions[d[2]][d[3]])
|
||||
if test['echecMat']:
|
||||
print('Win!')
|
||||
|
||||
else:
|
||||
self.statut('Déplacment impossible ! (' + test['message'] + ')')
|
||||
|
|
Reference in a new issue