コード例 #1
0
import random
import math
from Script.Core import cache_contorl, text_loading, value_handle, constant

clothing_tag_text_list = {
    "Sexy":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "118"),
    "Handsome":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "119"),
    "Elegant":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "120"),
    "Fresh":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "121"),
    "Sweet":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "122"),
    "Warm":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "123"),
    "Cleanliness":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "124"),
}
clothing_type_text_list = {
    "Coat":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "41"),
    "Underwear":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "42"),
    "Pants":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "43"),
    "Skirt":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "44"),
    "Shoes":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "45"),
コード例 #2
0
    start_date = game_time.game_time_to_time_tuple(birthday)
    end_day = game_time.count_day_for_time_tuple(start_date, end_date)
    now_day = game_time.count_day_for_time_tuple(start_date, now_date)
    sub_chest = target_chest / end_day
    now_chest = sub_chest * now_day
    if now_chest > sub_chest:
        now_chest = target_chest
    return {
        "TargetChest": target_chest,
        "NowChest": now_chest,
        "SubChest": sub_chest,
    }


chest_tem_weight_data = text_loading.get_text_data(
    constant.FilePath.ATTR_TEMPLATE_PATH, "ChestWeightTem"
)


def get_rand_npc_chest_tem() -> str:
    """
    随机获取npc罩杯模板
    """
    return value_handle.get_random_for_weight(chest_tem_weight_data)


def get_rand_npc_chest(chest_tem: str) -> int:
    """
    随机获取模板对应罩杯
    Keyword arguments:
    chest_tem -- 罩杯模板
コード例 #3
0
def enter_character_nature_head():
    """
    用于确认角色性格的头部面板
    """
    era_print.line_feed_print(
        text_loading.get_text_data(constant.FilePath.MESSAGE_PATH, "39"))
コード例 #4
0
def get_tem_list() -> dict:
    """
    获取人物生成模板
    """
    return text_loading.get_text_data(constant.FilePath.ATTR_TEMPLATE_PATH,
                                      "TemList")
コード例 #5
0
ファイル: buy_food_panel.py プロジェクト: miswanting/dieloli
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
コード例 #6
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
コード例 #7
0
    game_data,
    text_loading,
    game_path_config,
    game_config,
    constant,
)
from Script.Design import (
    attr_calculation,
    map_handle,
    attr_text,
    character,
)

language = game_config.language
game_path = game_path_config.game_path
sex_list = list(text_loading.get_text_data(constant.FilePath.ROLE_PATH, "Sex"))
age_tem_list = list(
    text_loading.get_text_data(constant.FilePath.ATTR_TEMPLATE_PATH, "AgeTem"))
character_list = list(game_data.game_data[language]["character"].keys())


def init_character_list():
    """
    初始生成所有npc数据
    """
    init_character_tem()
    id_list = iter([i + 1 for i in range(len(cache_contorl.npc_tem_data))])
    npc_data_iter = iter(cache_contorl.npc_tem_data)
    for now_id, now_npc_data in zip(id_list, npc_data_iter):
        init_character(now_id, now_npc_data)
    index_character_average_value()
コード例 #8
0
def init_phase_course_hour():
    """
    初始化各班级课时
    """
    phase_course_time = text_loading.get_text_data(
        constant.FilePath.PHASE_COURSE_PATH, "CourseTime"
    )
    primary_weight = text_loading.get_text_data(
        constant.FilePath.PHASE_COURSE_PATH, "PrimarySchool"
    )
    junior_middle_weight = text_loading.get_text_data(
        constant.FilePath.PHASE_COURSE_PATH, "JuniorMiddleSchool"
    )
    senior_high_weight = text_loading.get_text_data(
        constant.FilePath.PHASE_COURSE_PATH, "SeniorHighSchool"
    )
    now_weight_list = (
        primary_weight + junior_middle_weight + senior_high_weight
    )
    all_class_hour_data = {}
    phase_index = 0
    for phase in now_weight_list:
        phase_weight_regin = value_handle.get_region_list(phase)
        weight_max = 0
        weight_max = sum(map(int, phase_weight_regin.keys()))
        class_hour_data = {}
        class_hour_max = 0
        if phase_index <= 5:
            class_hour_max = phase_course_time["PrimarySchool"]
        elif phase_index <= 8:
            class_hour_max = phase_course_time["JuniorMiddleSchool"]
        else:
            class_hour_max = phase_course_time["SeniorHighSchool"]
        class_hour_data = {
            phase_weight_regin[region]: math.ceil(
                class_hour_max * (int(region) / weight_max)
            )
            for region in phase_weight_regin
        }
        now_class_hour_max = sum(class_hour_data.values())
        while now_class_hour_max != class_hour_max:
            for course in class_hour_data:
                if now_class_hour_max == class_hour_max:
                    break
                elif (
                    class_hour_data[course] > 1
                    and now_class_hour_max > class_hour_max
                ):
                    class_hour_data[course] -= 1
                    now_class_hour_max -= 1
                elif now_class_hour_max < class_hour_max:
                    class_hour_data[course] += 1
                    now_class_hour_max += 1
        more_hour = 0
        while 1:
            for course in class_hour_data:
                if more_hour > 0 and class_hour_data[course] < 14:
                    class_hour_data[course] += 1
                    more_hour -= 1
                elif more_hour > 0 and class_hour_data[course] > 14:
                    more_hour += class_hour_data[course] - 14
                    class_hour_data[course] -= class_hour_data[course] - 14
            if more_hour == 0:
                break
        all_class_hour_data[phase_index] = class_hour_data
        phase_index += 1
    cache_contorl.course_data["ClassHour"] = all_class_hour_data
    init_phase_course_hour_experience()
コード例 #9
0
ファイル: main_frame.py プロジェクト: miswanting/dieloli
    main_frame,
    width=game_config.textbox_width,
    height=game_config.textbox_hight,
    highlightbackground=game_config.background_color,
    bd=0,
)
textbox.grid(column=0, row=0, sticky=(N, W, E, S))

# 垂直滚动条
s_vertical = ttk.Scrollbar(main_frame, orient=VERTICAL, command=textbox.yview)
textbox.configure(yscrollcommand=s_vertical.set)
s_vertical.grid(column=1, row=0, sticky=(N, E, S), rowspan=2)

# 输入框背景容器
order_font_data = text_loading.get_text_data(
    constant.FilePath.FONT_CONFIG_PATH, "order"
)
input_background_box = Text(
    main_frame,
    highlightbackground=game_config.background_color,
    background=game_config.background_color,
    bd=0,
)
input_background_box.grid(column=0, row=1, sticky=(W, E, S))

cursor_text = game_config.cursor
cursor_width = text_handle.get_text_index(cursor_text)
input_background_box_cursor = Text(
    input_background_box,
    width=cursor_width,
    height=1,
コード例 #10
0
def option_int(
    cmd_list: list,
    cmd_column=1,
    id_size="left",
    id_switch=True,
    askfor=True,
    cmd_size="left",
    start_id=0,
    cmd_list_data=None,
    last_line=False,
    normal_style_data={},
    on_style_data={},
) -> list:
    """
    批量绘制带id命令列表
    例:
    [000]开始游戏
    Keyword arguments:
    cmd_list -- 命令列表id,当cmd_list_data为None时,根据此id调用cmd_list内的命令数据
    cmd_column -- 每行命令列数 (default 1)
    id_size -- id文本位置(left/center/right) (default 'left')
    id_switch -- id显示开关 (default True)
    askfor -- 绘制完成时等待玩家输入的开关 (default True)
    cmd_size -- 命令文本在当前列的对齐方式(left/center/right) (default 'left')
    start_id -- 命令列表的起始id (default 0)
    cmd_list_data -- 命令列表数据 (default None)
    last_line -- 最后一个命令换行绘制 (default False)
    normal_style_data -- 按钮对应通常样式列表
    on_style_data -- 按钮对应按下时样式列表
    """
    if cmd_list_data is None:
        cmd_list_data = text_loading.get_text_data(
            constant.FilePath.CMD_PATH, cmd_list
        ).copy()
    input_i = []
    text_width = game_config.text_width
    if last_line:
        if len(cmd_list_data) < cmd_column:
            cmd_column = len(cmd_list_data)
    else:
        if len(cmd_list_data) + 1 < cmd_column:
            cmd_column = len(cmd_list_data)
    cmd_index = int(text_width / cmd_column)
    if len(cmd_list_data) + 1 < cmd_column:
        cmd_column = len(cmd_list_data) + 1
    for i in range(0, len(cmd_list_data)):
        cmd_text = dictionaries.handle_text(cmd_list_data[i])
        return_id = i + start_id
        if id_switch:
            id = id_index(return_id)
        else:
            id = ""
        cmd_text_and_id = id + cmd_text
        cmd_text_and_id_index = text_handle.get_text_index(cmd_text_and_id)
        normal_style = "standard"
        on_style = "onbutton"
        if cmd_list_data[i] in normal_style_data:
            normal_style = normal_style_data[cmd_list_data[i]]
        if cmd_list_data[i] in on_style_data:
            on_style = on_style_data[cmd_list_data[i]]
        if cmd_text_and_id_index < cmd_index:
            if id_size == "right":
                cmd_text_and_id = cmd_text + id
            elif id_size == "left":
                cmd_text_and_id = id + cmd_text
            if i == 0:
                cmd_text_and_id = cmd_text_and_id.rstrip()
                cmd_size_print(
                    cmd_text_and_id,
                    return_id,
                    None,
                    cmd_index,
                    cmd_size,
                    True,
                    normal_style,
                    on_style,
                )
                input_i.append(str(return_id))
            elif i / cmd_column >= 1 and i % cmd_column == 0:
                era_print.line_feed_print()
                cmd_text_and_id = cmd_text_and_id.rstrip()
                cmd_size_print(
                    cmd_text_and_id,
                    return_id,
                    None,
                    cmd_index,
                    cmd_size,
                    True,
                    normal_style,
                    on_style,
                )
                input_i.append(str(return_id))
            elif i == len(cmd_list_data) and last_line:
                era_print.line_feed_print()
                cmd_text_and_id = cmd_text_and_id.rstrip()
                cmd_size_print(
                    cmd_text_and_id,
                    return_id,
                    None,
                    cmd_index,
                    cmd_size,
                    True,
                    normal_style,
                    on_style,
                )
                input_i.append(str(return_id))
            else:
                cmd_text_and_id = cmd_text_and_id.rstrip()
                cmd_size_print(
                    cmd_text_and_id,
                    return_id,
                    None,
                    cmd_index,
                    cmd_size,
                    True,
                    normal_style,
                    on_style,
                )
                input_i.append(str(return_id))
    era_print.line_feed_print()
    if askfor:
        ans = int(game_init.askfor_int(input_i))
        return ans
    else:
        return input_i
コード例 #11
0
def option_str(
    cmd_list: str,
    cmd_column=1,
    cmd_size="left",
    last_line=False,
    askfor=True,
    cmd_list_data=None,
    null_cmd="",
    return_data=None,
    normal_style_data={},
    on_style_data={},
) -> list:
    """
    绘制无id的文本命令列表
    例:
    [长寿的青蛙]
    Keyword arguments:
    cmd_list -- 命令列表id,当cmd_list_data为None时,根据此id调用cmd_list内的命令数据
    cmd_column -- 每行命令列数 (default 1)
    cmd_size -- 命令文本在当前列的对齐方式(left/center/right) (default 'left')
    last_line -- 最后一个命令换行绘制 (default False)
    cmd_list_data -- 命令列表数据 (default None)
    null_cmd -- 在列表中按纯文本绘制,并不加入监听列表的命令文本
    return_data -- 命令返回数据 (default None)
    normal_style_data -- 按钮通常样式列表
    on_style_data -- 按钮被按下时样式列表
    """
    if cmd_list_data is None:
        cmd_list_data = text_loading.get_text_data(
            constant.FilePath.CMD_PATH, cmd_list
        ).copy()
    input_s = []
    text_width = game_config.text_width
    if last_line:
        if len(cmd_list_data) - 1 < cmd_column:
            cmd_column = len(cmd_list_data) - 1
    else:
        if len(cmd_list_data) < cmd_column:
            cmd_column = len(cmd_list_data)
    cmd_index = int(text_width / cmd_column)
    now_null_cmd = null_cmd
    for i in range(0, len(cmd_list_data)):
        normal_style = "standard"
        on_style = "onbutton"
        if cmd_list_data[i] in normal_style_data:
            normal_style = normal_style_data[cmd_list_data[i]]
        if cmd_list_data[i] in on_style_data:
            on_style = on_style_data[cmd_list_data[i]]
        now_null_cmd = True
        if return_data is None:
            if null_cmd == cmd_list_data[i]:
                now_null_cmd = False
            cmd_text_bak = dictionaries.handle_text(cmd_list_data[i])
            cmd_text = "[" + cmd_text_bak + "]"
        else:
            if null_cmd == return_data[i]:
                now_null_cmd = False
            cmd_text_bak = return_data[i]
            cmd_text = "[" + cmd_list_data[i] + "]"
        if i == 0:
            cmd_size_print(
                cmd_text,
                cmd_text_bak,
                None,
                cmd_index,
                cmd_size,
                now_null_cmd,
                normal_style,
                on_style,
            )
            if now_null_cmd:
                input_s.append(cmd_text_bak)
        elif i / cmd_column >= 1 and i % cmd_column == 0:
            era_print.line_feed_print()
            cmd_size_print(
                cmd_text,
                cmd_text_bak,
                None,
                cmd_index,
                cmd_size,
                now_null_cmd,
                normal_style,
                on_style,
            )
            if now_null_cmd:
                input_s.append(cmd_text_bak)
        elif i == len(cmd_list_data) - 1 and last_line:
            era_print.line_feed_print()
            cmd_size_print(
                cmd_text,
                cmd_text_bak,
                None,
                cmd_index,
                cmd_size,
                now_null_cmd,
                normal_style,
                on_style,
            )
            if now_null_cmd:
                input_s.append(cmd_text_bak)
        else:
            cmd_size_print(
                cmd_text,
                cmd_text_bak,
                None,
                cmd_index,
                cmd_size,
                now_null_cmd,
                normal_style,
                on_style,
            )
            if now_null_cmd:
                input_s.append(cmd_text_bak)
    era_print.line_feed_print()
    if askfor:
        ans = game_init.askfor_all(input_s)
        return ans
    else:
        return input_s
コード例 #12
0
def see_character_main_attr_panel(character_id: int):
    """
    查看角色主属性面板
    Keyword arguments:
    character_id -- 角色Id
    """
    title_1 = text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH,
                                         "1")
    era_print.little_title_print(title_1)
    character_id_text = f"{text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, '0')}{character_id}"
    character_data = cache_contorl.character_data[character_id]
    name = character_data.name
    nick_name = character_data.nick_name
    character_name = (
        text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "13") +
        name)
    character_nick_name = (
        text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "12") +
        nick_name)
    sex = character_data.sex
    sex_text = text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH,
                                          "2") + attr_text.get_sex_text(sex)
    name_text = (character_id_text + " " + character_name + " " +
                 character_nick_name + " " + sex_text)
    hp_bar = attr_print.get_hp_or_mp_bar(character_id, "HitPoint",
                                         game_config.text_width / 2 - 4)
    era_print.list_print([name_text, hp_bar], 2, "center")
    era_print.line_feed_print()
    state_text = attr_text.get_state_text(character_id)
    mp_bar = attr_print.get_hp_or_mp_bar(character_id, "ManaPoint",
                                         game_config.text_width / 2 - 4)
    era_print.list_print([state_text, mp_bar], 2, "center")
    era_print.line_feed_print()
    era_print.little_line_print()
    stature_text = attr_text.get_stature_text(character_id)
    era_print.line_feed_print(stature_text)
    era_print.restart_line_print(".")
    era_print.list_print(
        [
            attr_text.get_character_dormitory_path_text(character_id),
            attr_text.get_character_classroom_path_text(character_id),
            attr_text.get_character_officeroom_path_text(character_id),
        ],
        3,
        "center",
    )
    era_print.little_line_print()
    character_species = f"{text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, '15')}{character_data.species}"
    character_age = f"{text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, '3')}{character_data.age}"
    birthday_text = f"{text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH,'140')}{character_data.birthday['month']}{text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH,'60')}{character_data.birthday['day']}{text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH,'61')}"
    era_print.list_print([character_species, character_age, birthday_text], 3,
                         "center")
    era_print.restart_line_print(".")
    character_intimate = f"{text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, '16')}{character_data.intimate}"
    character_graces = f"{text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, '17')}{character_data.graces}"
    era_print.list_print([character_intimate, character_graces], 2, "center")
    era_print.restart_line_print(".")
    character_chest = character_data.chest["NowChest"]
    chest_group = attr_calculation.judge_chest_group(character_chest)
    chest_text = (
        text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "141") +
        text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH,
                                   "142")[chest_group])
    era_print.list_print([chest_text], 1, "center")
    era_print.restart_line_print(".")
    character_height = character_data.height["NowHeight"]
    character_weight = character_data.weight
    character_height_text = str(round(character_height, 2))
    character_weight_text = str(round(character_weight, 2))
    character_height_info = (
        text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "80") +
        character_height_text)
    character_weight_info = (
        text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "81") +
        character_weight_text)
    era_print.list_print([character_height_info, character_weight_info], 2,
                         "center")
    era_print.restart_line_print(".")
    character_measurements = character_data.measurements
    character_bust = str(round(character_measurements["Bust"], 2))
    character_waist = str(round(character_measurements["Waist"], 2))
    character_hip = str(round(character_measurements["Hip"], 2))
    character_bust_info = (
        text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "82") +
        character_bust)
    character_waist_info = (
        text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "83") +
        character_waist)
    character_hip_info = (
        text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "84") +
        character_hip)
    era_print.list_print(
        [character_bust_info, character_waist_info, character_hip_info],
        3,
        "center",
    )
    era_print.restart_line_print(".")
コード例 #13
0
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
コード例 #14
0
def cook(food_data: Dict[str, Food], recipe_id: int, cook_level: str,
         maker: str) -> Food:
    """
    按食谱烹饪食物
    Keyword arguments:
    food_data -- 食材数据
    recipe_id -- 菜谱id
    cook_level -- 烹饪技能等级
    maker -- 制作者
    Return arguments:
    Food -- 食物对象
    """
    recipe = cache_contorl.recipe_data[recipe_id]
    cook_judge = True
    feel_data = {}
    quality_data = text_loading.get_text_data(
        constant.FilePath.ATTR_TEMPLATE_PATH,
        "FoodQualityWeight")[str(cook_level)]
    now_quality = int(value_handle.get_random_for_weight(quality_data))
    now_weight = 0
    for food in recipe.base:
        if food not in food_data:
            cook_judge = False
            break
        now_food = food_data[food]
        rand_weight = random.randint(75, 125)
        if now_food.weight < rand_weight:
            cook_judge = False
            break
        for feel in now_food.feel:
            feel_data.setdefault(feel, 0)
            feel_data[feel] += (now_food.feel[feel] / now_food.weight *
                                rand_weight)
        now_food.weight -= rand_weight
        now_weight += rand_weight
    if not cook_judge:
        return create_food("KitchenWaste", now_quality, now_weight, [])
    for food in recipe.ingredients:
        if food not in food_data:
            cook_judge = False
            break
        now_food = food_data[food]
        rand_weight = random.randint(25, 75)
        if now_food.weight < rand_weight:
            cook_judge = False
            break
        for feel in now_food.feel:
            feel_data.setdefault(feel, 0)
            feel_data[feel] += (now_food.feel[feel] / now_food.weight *
                                rand_weight)
        now_food.weight -= rand_weight
        now_weight += rand_weight
    if not cook_judge:
        return create_food("KitchenWaste", now_quality, now_weight, [])
    for food in recipe.seasoning:
        if food not in food_data:
            cook_judge = False
            break
        now_food = food_data[food]
        rand_weight = random.randint(3, 7)
        if now_food.weight < rand_weight:
            cook_judge = False
            break
        for feel in now_food.feel:
            feel_data.setdefault(feel, 0)
            now_feel_num = now_food.feel[feel] / now_food.weight * rand_weight
            feel_data[feel] += now_feel_num
            now_food.feel[feel] -= now_feel_num
        now_food.weight -= rand_weight
        now_weight += rand_weight
    if not cook_judge:
        return create_food("KitchenWaste", now_quality, now_weight, [])
    return create_food("", now_quality, now_weight, feel_data, maker,
                       recipe_id)
コード例 #15
0
from Script.Core import (
    text_loading,
    era_print,
    cache_contorl,
    game_config,
    constant,
)
from Script.Design import proportional_bar

point_text_data = {
    "HitPoint":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "8"),
    "ManaPoint":
    text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "9"),
}


def print_hp_and_mp_bar(character_id: str):
    """
    绘制角色的hp和mp(有比例图),自动居中处理,结尾换行
    Keyword arguments:
    character_id -- 角色id
    """
    hp_bar = get_hp_or_mp_bar(character_id, "HitPoint",
                              game_config.text_width / 2 - 4)
    mp_bar = get_hp_or_mp_bar(character_id, "ManaPoint",
                              game_config.text_width / 2 - 4)
    era_print.line_feed_print()
    era_print.list_print([hp_bar, mp_bar], 2, "center")
    era_print.line_feed_print()
コード例 #16
0
ファイル: character.py プロジェクト: miswanting/dieloli
def init_attr(character_data: game_type.Character):
    """
    初始化角色属性
    Keyword arguments:
    character_data -- 角色对象
    """
    character_data.language[character_data.mother_tongue] = 10000
    character_data.birthday = attr_calculation.get_rand_npc_birthday(
        character_data.age)
    character_data.end_age = attr_calculation.get_end_age(character_data.sex)
    character_data.height = attr_calculation.get_height(
        character_data.sex, character_data.age)
    bmi = attr_calculation.get_bmi(character_data.weigt_tem)
    character_data.weight = attr_calculation.get_weight(
        bmi, character_data.height["NowHeight"])
    character_data.bodyfat = attr_calculation.get_bodyfat(
        character_data.sex, character_data.bodyfat_tem)
    character_data.measurements = attr_calculation.get_measurements(
        character_data.sex,
        character_data.height["NowHeight"],
        character_data.weight,
        character_data.bodyfat,
        character_data.bodyfat_tem,
    )
    character_data.sex_experience = attr_calculation.get_sex_experience(
        character_data.sex_experience_tem)
    character_data.sex_grade = attr_calculation.get_sex_grade(
        character_data.sex_experience)
    default_clothing_data = clothing.creator_suit(character_data.clothing_tem,
                                                  character_data.sex)
    character_data.clothing = {
        clothing: {
            uuid.uuid1(): default_clothing_data[clothing]
        } if clothing in default_clothing_data else {}
        for clothing in character_data.clothing
    }
    character_data.chest = attr_calculation.get_chest(character_data.chest_tem,
                                                      character_data.birthday)
    character_data.hit_point_max = attr_calculation.get_max_hit_point(
        character_data.hit_point_tem)
    character_data.hit_point = character_data.hit_point_max
    character_data.mana_point_max = attr_calculation.get_max_mana_point(
        character_data.mana_point_tem)
    character_data.mana_point = character_data.mana_point_max
    character_data.nature = nature.get_random_nature()
    character_data.status = text_loading.get_game_data(
        constant.FilePath.CHARACTER_STATE_PATH)
    character_data.wear_item = {
        "Wear": {
            key: {}
            for key in text_loading.get_game_data(
                constant.FilePath.WEAR_ITEM_PATH)["Wear"]
        },
        "Item": {},
    }
    character_data.engraving = {
        "Pain": 0,
        "Happy": 0,
        "Yield": 0,
        "Fear": 0,
        "Resistance": 0,
    }
    character_data.social_contact = {
        social: {}
        for social in text_loading.get_text_data(
            constant.FilePath.STAGE_WORD_PATH, "144")
    }
    init_class(character_data)
    put_on_clothing(character_data)
    if character_data.occupation == "":
        if character_data.age <= 18:
            character_data.occupation = "Student"
        else:
            character_data.occupation = "Teacher"
コード例 #17
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
コード例 #18
0
def see_attr_on_every_time_func():
    """
    通用用于查看角色属性的流程
    """
    while True:
        character_id = cache_contorl.character_data[0].target_character_id
        if cache_contorl.old_flow_id == "in_scene":
            now_scene = cache_contorl.character_data[0].position
            now_scene_str = map_handle.get_map_system_path_str_for_list(
                now_scene
            )
            character_id_list = map_handle.get_scene_character_id_list(
                now_scene_str
            )
        else:
            character_id_list = list(cache_contorl.character_data.keys())
        character_id_index = character_id_list.index(character_id)
        input_s = []
        see_attr_in_every_time_func()
        ask_see_attr = see_character_attr_panel.ask_for_see_attr()
        input_s += ask_see_attr
        inputs_1 = see_character_attr_panel.ask_for_see_attr_cmd()
        input_s += inputs_1
        yrn = game_init.askfor_all(input_s)
        py_cmd.clr_cmd()
        show_attr_handle_data = text_loading.get_text_data(
            constant.FilePath.CMD_PATH, "seeAttrPanelHandle"
        )
        character_max = character_id_list[len(character_id_list) - 1]
        if yrn in show_attr_handle_data:
            cache_contorl.panel_state["AttrShowHandlePanel"] = yrn
        elif yrn == "0":
            if character_id_index == 0:
                cache_contorl.character_data[
                    0
                ].target_character_id = character_max
            else:
                character_id = character_id_list[character_id_index - 1]
                cache_contorl.character_data[
                    0
                ].target_character_id = character_id
        elif yrn == "1":
            if cache_contorl.old_flow_id == "main":
                cache_contorl.character_data[0].target_character_id = 0
            elif cache_contorl.old_flow_id == "see_character_list":
                character_list_show = int(game_config.character_list_show)
                now_page_id = character_id_index / character_list_show
                cache_contorl.panel_state[
                    "SeeCharacterListPanel"
                ] = now_page_id
            elif cache_contorl.old_flow_id == "in_scene":
                scene_path = cache_contorl.character_data[0].position
                scene_path_str = map_handle.get_map_system_path_str_for_list(
                    scene_path
                )
                name_list = map_handle.get_scene_character_name_list(
                    scene_path_str, True
                )
                now_character_name = cache_contorl.character_data[
                    cache_contorl.character_data[0].target_character_id
                ].name
                try:
                    now_character_index = name_list.index(now_character_name)
                except ValueError:
                    now_character_index = 0
                name_list_max = int(game_config.in_scene_see_player_max)
                now_scene_character_list_page = math.floor(
                    now_character_index / name_list_max
                )
                cache_contorl.panel_state[
                    "SeeSceneCharacterListPanel"
                ] = now_scene_character_list_page
            cache_contorl.panel_state["AttrShowHandlePanel"] = "MainAttr"
            cache_contorl.now_flow_id = cache_contorl.old_flow_id
            cache_contorl.old_flow_id = cache_contorl.too_old_flow_id
            break
        elif yrn == "2":
            if character_id == character_max:
                character_id = character_id_list[0]
                cache_contorl.character_data[
                    0
                ].target_character_id = character_id
            else:
                character_id = character_id_list[character_id_index + 1]
                cache_contorl.character_data[
                    0
                ].target_character_id = character_id
コード例 #19
0
ファイル: game_time.py プロジェクト: yodamaster122/dieloli
def judge_school_course_time(school_id: str) -> dict:
    """
    校验当前时间是否是学校上课时间
    Keyword arguments:
    school_id -- 学校Id
    Return arguments:
    dict:{
        "InCourse":int 当前是否是上课时间
        "ToCourse":int 当前距离下节课开始所需的时间
        "EndCourse":int 当前距离下课时间所需的时间
        "TimeSlice":int 当前时间所属时间段
    }
    """
    course_status = {
        "InCourse": 0,
        "ToCourse": 0,
        "EndCourse": 0,
        "TimeSlice": 0,
    }
    course_time_data = text_loading.get_text_data(
        constant.FilePath.COURSE_SESSION_PATH, school_id
    )
    now_time = (
        cache_contorl.game_time["hour"] * 100
        + cache_contorl.game_time["minute"]
    )
    end_time_data = {
        course_time_data[i][1]: i for i in range(len(course_time_data))
    }
    now_time_index = bisect.bisect_left(list(end_time_data.keys()), now_time)
    if now_time_index >= len(end_time_data):
        course_status["TimeSlice"] = TIME_SLEEP
        return course_status
    start_time = course_time_data[now_time_index][0]
    end_time = course_time_data[now_time_index][1]
    if now_time < start_time:
        if start_time / 100 != now_time / 100:
            index_time = (start_time / 100 - now_time / 100) * 60
            course_status["ToCourse"] = (
                start_time
                - (start_time / 100 - now_time / 100) * 100
                + index_time
                - now_time
            )
        else:
            course_status["ToCourse"] = start_time - now_time
        course_status["TimeSlice"] = constant.TimeSlice.TIME_BREAKFAST
    else:
        course_status["InCourse"] = 1
        if end_time / 100 != now_time / 100:
            index_time = (end_time / 100 - now_time / 100) * 60
            course_status["EndCourse"] = (
                end_time
                - (end_time / 100 - now_time / 100) * 100
                + index_time
                - now_time
            )
        else:
            course_status["EndCourse"] = end_time - now_time
        course_status["TimeSlice"] = constant.TimeSlice.TIME_IN_CLASS
        if now_time < course_time_data[0][1]:
            course_status["TimeSlice"] = constant.TimeSlice.TIME_EARLY_READING
    return course_status
コード例 #20
0
ファイル: instruct_panel.py プロジェクト: miswanting/dieloli
        text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "147"))
    return cmd_button_queue.option_str(
        None,
        len(instruct_data),
        "center",
        False,
        False,
        list(instruct_data.values()),
        "",
        list(instruct_data.keys()),
        style_data,
        on_style_data,
    )


instruct_data = text_loading.get_text_data(constant.FilePath.CMD_PATH,
                                           constant.CmdMenu.INSTRUCT_PANEL)
instruct_text_data = {
    instruct: instruct_data[instruct_type][instruct]
    for instruct_type in instruct_data
    for instruct in instruct_data[instruct_type]
}
instruct_cmd_id_data = {
    list(instruct_text_data.keys())[i]: i
    for i in range(len(instruct_text_data))
}
instruct_id_cmd_data = {
    instruct_cmd_id_data[instruct]: instruct
    for instruct in instruct_cmd_id_data
}

コード例 #21
0
from Script.Core import (
    cache_contorl,
    text_loading,
    era_print,
    py_cmd,
    constant,
)
from Script.Design import map_handle, cmd_button_queue

panel_state_text_data = text_loading.get_text_data(constant.FilePath.CMD_PATH,
                                                   "cmdSwitch")
panel_state_on_text = panel_state_text_data[1]
panel_state_off_text = panel_state_text_data[0]


def see_map_panel() -> list:
    """
    地图绘制面板
    """
    input_s = []
    title_text = text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH,
                                            "78")
    now_map = cache_contorl.now_map
    now_map_map_system_str = map_handle.get_map_system_path_str_for_list(
        now_map)
    map_name = cache_contorl.map_data[now_map_map_system_str]["MapName"]
    era_print.little_title_print(title_text + ": " + map_name + " ")
    input_s = input_s + map_handle.print_map(now_map)
    return input_s

コード例 #22
0
 def init_attr(self):
     """
     随机生成角色属性
     """
     self.language[self.mother_tongue] = 10000
     self.birthday = attr_calculation.get_rand_npc_birthday(self.age)
     self.end_age = attr_calculation.get_end_age(self.sex)
     self.height = attr_calculation.get_height(self.sex, self.age, {})
     bmi = attr_calculation.get_bmi(self.weigt_tem)
     self.weight = attr_calculation.get_weight(
         bmi, self.height["NowHeight"]
     )
     self.bodyfat = attr_calculation.get_bodyfat(self.sex, self.bodyfat_tem)
     self.measurements = attr_calculation.get_measurements(
         self.sex,
         self.height["NowHeight"],
         self.weight,
         self.bodyfat,
         self.bodyfat_tem,
     )
     self.sex_experience = attr_calculation.get_sex_experience(
         self.sex_experience_tem
     )
     self.sex_grade = attr_calculation.get_sex_grade(self.sex_experience)
     default_clothing_data = clothing.creator_suit(
         self.clothing_tem, self.sex
     )
     self.clothing = {
         clothing: {uuid.uuid1(): default_clothing_data[clothing]}
         if clothing in default_clothing_data
         else {}
         for clothing in self.clothing
     }
     self.chest = attr_calculation.get_chest(self.chest_tem, self.birthday)
     self.hit_point_max = attr_calculation.get_max_hit_point(
         self.hit_point_tem
     )
     self.hit_point = self.hit_point_max
     self.mana_point_max = attr_calculation.get_max_mana_point(
         self.mana_point_tem
     )
     self.mana_point = self.mana_point_max
     self.nature = nature.get_random_nature()
     self.status = text_loading.get_game_data(
         constant.FilePath.CHARACTER_STATE_PATH
     )
     self.wear_item = {
         "Wear": {
             key: {}
             for key in text_loading.get_game_data(
                 constant.FilePath.WEAR_ITEM_PATH
             )["Wear"]
         },
         "Item": {},
     }
     self.engraving = {
         "Pain": 0,
         "Happy": 0,
         "Yield": 0,
         "Fear": 0,
         "Resistance": 0,
     }
     self.social_contact = {
         social: {}
         for social in text_loading.get_text_data(
             constant.FilePath.STAGE_WORD_PATH, "144"
         )
     }
     self.init_class()
     self.put_on_clothing()