예제 #1
0
 def slotClicked(self, x, y):
     if chessboard.has_key((x, y)) and labels.get((x, y)).styleSheet() == "background: #00f":
         chessboard.get((x, y)).makeNotAlive()
         self.movePiece(x, y)
     elif chessboard.has_key((x, y)):
         if chessboard.get((x, y)).color == self.next_move:
             for i in xrange(8):
                 for j in xrange(8):
                     labels[(i, j)].setStyleSheet(self.style[(i+j) % 2])
                     if chessboard.get((x, y)).moveValidator(i, j) and not chessboard.get((x, y)).isSelfHere(i, j):
                         labels.get((i, j)).setStyleSheet("background: #00f")
                     else:
                         labels.get((x, y)).setStyleSheet(self.style[(i+j) % 2])
                         labels.get((x, y)).setStyleSheet("background: #f00")
                         self.active_x = x
                         self.active_y = y
     elif labels.get((x, y)).styleSheet() == "background: #00f":
         self.movePiece(x, y)
예제 #2
0
 def refreshPiece(self):
     for i in xrange(8):
         for j in xrange(8):
             if chessboard.has_key((i, j)):
                 piece = chessboard.get((i, j))
                 if piece.alive:
                     if piece.color:
                         labels.get((i, j)).setImagePiece(piece.src_black)
                     else:
                         labels.get((i, j)).setImagePiece(piece.src_white)
             else:
                 labels.get((i, j)).setImagePiece("")
예제 #3
0
 def removePiece(self):
     for i in xrange(8):
         for j in xrange(8):
             if chessboard.has_key((i, j)):
                 del chessboard[(i, j)]