Beispiel #1
0
def instract_list_panel() -> list:
    """
    绘制指令面板
    Return arguments:
    list -- 绘制的按钮列表
    """
    instruct_list = [
        instruct for instruct_type in instruct_data
        if instruct_type in cache_contorl.instruct_filter
        and cache_contorl.instruct_filter[instruct_type]
        for instruct in instruct_data[instruct_type]
        if judge_instract_available(instruct)
    ]
    return_data = [
        str(instruct_cmd_id_data[instruct]) for instruct in instruct_list
    ]
    cmd_data = [
        "      " + cmd_button_queue.id_index(return_data[i]) +
        instruct_text_data[instruct_list[i]] for i in range(len(instruct_list))
    ]
    if len(return_data) > 0:
        cmd_button_queue.option_str(
            None,
            5,
            "left",
            False,
            False,
            cmd_data,
            "",
            return_data,
            {},
            {},
            False,
        )
    return return_data
def see_character_item_panel(character_id: int) -> list:
    """
    查看角色背包道具列表面板
    Keyword arguments:
    character_id -- 角色Id
    """
    era_print.normal_print(
        attr_text.get_see_attr_panel_head_character_info(character_id))
    era_print.restart_line_print(".")
    if character_id != 0:
        era_print.line_feed_print(
            text_loading.get_text_data(constant.FilePath.MESSAGE_PATH, "37"))
        return []
    character_item_data = cache_contorl.character_data["character"][
        character_id].item
    if len(character_item_data) == 0:
        era_print.line_feed_print(
            text_loading.get_text_data(constant.FilePath.MESSAGE_PATH, "36"))
        return []
    now_page_id = int(cache_contorl.panel_state["SeeCharacterItemListPanel"])
    now_page_max = game_config.see_character_item_max
    now_page_start_id = now_page_id * now_page_max
    now_page_end_id = now_page_start_id + now_page_max
    if now_page_end_id > len(character_item_data.keys()):
        now_page_end_id = len(character_item_data.keys())
    input_s = []
    index = 0
    for i in range(now_page_start_id, now_page_end_id):
        item_id = list(character_item_data.keys())[i]
        item_data = character_item_data[item_id]
        item_text = (item_data["ItemName"] + " " + text_loading.get_text_data(
            constant.FilePath.STAGE_WORD_PATH, "136") +
                     str(item_data["ItemNum"]))
        if character_id == "0":
            id_info = cmd_button_queue.id_index(index)
            cmd_text = id_info + item_text
            py_cmd.pcmd(cmd_text, index, None)
        else:
            era_print.normal_print(item_text)
        index += 1
        input_s.append(str(index))
        era_print.line_feed_print()
    return input_s
Beispiel #3
0
def see_character_list_panel(max_page: int) -> list:
    """
    查看角色列表面板
    Keyword arguments:
    max_page -- 最大角色列表页数
    """
    title_text = text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH,
                                            "74")
    era_print.little_title_print(title_text)
    input_s = []
    page_id = int(cache_contorl.panel_state["SeeCharacterListPanel"])
    page_show = int(game_config.character_list_show)
    character_max = len(cache_contorl.character_data["character"]) - 1
    if page_id == max_page:
        show_page_start = page_show * page_id
        show_page_over = show_page_start + (character_max + 1 -
                                            show_page_start)
    else:
        show_page_over = page_show * (page_id + 1)
        show_page_start = show_page_over - page_show
    for i in range(show_page_start, show_page_over):
        cmd_id = i - show_page_start
        cmd_id_text = cmd_button_queue.id_index(cmd_id)
        cmd_text = attr_text.get_character_abbreviations_info(i)
        cmd_id_text_index = text_handle.get_text_index(cmd_id_text)
        window_width = int(game_config.text_width)
        text_width = window_width - cmd_id_text_index
        cmd_text = text_handle.align(cmd_text, "center", text_width=text_width)
        cmd_text = cmd_id_text + " " + cmd_text
        cmd_id = str(cmd_id)
        era_print.little_line_print()
        py_cmd.pcmd(cmd_text, cmd_id, None)
        input_s.append(cmd_id)
        era_print.normal_print("\n")
    page_text = "(" + str(page_id) + "/" + str(max_page) + ")"
    era_print.page_line_print(sample="-", string=page_text)
    era_print.line_feed_print()
    return input_s
Beispiel #4
0
def see_character_wear_clothes(character_id: int, change_button: bool):
    """
    查看角色穿戴服装列表面板
    Keyword arguments:
    character_id -- 角色id
    change_button -- 将服装列表绘制成按钮的开关
    """
    character_clothing_data = cache_contorl.character_data[
        character_id
    ].clothing
    character_put_on_list = cache_contorl.character_data[character_id].put_on
    clothing_text_data = {}
    tag_text_index = 0
    for i in range(len(clothing.clothing_type_text_list.keys())):
        clothing_type = list(clothing.clothing_type_text_list.keys())[i]
        clothing_id = character_put_on_list[clothing_type]
        if clothing_id == "":
            clothing_text_data[clothing_type] = "None"
        else:
            clothing_data = character_clothing_data[clothing_type][clothing_id]
            clothing_text = (
                clothing.clothing_type_text_list[clothing_type]
                + ":"
                + clothing_data["Evaluation"]
                + clothing_data["Tag"]
                + clothing_data["Name"]
            )
            clothing_text_data[clothing_text] = {}
            for tag in clothing.clothing_tag_text_list:
                tag_text = clothing.clothing_tag_text_list[tag] + str(
                    clothing_data[tag]
                )
                clothing_text_data[clothing_text][tag_text] = 0
                now_tag_text_index = text_handle.get_text_index(tag_text)
                if now_tag_text_index > tag_text_index:
                    tag_text_index = now_tag_text_index
    long_clothing_text_index = text_handle.get_text_index(
        max(clothing_text_data.keys(), key=text_handle.get_text_index)
    )
    i = 0
    input_s = []
    for clothing_text in clothing_text_data:
        draw_text = ""
        era_print.little_line_print()
        if clothing_text_data[clothing_text] == "None":
            draw_text = (
                clothing.clothing_type_text_list[clothing_text]
                + ":"
                + text_loading.get_text_data(
                    constant.FilePath.STAGE_WORD_PATH, "117"
                )
            )
        else:
            now_clothing_text_index = text_handle.get_text_index(clothing_text)
            draw_text += clothing_text + " "
            if now_clothing_text_index < long_clothing_text_index:
                draw_text += " " * (
                    long_clothing_text_index - now_clothing_text_index
                )
            for tag_text in clothing_text_data[clothing_text]:
                now_tag_text_index = text_handle.get_text_index(tag_text)
                if now_tag_text_index < tag_text_index:
                    draw_text += (
                        " "
                        + tag_text
                        + " " * (tag_text_index - now_tag_text_index)
                    )
                else:
                    draw_text += " " + tag_text
        if change_button:
            id_info = cmd_button_queue.id_index(i)
            cmd_text = id_info + draw_text
            py_cmd.pcmd(cmd_text, i, None)
        else:
            era_print.normal_print(draw_text)
        input_s.append(f"{i}")
        i += 1
        era_print.normal_print("\n")
    return input_s
Beispiel #5
0
def see_character_clothes_panel(
    character_id: str, clothing_type: str, max_page: int
) -> list:
    """
    用于查看角色服装列表的面板
    Keyword arguments:
    character_id -- 角色id
    clothing_type -- 服装类型
    max_page -- 服装列表最大页数
    Rerurn arguments:
    list -- 监听的按钮列表
    """
    era_print.line_feed_print()
    character_clothing_data = cache_contorl.character_data[
        character_id
    ].clothing[clothing_type]
    clothing_text_data = {}
    tag_text_index = 0
    now_page_id = int(cache_contorl.panel_state["SeeCharacterClothesPanel"])
    now_page_max = game_config.see_character_clothes_max
    now_page_start_id = now_page_id * now_page_max
    now_page_end_id = now_page_start_id + now_page_max
    if character_clothing_data == {}:
        era_print.normal_print(
            text_loading.get_text_data(constant.FilePath.MESSAGE_PATH, "34")
        )
        era_print.line_feed_print()
        return []
    if now_page_end_id > len(character_clothing_data.keys()):
        now_page_end_id = len(character_clothing_data.keys())
    pass_id = None
    for i in range(now_page_start_id, now_page_end_id):
        clothing_id = list(character_clothing_data.keys())[i]
        if (
            clothing_id
            == cache_contorl.character_data[character_id].put_on[clothing_type]
        ):
            pass_id = i - now_page_start_id
        clothing_data = character_clothing_data[clothing_id]
        clothing_text = (
            clothing_data["Evaluation"]
            + clothing_data["Tag"]
            + clothing_data["Name"]
        )
        clothing_text_data[clothing_text] = {}
        for tag in clothing.clothing_tag_text_list:
            tag_text = clothing.clothing_tag_text_list[tag] + str(
                clothing_data[tag]
            )
            clothing_text_data[clothing_text][tag_text] = 0
            now_tag_text_index = text_handle.get_text_index(tag_text)
            if now_tag_text_index == now_tag_text_index:
                tag_text_index = now_tag_text_index
    long_clothing_text_index = text_handle.get_text_index(
        max(clothing_text_data.keys(), key=text_handle.get_text_index)
    )
    i = 0
    input_s = []
    for clothing_text in clothing_text_data:
        draw_text = ""
        era_print.little_line_print()
        now_clothing_text_index = text_handle.get_text_index(clothing_text)
        draw_text += clothing_text + " "
        if now_clothing_text_index < long_clothing_text_index:
            draw_text += " " * (
                long_clothing_text_index - now_clothing_text_index
            )
        for tag_text in clothing_text_data[clothing_text]:
            now_tag_text_index = text_handle.get_text_index(tag_text)
            if now_tag_text_index < tag_text_index:
                draw_text += (
                    " "
                    + tag_text
                    + " " * (tag_text_index - now_tag_text_index)
                )
            else:
                draw_text += " " + tag_text
        if i == pass_id:
            draw_text += " " + text_loading.get_text_data(
                constant.FilePath.STAGE_WORD_PATH, "125"
            )
        id_info = cmd_button_queue.id_index(i)
        cmd_text = id_info + draw_text
        input_s.append(f"{i}")
        py_cmd.pcmd(cmd_text, i, None)
        era_print.line_feed_print()
        i += 1
    era_print.normal_print("\n")
    page_text = "(" + str(now_page_id) + "/" + str(max_page) + ")"
    era_print.page_line_print(sample="-", string=page_text)
    era_print.line_feed_print()
    return input_s
Beispiel #6
0
def see_food_shop_list_by_food_type(max_page: int, food_list: list) -> list:
    """
    用于查看餐馆出售食物列表的面板
    Keyword arguments:
    max_page -- 最大页数
    Return arguments:
    list -- 监听的按钮列表
    """
    era_print.restart_line_print("+")
    tag_text_index = 0
    now_page_id = int(
        cache_contorl.panel_state["SeeFoodShopListByFoodTypePanel"]
    )
    now_page_max = game_config.food_shop_item_max
    now_page_start_id = now_page_id * now_page_max
    now_page_end_id = now_page_start_id + now_page_max
    if not len(food_list):
        era_print.normal_print(
            text_loading.get_text_data(constant.FilePath.MESSAGE_PATH, "34")
        )
        era_print.line_feed_print()
        return []
    if now_page_end_id > len(food_list):
        now_page_end_id = len(food_list)
    input_s = []
    text_list = []
    fix_text = ""
    for i in range(now_page_start_id, now_page_end_id):
        now_food = food_list[i]
        if now_food.recipe == -1:
            food_config = text_loading.get_text_data(
                constant.FilePath.FOOD_PATH, now_food.id
            )
            food_name = food_config["Name"]
        else:
            food_name = cache_contorl.recipe_data[now_food.recipe].name
        now_index = cmd_button_queue.id_index(tag_text_index)
        food_text = now_index + " " + food_name
        food_text += " " + text_loading.get_text_data(
            constant.FilePath.STAGE_WORD_PATH, "154"
        )
        if "Hunger" in now_food.feel:
            food_text += str(round(now_food.feel["Hunger"], 2))
        else:
            food_text += "0"
        food_text += " " + text_loading.get_text_data(
            constant.FilePath.STAGE_WORD_PATH, "153"
        )
        if "Thirsty" in now_food.feel:
            food_text += str(round(now_food.feel["Thirsty"], 2))
        else:
            food_text += "0"
        food_text += (
            " "
            + text_loading.get_text_data(
                constant.FilePath.STAGE_WORD_PATH, "155"
            )
            + str(now_food.weight)
        )
        food_text += text_loading.get_text_data(
            constant.FilePath.STAGE_WORD_PATH, "156"
        )
        food_text += " " + text_loading.get_text_data(
            constant.FilePath.STAGE_WORD_PATH, "152"
        )
        food_text += text_loading.get_text_data(
            constant.FilePath.STAGE_WORD_PATH, "151"
        )[now_food.quality]
        text_list.append(food_text)
        now_fix_text = text_handle.align(food_text, "center", True)
        if fix_text == "":
            fix_text = now_fix_text
        if len(now_fix_text) < len(fix_text):
            fix_text = now_fix_text
        tag_text_index += 1
    for i in range(tag_text_index):
        now_text = fix_text + text_list[i]
        now_text = text_handle.align(now_text)
        py_cmd.pcmd(now_text, i)
        era_print.normal_print("\n")
        input_s.append(str(i))
        if i < tag_text_index - 1:
            era_print.restart_line_print("*")
    return input_s
def see_save_list_panel(page_save_value: int,
                        last_save_page_value: int,
                        auto_save=False) -> list:
    """
    查看存档页面面板
    Keyword arguments:
    page_save_value -- 单页最大存档显示数量
    last_save_page_value -- 最后一页存档显示数量
    auto_save -- 自动存档显示开关 (default False)
    """
    save_panel_page = int(cache_contorl.panel_state["SeeSaveListPanel"]) + 1
    input_s = []
    id_text_list = []
    id_info_text = text_loading.get_text_data(
        constant.FilePath.STAGE_WORD_PATH, "72")
    text_width = int(game_config.text_width)
    save_none_text = text_loading.get_text_data(constant.FilePath.MESSAGE_PATH,
                                                "20")
    if save_panel_page == int(game_config.save_page) + 1:
        start_save_id = int(page_save_value) * (save_panel_page - 1)
        over_save_id = start_save_id + last_save_page_value
    else:
        over_save_id = int(page_save_value) * save_panel_page
        start_save_id = over_save_id - int(page_save_value)
    for i in range(0, over_save_id - start_save_id):
        id = cmd_button_queue.id_index(i)
        save_id = start_save_id + i
        if auto_save and not save_handle.judge_save_file_exist(str(save_id)):
            id_text = id_info_text + " " + str(save_id) + ":"
            id_text_list.append(id_text)
        else:
            id_text = id + id_info_text + " " + str(save_id) + ":"
            id_text_list.append(id_text)
    for i in range(0, over_save_id - start_save_id):
        id = str(i)
        id_text = id_text_list[i]
        era_print.little_line_print()
        save_id = str(save_handle.get_save_page_save_id(page_save_value, i))
        if save_handle.judge_save_file_exist(save_id):
            save_info_head = save_handle.load_save_info_head(save_id)
            game_time_data = save_info_head["game_time"]
            game_time_text = game_time.get_date_text(game_time_data)
            character_name = save_info_head["character_name"]
            save_verson = save_info_head["game_verson"]
            save_text = (character_name + " " + game_time_text + " " +
                         save_verson)
            id_text_index = int(text_handle.get_text_index(id_text))
            fix_id_width = text_width - id_text_index
            save_align = text_handle.align(save_text,
                                           "center",
                                           text_width=fix_id_width)
            id_text = id_text + save_align
            py_cmd.pcmd(id_text, id, None)
            input_s.append(id)
            era_print.normal_print("\n")
        else:
            id_text_index = int(text_handle.get_text_index(id_text))
            fix_id_width = text_width - id_text_index
            save_none_align = text_handle.align(save_none_text,
                                                "center",
                                                text_width=fix_id_width)
            id_text = id_text + save_none_align
            if auto_save:
                era_print.normal_print(id_text)
            else:
                py_cmd.pcmd(id_text, id, None)
                input_s.append(id)
        era_print.line_feed_print()
    if auto_save:
        auto_info_text = text_loading.get_text_data(
            constant.FilePath.STAGE_WORD_PATH, "73")
        i = page_save_value
        id = cmd_button_queue.id_index(i)
        era_print.little_line_print()
        if save_handle.judge_save_file_exist("auto"):
            save_info_head = save_handle.load_save_info_head("auto")
            game_time_data = save_info_head["game_time"]
            game_time_text = game_time.get_date_text(game_time_data)
            character_name = save_info_head["character_name"]
            save_verson = save_info_head["game_verson"]
            save_text = (character_name + " " + game_time_text + " " +
                         save_verson)
            id_text = id + auto_info_text
            id_text_index = int(text_handle.get_text_index(id_text))
            fix_id_width = text_width - id_text_index
            save_text_align = text_handle.align(save_text,
                                                "center",
                                                text_width=fix_id_width)
            id_text = id_text + save_text_align
            py_cmd.pcmd(id_text, id, None)
            input_s.append(id)
            era_print.line_feed_print()
        else:
            id_text_index = int(text_handle.get_text_index(auto_info_text))
            fix_id_width = text_width - id_text_index
            save_none_align = text_handle.align(save_none_text,
                                                "center",
                                                text_width=fix_id_width)
            id_text = auto_info_text + save_none_align
            era_print.normal_print(id_text)
            era_print.line_feed_print()
    return input_s