Example #1
0
    def update(self):

        # update liststore
        self.liststore.clear()
        self.liststore.append(("0.", "Start Pos", " "))
        mvstr = engine.getmovelist()

        if mvstr != "":
            mlst = mvstr.split(",")
            moveno = 1
            for m in mlst:

                (capture, ispromoted, move) = m.split(";")

                if move.find("*") == -1:
                    m1 = move[0:3]
                    m2 = move[3:]
                    move = m1 + capture + m2
                    if ispromoted == "+":
                        move = "+" + move
                comment = self.comments.get_comment(moveno)
                if comment != "":
                    cind = "..."
                else:
                    cind = " "
                e = str(moveno) + ".", move, cind
                self.liststore.append(e)
                moveno += 1

        GObject.idle_add(self.scroll_to_end)
Example #2
0
    def update(self):

        # update liststore
        self.liststore.clear()
        self.liststore.append(("0.", "Start Pos", " "))
        mvstr = engine.getmovelist()

        if mvstr != "":
            mlst = mvstr.split(",")
            moveno = 1
            for m in mlst:

                (capture, ispromoted, move) = m.split(";")

                if move.find("*") == -1:
                    m1 = move[0:3]
                    m2 = move[3:]
                    move = m1 + capture + m2
                    if ispromoted == "+":
                        move = "+" + move
                comment = self.comments.get_comment(moveno)
                if comment != "":
                    cind = "..."
                else:
                    cind = " "
                e = str(moveno) + ".", move, cind
                self.liststore.append(e)
                moveno += 1

        GObject.idle_add(self.scroll_to_end)
Example #3
0
    def update(self): 

        # update liststore
        self.liststore.clear()
        self.liststore.append( ('0.', 'Start Pos', ' ') )
        mvstr = engine.getmovelist()
        
        if mvstr != "":                
            mlst = mvstr.split(',')
            moveno = 1
            for m in mlst:                    
                        
                (capture, ispromoted, move) = m.split(';') 
                    
                if move.find('*') == -1:
                    m1 = move[0:3]
                    m2 = move[3:]
                    move = m1 + capture + m2
                    if ispromoted == '+':
                        move = '+' + move
                comment = self.comments.get_comment(moveno)
                if comment != '':
                    cind = '...'
                else:
                    cind = ' '                 
                e = str(moveno) + '.', move, cind
                self.liststore.append(e)
                moveno += 1       
        
        gobject.idle_add(self.scroll_to_end)
Example #4
0
    def get_game(self):

        gamestr = ""
        startpos = gv.gshogi.get_startpos()
        # properties
        dat = str(date.today())
        dat = dat.replace("-", "/")

        zstr = '[Date "' + dat + '"]\n'
        gamestr += zstr

        zstr = '[Sente "' + gv.gshogi.get_player(BLACK).strip() + '"]\n'
        gamestr += zstr

        zstr = '[Gote "' + gv.gshogi.get_player(WHITE).strip() + '"]\n'
        gamestr += zstr

        # sfen
        if startpos == "startpos":
            zstr = '[SFEN "lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP" \
                   "/1B5R1/LNSGKGSNL b - 1"]\n'
            gamestr += zstr
        else:
            zstr = '[SFEN "' + startpos + '"]\n'
            gamestr += zstr

        # add comment if present
        comment = self.comments.get_comment(0)
        if comment != "":
            gamestr = gamestr + "{\n" + comment + "\n}\n"

        # if the movelist is positioned part way through the game then
        # we must redo all moves so the full game will be saved
        redo_count = len(gv.gshogi.get_redolist())
        for i in range(0, redo_count):
            gv.gshogi.redo_move()

        # moves
        moveno = 1
        # ml = self.movelist
        mvstr = engine.getmovelist()

        # if we did any redo moves then undo them now to get things back
        # the way they were
        for i in range(0, redo_count):
            gv.gshogi.undo_move()

        if mvstr != "":
            mlst = mvstr.split(",")

            for m in mlst:

                (capture, ispromoted, move) = m.split(";")

                if move.find("*") == -1:
                    m1 = move[0:3]
                    m2 = move[3:]
                    move = m1 + capture + m2
                    if ispromoted == "+":
                        move = "+" + move
                zstr = str(moveno) + "." + move + "\n"
                gamestr += zstr
                # add comment for this move if present
                comment = self.comments.get_comment(moveno)
                if comment != "":
                    gamestr = gamestr + "{" + comment + "}\n"
                moveno += 1
        return (gamestr)
Example #5
0
    def get_game(self):

        gamestr = ""
        startpos = self.game.get_startpos()
        # properties
        dat = str(date.today())
        dat = dat.replace('-', '/')
                
        zstr = '[Date "' + dat + '"]\n'
        gamestr += zstr

        zstr = '[Sente "' + self.game.get_player(BLACK).strip() + '"]\n'
        gamestr += zstr

        zstr = '[Gote "' + self.game.get_player(WHITE).strip() + '"]\n'
        gamestr += zstr

        # sfen
        if startpos == 'startpos':
            zstr = '[SFEN "lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL b - 1"]\n'
            gamestr += zstr
        else:                    
            zstr = '[SFEN "' + startpos + '"]\n'
            gamestr += zstr

        # add comment if present
        comment = self.comments.get_comment(0)
        if comment != '':                    
            gamestr = gamestr + '{\n' + comment + '\n}\n' 

        # if the movelist is positioned part way through the game then
        # we must redo all moves so the full game will be saved
        redo_count = len(self.game.get_redolist())
        for i in range(0, redo_count):                    
            self.game.redo_move()   

        # moves
        moveno = 1
        # ml = self.movelist
        mvstr = engine.getmovelist()

        # if we did any redo moves then undo them now to get things back
        # the way they were
        for i in range(0, redo_count):                    
            self.game.undo_move()

        if mvstr != "":                             
            mlst = mvstr.split(',')                

            for m in mlst:                

                (capture, ispromoted, move) = m.split(';') 
                    
                if move.find('*') == -1:
                    m1 = move[0:3]
                    m2 = move[3:]
                    move = m1 + capture + m2
                    if ispromoted == '+':
                        move = '+' + move
                zstr = str(moveno) + '.' + move + '\n'
                gamestr += zstr 
                # add comment for this move if present 
                comment = self.comments.get_comment(moveno)
                if comment != '':                    
                    gamestr = gamestr + '{' + comment + '}\n' 
                moveno += 1
        return (gamestr)