Exemplo n.º 1
0
 def button_clicked(self):
     """This method is called when an array of the board (button) is clicked."""
     position = UICommons.game_position(self.sender().position, self._players_color())
     if self.selected:
         result = self.game.players_move((self.selected, position, None))
         self.selected = None
         self.redraw.emit()
         self._computers_move()
     else:
         self.selected = position
     self.redraw.emit()
Exemplo n.º 2
0
 def paintEvent(self, event):
     
     """Redraw the field array regarding the figure and color."""
     painter = QPainter(self)
     
     #Coordinates of [0, 0] are on the left bottom corner here
     game_position = UICommons.game_position(self.position, self._parent._players_color())
     board_color = (self.position + (self.position // Common.board_size) % 2) % 2
     
     figure = self._parent.game.board()[game_position]
     if figure:
         figure_type = figure.get_type()
         index = figure.color + 2 * board_color
         painter.drawPixmap(event.rect(), self._parent.images.figures[figure_type][index])
     else:
         painter.drawPixmap(event.rect(), self._parent.images.empty[board_color])
     if self._parent.selected == game_position:
         self._draw_border()
Exemplo n.º 3
0
    def paintEvent(self, event):
        """Redraw the field array regarding the figure and color."""
        painter = QPainter(self)

        #Coordinates of [0, 0] are on the left bottom corner here
        game_position = UICommons.game_position(self.position,
                                                self._parent._players_color())
        board_color = (self.position +
                       (self.position // Common.board_size) % 2) % 2

        figure = self._parent.game.board()[game_position]
        if figure:
            figure_type = figure.get_type()
            index = figure.color + 2 * board_color
            painter.drawPixmap(event.rect(),
                               self._parent.images.figures[figure_type][index])
        else:
            painter.drawPixmap(event.rect(),
                               self._parent.images.empty[board_color])
        if self._parent.selected == game_position:
            self._draw_border()