jcchess.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:jcchess 作者: johncheetham 项目源码 文件源码
def goto_move(self, move_idx):
        try:
            gv.ucib.stop_engine()
            gv.uciw.stop_engine()
        except:
            pass
        self.gameover = False
        if move_idx < len(self.movelist):
            while move_idx < len(self.movelist):
                self.undo_move()
        else:
            while move_idx > len(self.movelist):
                self.redo_move()

        self.stm = self.get_side_to_move()
        gv.gui.set_side_to_move(self.stm)

        gv.board.update()
        # gv.gui.set_status_bar_msg(" ")
        move = None
        try:
            move = self.movelist[len(self.movelist) - 1]
            self.lastmove = move
            # print "move ",move
        except IndexError:
            pass

        if move is not None:
            gv.gui.set_status_bar_msg(self.convert_move(move_idx)+move)
            if gv.show_moves == True:
               nmoves = len(self.movelist)
               path =(nmoves-1,)
               sel = gv.gui.move_view.get_selection()
               sel.select_path(path)  # path has to be set to nmoves-1 to hit the right selection
               self.move_list.set_move(nmoves)
               #print(nmoves, "goto move")             
        else:
            gv.gui.set_status_bar_msg(" ")

    #
    # called from gui.py when undo button click on toolbar (passed widget is
    # Gtk.ToolButton object) and when undo move is selected from menu
    # (or ctrl-u is pressed) (passed widget is Gtk.Action object)
    #
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号