def initPhaseCourseHour(): ''' 初始化各班级课时 ''' phaseCourseTime = TextLoading.getTextData(TextLoading.phaseCourse, 'CourseTime') primaryWeight = TextLoading.getTextData(TextLoading.phaseCourse, 'PrimarySchool') juniorMiddleWeight = TextLoading.getTextData(TextLoading.phaseCourse, 'JuniorMiddleSchool') seniorHighWeight = TextLoading.getTextData(TextLoading.phaseCourse, 'SeniorHighSchool') nowWeightList = primaryWeight + juniorMiddleWeight + seniorHighWeight allClassHourData = {} phaseIndex = 0 for phase in nowWeightList: phaseWeightRegin = ValueHandle.getReginList(phase) weightMax = 0 weightMax = sum(map(int, phaseWeightRegin.keys())) classHourData = {} classHourMax = 0 if phaseIndex <= 5: classHourMax = phaseCourseTime['PrimarySchool'] elif phaseIndex <= 8: classHourMax = phaseCourseTime['JuniorMiddleSchool'] else: classHourMax = phaseCourseTime['SeniorHighSchool'] classHourData = { phaseWeightRegin[region]: math.ceil(classHourMax * (int(region) / weightMax)) for region in phaseWeightRegin } nowClassHourMax = sum(classHourData.values()) while nowClassHourMax != classHourMax: for course in classHourData: if nowClassHourMax == classHourMax: break elif classHourData[ course] > 1 and nowClassHourMax > classHourMax: classHourData[course] -= 1 nowClassHourMax -= 1 elif nowClassHourMax < classHourMax: classHourData[course] += 1 nowClassHourMax += 1 while 1: moreHour = 0 for course in classHourData: if moreHour > 0 and classHourData[course] < 14: classHourData[course] += 1 moreHour -= 1 elif moreHour > 0 and classHourData[course] > 14: moreHour += (classHourData[course] - 14) classHourData[course] -= (classHourData[course] - 14) if moreHour == 0: break allClassHourData[phaseIndex] = classHourData phaseIndex += 1 CacheContorl.courseData['ClassHour'] = allClassHourData initPhaseCourseHourExperience()
def initNameRegion(nameData:dict,manJudge:int): ''' 初始化性别名字随机权重 Keyword arguments: nameData -- 名字数据 manJudge -- 类型校验(0:男,1:女,2:姓) ''' regionList = ValueHandle.getReginList(nameData) if manJudge == 0: CacheContorl.boysRegionList = regionList CacheContorl.boysRegionIntList = list(map(int,regionList)) elif manJudge == 1: CacheContorl.girlsRegionList = regionList CacheContorl.girlsRegionIntList = list(map(int,regionList)) else: CacheContorl.familyRegionList = regionList CacheContorl.familyRegionIntList = list(map(int,regionList))
# 获取目录中的角色模板 def getDirCharacterTem(character): characterAttrTemPath = os.path.join(characterListPath, character, 'AttrTemplate.json') return GameData._loadjson(characterAttrTemPath) randomNpcMax = int(GameConfig.random_npc_max) randomTeacherProportion = int(GameConfig.proportion_teacher) randomStudentProportion = int(GameConfig.proportion_student) ageWeightData = { "Teacher": randomTeacherProportion, "Student": randomStudentProportion } ageWeightReginData = ValueHandle.getReginList(ageWeightData) ageWeightReginList = ValueHandle.getListKeysIntList( list(ageWeightReginData.keys())) # 获取随机npc数据 def getRandomNpcData(): if CacheContorl.randomNpcList == []: ageWeightMax = 0 for i in ageWeightData: ageWeightMax += int(ageWeightData[i]) for i in range(0, randomNpcMax): nowAgeWeight = random.randint(0, ageWeightMax - 1) nowAgeWeightRegin = ValueHandle.getNextValueForList( nowAgeWeight, ageWeightReginList) ageWeightTem = ageWeightReginData[str(nowAgeWeightRegin)]
language = GameConfig.language gamepath = GamePathConfig.gamepath roleAttrPath = os.path.join(gamepath,'data',language,'RoleAttributes.json') roleAttrData = GameData._loadjson(roleAttrPath) sexData = roleAttrData['Sex'] equipmentPath = os.path.join(gamepath,'data',language,'Equipment.json') equipmentData = GameData._loadjson(equipmentPath) boysNameListData = TextLoading.getTextData(TextLoading.nameListPath,'Boys') girlsNameListData = TextLoading.getTextData(TextLoading.nameListPath,'Girls') familyNameListData = TextLoading.getTextData(TextLoading.familyNameListPath,'FamilyNameList') boysNameMax = len(boysNameListData) girlsNameMax = len(girlsNameListData) sortFamilyIndex = sorted(familyNameListData.items(),key=lambda x:x[1]) familyRegionList = ValueHandle.getReginList(familyNameListData) boysRegionList = ValueHandle.getReginList(boysNameListData) girlsRegionList = ValueHandle.getReginList(girlsNameListData) familyRegionIntList = ValueHandle.getListKeysIntList(familyRegionList) boysRegionIntList = ValueHandle.getListKeysIntList(boysRegionList) girlsRegionIntList = ValueHandle.getListKeysIntList(girlsRegionList) #获取性经验文本 def getSexExperienceText(sexList,sexName): mouthExperience = TextLoading.getTextData(TextLoading.stageWordPath,'19') + str(sexList['mouthExperience']) bosomExperience = TextLoading.getTextData(TextLoading.stageWordPath,'20') + str(sexList['bosomExperience']) vaginaExperience = TextLoading.getTextData(TextLoading.stageWordPath,'21') + str(sexList['vaginaExperience']) clitorisExperience = TextLoading.getTextData(TextLoading.stageWordPath,'22') + str(sexList['clitorisExperience']) anusExperience = TextLoading.getTextData(TextLoading.stageWordPath,'23') + str(sexList['anusExperience']) penisExperience = TextLoading.getTextData(TextLoading.stageWordPath,'24') + str(sexList['penisExperience'])