Exemplo n.º 1
0
        if event.type == pg.QUIT:
            sys.exit()
        if event.type == pg.MOUSEBUTTONDOWN:
            # get which button was clicked:
            (b1, b2, b3) = pg.mouse.get_pressed()
            colorshift = 0
            if b1:
                if clicked:
                    # move the piece from xc yc to xn yn (new positions)
                    (xn, yn) = pg.mouse.get_pos()
                    xn, yn = findclicked(xn, yn)
                    # if (xn, yn) is in the np array of all possible moves,
                    # which is returned from getpossible(Piece), then move piece
                    # findspiece(xc, yc)
                    if CURR_PLAYER == s_piece.owner:
                        s_moves = s_piece.getpossiblemoves(boardfilled)
                        for m in s_moves:
                            if m[0] == xn and m[1] == yn:
                                clicked = False
                                movepiece(xc, yc, xn, yn)
                                boardfilled[yc][xc] = -1
                                boardfilled[yn][xn] = CURR_PLAYER
                                # test for check
                                checktest()
                                CURR_PLAYER = not CURR_PLAYER
                                moves = []
                                break

                else:
                    clicked = True
                    s_moves = []