示例#1
0
def display_board(channel):

    moves = Move.query_board_moves(channel)

    moves_listed = []

    for move in sorted(moves):
        for item in move:
            moves_listed.append(item)

    print moves_listed

    numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]

    #cb = current_board
    cb = []

    if not moves:
        for num in numbers:
            cb.append("   ")
    else:
        for num in numbers:
            if num in moves_listed:
                cb.append(moves_listed[1])
                moves_listed = moves_listed[2:]
            else:
                cb.append("   ")


    print cb

    board = '''
    | ''' + cb[0] + '''   | ''' + cb[1] + '''   | ''' + cb[2] + '''   |
    |---+---+---|
    | ''' + cb[3] + '''   | ''' + cb[4] + '''   | ''' + cb[5] + '''   |
    |---+---+---|
    | ''' + cb[6] + '''   | ''' + cb[7] + '''   | ''' + cb[8] + '''   |
    '''

    return board