def get_max_mana_point(tem_id: int) -> int: """ 获取最大mp值 Keyword arguments: tem_id -- mp模板 Return arguments: int -- 最大mp值 """ tem_data = game_config.config_manapoint_tem[tem_id] max_mana_point = tem_data.max_value add_value = value_handle.get_gauss_rand(0, 500) impairment = value_handle.get_gauss_rand(0, 500) return max_mana_point + add_value - impairment
def init_character_interest(): """ 初始化全部角色兴趣/精力/天赋数值分配 """ language_skills = list(game_config.config_language.keys()) knowledge_skills = list(game_config.config_knowledge.keys()) for character in cache.character_data: numpy.random.shuffle(knowledge_skills) numpy.random.shuffle(language_skills) for knowledge in knowledge_skills: cache.character_data[character].knowledge_interest[ knowledge] = value_handle.get_gauss_rand(0.5, 1.5) for language in language_skills: cache.character_data[character].language_interest[ language] = value_handle.get_gauss_rand(0.5, 1.5)
def get_chest(chest_tem: int, birthday: datetime.datetime) -> game_type.Chest: """ 按罩杯模板生成人物最终胸围差,并按人物年龄计算当前胸围差 Keyword arguments: chest_tem -- 罩杯模板 birthday -- 出生日期 Return arguments: game_type.Chest -- 胸围数据 """ target_chest = get_rand_npc_chest(chest_tem) over_age = int(value_handle.get_gauss_rand(14, 18)) over_year = birthday.year + over_age end_date = game_time.get_rand_day_for_year(over_year) now_date = cache.game_time end_day = game_time.count_day_for_datetime(birthday, end_date) now_day = game_time.count_day_for_datetime(birthday, now_date) sub_chest = target_chest / end_day now_chest = sub_chest * now_day if now_chest > target_chest: now_chest = target_chest chest = game_type.Chest() chest.now_chest = now_chest chest.sub_chest = sub_chest chest.target_chest = target_chest return chest
def get_height(tem_name: int, age: int) -> game_type.Height: """ 按模板和年龄计算身高 Keyword arguments: tem_name -- 人物生成模板(性别id) age -- 人物年龄 """ tem_data = game_config.config_height_tem_sex_data[tem_name] initial_height = value_handle.get_gauss_rand(tem_data.min_value, tem_data.max_value) if tem_name in {0, 3}: expect_age = random.randint(18, 22) expect_height = initial_height / 0.2949 else: expect_age = random.randint(13, 17) expect_height = initial_height / 0.3109 development_age = random.randint(4, 6) growth_height_data = get_growth_height(age, expect_height, development_age, expect_age) growth_height = growth_height_data["GrowthHeight"] now_height = growth_height_data["NowHeight"] if now_height >= expect_height: now_height = expect_height height_data = game_type.Height() height_data.now_height = now_height height_data.growth_height = growth_height height_data.expect_age = expect_age height_data.development_age = development_age height_data.expect_height = expect_height return height_data
def get_end_age(sex: int) -> int: """ 按照性别模板随机生成预期寿命 Keyword arguments: sex -- 性别 """ tem_value = game_config.config_end_age_tem_sex_data[sex] return value_handle.get_gauss_rand(int(tem_value * 0.5), int(tem_value * 1.5))
def get_rand_npc_chest(chest_tem: int) -> int: """ 随机获取模板对应罩杯 Keyword arguments: chest_tem -- 罩杯模板 """ chest_scope = game_config.config_chest[chest_tem] return value_handle.get_gauss_rand(chest_scope.min_value, chest_scope.max_value)
def get_bmi(tem_name: int) -> float: """ 按体重比例模板生成BMI Keyword arguments: tem_name -- 体重比例模板id Return arguments: int -- bmi值 """ tem_data = game_config.config_weight_tem[tem_name] return value_handle.get_gauss_rand(tem_data.min_value, tem_data.max_value)
def init_attr(character_id: int): """ 初始化角色属性 Keyword arguments: character_id -- 角色id """ character_data: game_type.Character = cache.character_data[character_id] 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.weight_tem) character_data.weight = attr_calculation.get_weight( bmi, character_data.height.now_height) character_data.bodyfat = attr_calculation.get_body_fat( character_data.sex, character_data.bodyfat_tem) character_data.measurements = attr_calculation.get_measurements( character_data.sex, character_data.height.now_height, 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) default_clothing_data = clothing.creator_suit(character_data.clothing_tem, character_data.sex) for clothing_id in default_clothing_data: clothing_data = default_clothing_data[clothing_id] character_data.clothing.setdefault(clothing_id, {}) character_data.clothing[clothing_id][clothing_data.uid] = clothing_data character_data.clothing_data.setdefault(clothing_data.tem_id, set()) character_data.clothing_data[clothing_data.tem_id].add( clothing_data.uid) chest_tem_config = game_config.config_chest[character_data.chest_tem] if chest_tem_config.weight_fix: fix_weight = value_handle.get_gauss_rand( chest_tem_config.weight_fix - 0.5, chest_tem_config.weight_fix + 0.5) character_data.weight += fix_weight 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 new_nature = nature.get_random_nature() for nature_id in new_nature: if nature_id not in character_data.nature: character_data.nature[nature_id] = new_nature[nature_id] init_class(character_data)
def get_measurements( tem_name: int, height: float, weight: float, bodyfat: float, weight_tem: int, ) -> dict: """ 计算角色三围 Keyword arguments: tem_name -- 性别模板 height -- 身高 weight -- 体重 bodyfat -- 体脂率 weight_tem -- 体重比例模板 """ fix = 0 if not weight_tem: fix = -5 elif weight_tem > 1: fix = 5 * (weight_tem - 1) if tem_name in {0, 3}: bust = value_handle.get_gauss_rand(0.4676, 0.5676) * height + fix waist = value_handle.get_gauss_rand(0.3779, 0.4779) * height + fix hip = value_handle.get_gauss_rand(0.4707, 0.5707) * height + fix else: bust = value_handle.get_gauss_rand(0.4735, 0.5735) * height + fix waist = value_handle.get_gauss_rand(0.3634, 0.4634) * height + fix hip = value_handle.get_gauss_rand(0.5278, 0.6278) * height + fix measurements = game_type.Measurements() measurements.bust = bust measurements.waist = waist measurements.hip = hip return measurements
def get_body_fat(sex: int, tem_name: int) -> float: """ 按性别和体脂率模板生成体脂率 Keyword arguments: sex -- 性别 tem_name -- 体脂率模板id Return arguments: float -- 体脂率 """ sex_tem = sex in (0, 3) tem_data_id = game_config.config_body_fat_tem_data[sex_tem][tem_name] tem_data = game_config.config_body_fat_tem[tem_data_id] return value_handle.get_gauss_rand(tem_data.min_value, tem_data.max_value)