Example #1
0
def main():
    """
    Main function
    """
    record = GameRecord(ARGS.filename)

    game_list = record[:]
    game_label_list = [game.label for game in game_list]

    while True:
        int_response = Cli.list_menu(Enumeration(game_label_list))
        move_list = game_list[int_response - 1][:]
        print Enumeration(move_list)

        goban = Goban(game_list[int_response - 1].header_dict['SZ'])

        color = 'black'
        for move in move_list:
            Cli.wait()
            Cli.clear()
            print goban
            goban.place_stone(move.address[0], move.address[1], color)

            if color == 'black':
                color = 'white'
            elif color == 'white':
                color = 'black'
def main():
    """
    This particular file shows a point oscillating left and right along
    the x-axis.
    """
    goban = Goban(size=SIZE_, sh_obj=Cli(), adjust_ssize=-8)
    current_frame_no = 0

    while True:
        for i in range(-(goban.max_domain), goban.max_domain + 1,
            int(round(D_INTERVAL))):
            goban.fill('empty')
            goban.plot_point(i, 0, 'white')
            current_frame_no += 1
            Cli.print_header('+f{}'.format(current_frame_no))
            print((str(goban).rstrip()))  # pylint: disable=C0325
            time.sleep(T_INTERVAL)

        for i in range(-(goban.max_domain - 1), (goban.max_domain),
            int(round(D_INTERVAL))):
            goban.fill('empty')
            goban.plot_point(-i, 0, 'black')
            current_frame_no += 1
            Cli.print_header('+f{}'.format(current_frame_no))
            print((str(goban).rstrip()))  # pylint: disable=C0325
            time.sleep(T_INTERVAL)
def main():
    """
    Lets user browse and preview skins for the Goban class.
    """
    goban = Goban(sh_obj=SHELL, size=9)

    if __name__ == '__main__':
        while True:
            choice = Cli.make_page(func=lambda: SHELL.list_menu(LIST_OBJ))
            skinfile = LIST_OBJ[choice - 1]
            try:
                if SHELL.py_version == 2:
                    goban.skin_dict = json.load(open('skins/' + skinfile, 'rb'))
                elif SHELL.py_version == 3:
                    file_ptr = open('skins/{}'.format(skinfile), 'rb')
                    text_buffer = file_ptr.read().decode('utf-8')
                    goban.skin_dict = json.loads(text_buffer)
            except IOError:
                Cli.text_splash(Cli.box("File Error with '{}'".format(
                    skinfile)), duration=0)
                SHELL.wait()
                continue
            goban.cursor = [0, 0]
            Cli.text_splash("== Now give '{}' a try! ==".format(
                skinfile), duration=1, flashes=4)
            goban.view_edit()