Ejemplo n.º 1
0
def init_name_region(name_data: Dict[str, int], man_judge: int):
    """
    初始化性别名字随机权重
    Keyword arguments:
    name_data -- 名字数据
    man_judge -- 类型校验(0:男,1:女,2:姓)
    """
    region_list = value_handle.get_region_list(name_data)
    if man_judge == 0:
        cache_contorl.boys_region_list = region_list
        cache_contorl.boys_region_int_list = list(map(int, region_list))
    elif man_judge == 1:
        cache_contorl.girls_region_list = region_list
        cache_contorl.girls_region_int_list = list(map(int, region_list))
    else:
        cache_contorl.family_region_list = region_list
        cache_contorl.family_region_int_list = list(map(int, region_list))
Ejemplo n.º 2
0
        new_npc_data.BodyFat = dir_data["BodyFat"]
    if "Chest" in dir_data:
        new_npc_data.Chest = dir_data["Chest"]
    if "MotherTongue" in dir_data:
        new_npc_data.MotherTongue = dir_data["MotherTongue"]
    return new_npc_data


random_npc_max = int(game_config.random_npc_max)
random_teacher_proportion = int(game_config.proportion_teacher)
random_student_proportion = int(game_config.proportion_student)
age_weight_data = {
    "Teacher": random_teacher_proportion,
    "Student": random_student_proportion,
}
age_weight_regin_data = value_handle.get_region_list(age_weight_data)
age_weight_regin_list = list(map(int, age_weight_regin_data.keys()))
age_weight_max = sum(
    [int(age_weight_data[age_weight]) for age_weight in age_weight_data])


def init_random_npc_data() -> list:
    """
    生成所有随机npc的数据模板
    """
    cache_contorl.random_npc_list = []
    for i in range(random_npc_max):
        create_random_npc(i)


def create_random_npc(id) -> dict:
Ejemplo n.º 3
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()