Beispiel #1
0
 def undoLastMove(self):
     lastMove = self._recorder.getLastMove()
     if lastMove != None:
         for move in lastMove:
             pionV = None
             pionLetter = move[2]
             color = move[3]
             if pionLetter == "T":
                 pionV = tour(color)
             elif pionLetter == "C":
                 pionV = cavalier(color)
             elif pionLetter == "F":
                 pionV = fou(color)
             elif pionLetter == "K":
                 pionV = roi(color)
             elif pionLetter == "Q":
                 pionV = reine(color)
             elif pionLetter == "P":
                 pionV = pion(color)
             self.setPion(move[0], move[1], pionV, False)
         self.changePlayer(False)
         self._echecEtMat = False
         self._interface.clearMessage()
     else:
         self._interface.showMessage ("No moves recorded")
Beispiel #2
0
 def openFile(self, filename):
     if self._server != None or self._client != None: #pragma: no cover 
         self._interface.showMessage ("load file not permitted while playing in network")
         return
     if filename != "":
         for X in range(0, 8):
             for Y in range(0, 8):
                 self.setPion(X, Y, None)
         with open(filename) as f:
             content = f.readlines()
             f.close()
         for line in content:
             values = line.split(',')
             color = int(values[3].replace('\n', ''))
             pionLetter = values[2]
             if pionLetter == "T":
                 pionV = tour(color)
             elif pionLetter == "C":
                 pionV = cavalier(color)
             elif pionLetter == "F":
                 pionV = fou(color)
             elif pionLetter == "K":
                 pionV = roi(color)
             elif pionLetter == "Q":
                 pionV = reine(color)
             elif pionLetter == "P":
                 pionV = pion(color)
             self.setPion(int(values[0]), int(values[1]), pionV)
         self.setCurPlayer(-1)
         self._interface.draw(self)
Beispiel #3
0
    def reset(self):
        for X in range(0, 8):
            for Y in range(2, 6):
                self._tableau[X][Y]=None
        self._tableau[0][0]=tour(piece._players['NOIR'])
        self._tableau[1][0]=cavalier(piece._players['NOIR'])
        self._tableau[2][0]=fou(piece._players['NOIR'])
        self._tableau[3][0]=reine(piece._players['NOIR'])
        self._tableau[4][0]=roi(piece._players['NOIR'])
        self._tableau[5][0]=fou(piece._players['NOIR'])
        self._tableau[6][0]=cavalier(piece._players['NOIR'])
        self._tableau[7][0]=tour(piece._players['NOIR'])

        self._tableau[0][1]=pion(piece._players['NOIR'])
        self._tableau[1][1]=pion(piece._players['NOIR'])
        self._tableau[2][1]=pion(piece._players['NOIR'])
        self._tableau[3][1]=pion(piece._players['NOIR'])
        self._tableau[4][1]=pion(piece._players['NOIR'])
        self._tableau[5][1]=pion(piece._players['NOIR'])
        self._tableau[6][1]=pion(piece._players['NOIR'])
        self._tableau[7][1]=pion(piece._players['NOIR'])

        self._tableau[0][6]=pion(piece._players['BLANC'])
        self._tableau[1][6]=pion(piece._players['BLANC'])
        self._tableau[2][6]=pion(piece._players['BLANC'])
        self._tableau[3][6]=pion(piece._players['BLANC'])
        self._tableau[4][6]=pion(piece._players['BLANC'])
        self._tableau[5][6]=pion(piece._players['BLANC'])
        self._tableau[6][6]=pion(piece._players['BLANC'])
        self._tableau[7][6]=pion(piece._players['BLANC'])

        self._tableau[0][7]=tour(piece._players['BLANC'])
        self._tableau[1][7]=cavalier(piece._players['BLANC'])
        self._tableau[2][7]=fou(piece._players['BLANC'])
        self._tableau[3][7]=reine(piece._players['BLANC'])
        self._tableau[4][7]=roi(piece._players['BLANC'])
        self._tableau[5][7]=fou(piece._players['BLANC'])
        self._tableau[6][7]=cavalier(piece._players['BLANC'])
        self._tableau[7][7]=tour(piece._players['BLANC'])
        self._curPlayer = -1
        self._echecEtMat = False
Beispiel #4
0
 def showPromotion(self, tableau):
     curPlayer = tableau.getCurPlayer()
     print("Enter the type of piece you want (T, C, F, Q) :")
     piece = input("Piece : ")
     while (True):
         if piece == "T":
             tableau.setPromoted(tour.tour(curPlayer))
             break
         elif piece == "C":
             tableau.setPromoted(cavalier.cavalier(curPlayer))
             break
         elif piece == "F":
             tableau.setPromoted(fou.fou(curPlayer))
             break
         elif piece == "Q":
             tableau.setPromoted(reine.reine(curPlayer))
             break
         else:
             piece = input("Piece : ")
Beispiel #5
0
 def showPromotion(self, tableau):
     color = tableau.getCurPlayer()
     self.promotion = Toplevel()
     self.promotion.title("Promotion")
     canvas=Canvas(self.promotion, width=300, height=100)
     canvas.grid(row=1, column = 1, sticky=W)
     if (color == 1 or color == 0):
         canvas.create_image(10, 10, anchor=NW, image=self.tour_n)
         canvas.create_image(50, 10, anchor=NW, image=self.cavalier_n)
         canvas.create_image(90, 10, anchor=NW, image=self.fou_n)
         canvas.create_image(130, 10, anchor=NW, image=self.reine_n)
     if (color == -1 or color == 0):
         canvas.create_image(10, 50, anchor=NW, image=self.tour_b)
         canvas.create_image(50, 50, anchor=NW, image=self.cavalier_b)
         canvas.create_image(90, 50, anchor=NW, image=self.fou_b)
         canvas.create_image(130, 50, anchor=NW, image=self.reine_b)
     self.promotion.bind('<Button-1>', self.getPromoted)
     while True:
         self.fenetre.update()
         try:
             item = self.queueP.get(False)
             command = item[0]
             if command == "promotion":
                 piece = item[1]
                 if piece == "T":
                     tableau.setPromoted(tour.tour(color))
                     break
                 elif piece == "C":
                     tableau.setPromoted(cavalier.cavalier(color))
                     break
                 elif piece == "F":
                     tableau.setPromoted(fou.fou(color))
                     break
                 elif piece == "Q":
                     tableau.setPromoted(reine.reine(color))
                     break
                 break
         except KeyboardInterrupt:
             item = (-1,-1)
         except queue.Empty:
             time.sleep(0.3)
             continue
Beispiel #6
0
 def showPromotion(self, tableau):
     try:
         curPlayer = tableau.getCurPlayer()
         print("Enter the type of piece you want (T, C, F, Q) :")
         piece = input("Piece : ")
         while (True):
             if piece == "T":
                 tableau.setPromoted(tour.tour(curPlayer))
                 break
             elif piece == "C":
                 tableau.setPromoted(cavalier.cavalier(curPlayer))
                 break
             elif piece == "F":
                 tableau.setPromoted(fou.fou(curPlayer))
                 break
             elif piece == "Q":
                 tableau.setPromoted(reine.reine(curPlayer))
                 break
             else:
                 piece = input("Piece : ")
         self.draw(tableau)
     except KeyboardInterrupt:  #pragma: no cover
         tableau.insertMove(-1, -1, -1)