Example #1
0
def legend(headcolor, tailcolor, status, name):
    tailcolor()
    sys.stdout.write('  ')
    headcolor()
    sys.stdout.write(status)
    color.reset()
    sys.stdout.write(' '+name)
Example #2
0
def legend(headcolor, tailcolor, status, name):
    tailcolor()
    sys.stdout.write('  ')
    headcolor()
    sys.stdout.write(status)
    color.reset()
    sys.stdout.write(' '+name)
Example #3
0
def print_board(board, name1, name2, ansi=False):
    if ansi:
        if board.diff is None:
            color.clear()
            for line in board.getboard():
                for match in re.finditer('(.)\\1*', line):
                    a, b = ANSICHARS[match.group(1)]
                    a()
                    sys.stdout.write(b*len(match.group(0)))
                    color.reset()
                blank_line()
        else:
            for x,y in board.diff:
                color.movexy(x*2, y)
                a, b = ANSICHARS[board.board[y][x]]
                a()
                sys.stdout.write(b)
                color.reset()
            color.movexy(0, board.height)
        clear_line(board)
        blank_line()
        clear_line(board)
        x, y = board.p1loc
        legend(C1, C1T, ANSICHARS[board.board[y][x]][1], name1)
        blank_line()
        clear_line(board)
        x, y = board.p2loc
        legend(C2, C2T, ANSICHARS[board.board[y][x]][1],name2)
        blank_line()
        clear_line(board)
    else:
        print
        for line in board.getboard():
            for c in line:
                sys.stdout.write(CHARS[c])
            print
        print '-'*board.width
Example #4
0
def print_board(board, name1, name2, ansi=False):
    if ansi:
        if board.diff is None:
            color.clear()
            for line in board.getboard():
                for match in re.finditer('(.)\\1*', line):
                    a, b = ANSICHARS[match.group(1)]
                    a()
                    sys.stdout.write(b*len(match.group(0)))
                    color.reset()
                blank_line()
        else:
            for x,y in board.diff:
                color.movexy(x*2, y)
                a, b = ANSICHARS[board.board[y][x]]
                a()
                sys.stdout.write(b)
                color.reset()
            color.movexy(0, board.height)
        clear_line(board)
        blank_line()
        clear_line(board)
        x, y = board.p1loc
        legend(C1, C1T, ANSICHARS[board.board[y][x]][1], name1)
        blank_line()
        clear_line(board)
        x, y = board.p2loc
        legend(C2, C2T, ANSICHARS[board.board[y][x]][1],name2)
        blank_line()
        clear_line(board)
    else:
        print
        for line in board.getboard():
            for c in line:
                sys.stdout.write(CHARS[c])
            print
        print '-'*board.width