def inputSexConfirm_func(): ''' 请求玩家输入性别流程 输入0:进入询问是否进行详细设置流程(玩家性别为默认,或请求选择性别流程结果) 输入1:进入选择性别流程 输入2:返回请求输入自称流程 ''' flowReturn = CreatorCharacterPanel.inputSexPanel() sexId = CacheContorl.characterData['character'][characterId]['Sex'] if flowReturn == 0: AttrCalculation.setSexCache(sexId) sexKeysList = list(TextLoading.getTextData(TextLoading.rolePath, 'Sex')) if sexId == sexKeysList[2]: CacheContorl.temporaryCharacter['Features'][ 'Sex'] = TextLoading.getTextData(TextLoading.rolePath, 'Features')['Sex'][0] elif sexId == sexKeysList[3]: CacheContorl.temporaryCharacter['Features'][ 'Sex'] = TextLoading.getTextData(TextLoading.rolePath, 'Features')['Sex'][1] PyCmd.clr_cmd() attributeGenerationBranch_func() elif flowReturn == 1: PyCmd.clr_cmd() inputSexChoice_func() elif flowReturn == 2: PyCmd.clr_cmd() inputSelfName_func()
def inputSexConfirm_func(): flowReturn = CreatorCharacterPanel.inputSexPanel() sexId = CacheContorl.characterData['character'][characterId]['Sex'] if flowReturn == 0: AttrCalculation.setSexCache(sexId) sexKeysList = list(TextLoading.getTextData(TextLoading.rolePath,'Sex')) if sexId == sexKeysList[2]: CacheContorl.temporaryCharacter['Features']['Sex'] = TextLoading.getTextData(TextLoading.rolePath, 'Features')['Sex'][0] elif sexId == sexKeysList[3]: CacheContorl.temporaryCharacter['Features']['Sex'] = TextLoading.getTextData(TextLoading.rolePath, 'Features')['Sex'][1] PyCmd.clr_cmd() attributeGenerationBranch_func() elif flowReturn == 1: PyCmd.clr_cmd() inputSexChoice_func() elif flowReturn == 2: PyCmd.clr_cmd() inputNickName_func()
def initCharacter(nowId, character): AttrCalculation.initTemporaryCharacter() characterId = str(nowId) CacheContorl.characterData['character'][ characterId] = CacheContorl.temporaryCharacter.copy() AttrCalculation.setDefaultCache() characterName = character['Name'] characterSex = character['Sex'] CacheContorl.characterData['character'][characterId]['Sex'] = characterSex defaultAttr = AttrCalculation.getAttr(characterSex) defaultAttr['Name'] = characterName defaultAttr['Sex'] = characterSex AttrCalculation.setSexCache(characterSex) defaultAttr['Features'] = CacheContorl.featuresList.copy() motherTongue = {"Level": 5, "Exp": 0} if 'MotherTongue' in character: defaultAttr['Language'][character['MotherTongue']] = motherTongue defaultAttr['MotherTongue'] = character['MotherTongue'] else: defaultAttr['Language']['Chinese'] = motherTongue if 'Age' in character: ageTem = character['Age'] characterAge = AttrCalculation.getAge(ageTem) defaultAttr['Age'] = characterAge characterAgeFeatureHandle(ageTem, characterSex) defaultAttr['Features'] = CacheContorl.featuresList.copy() elif 'Features' in character: AttrCalculation.setAddFeatures(character['Features']) defaultAttr['Features'] = CacheContorl.featuresList.copy() temList = AttrCalculation.getTemList() if 'Features' in character: height = AttrCalculation.getHeight(characterSex, defaultAttr['Age'], character['Features']) else: height = AttrCalculation.getHeight(characterSex, defaultAttr['Age'], {}) defaultAttr['Height'] = height if 'Weight' in character: weightTemName = character['Weight'] else: weightTemName = 'Ordinary' if 'BodyFat' in character: bodyFatTem = character['BodyFat'] else: bodyFatTem = weightTemName bmi = AttrCalculation.getBMI(weightTemName) weight = AttrCalculation.getWeight(bmi, height['NowHeight']) defaultAttr['Weight'] = weight schoolClassDataPath = os.path.join(gamepath, 'data', language, 'SchoolClass.json') schoolClassData = GameData._loadjson(schoolClassDataPath) if defaultAttr['Age'] <= 18 and defaultAttr['Age'] >= 7: classGradeMax = len(schoolClassData['Class'].keys()) classGrade = str(defaultAttr['Age'] - 6) if int(classGrade) > classGradeMax: classGrade = str(classGradeMax) defaultAttr['Class'] = random.choice( schoolClassData['Class'][classGrade]) else: defaultAttr['Office'] = str(random.randint(0, 12)) bodyFat = AttrCalculation.getBodyFat(characterSex, bodyFatTem) measurements = AttrCalculation.getMeasurements(characterSex, height['NowHeight'], weight, bodyFat, bodyFatTem) defaultAttr['Measirements'] = measurements CacheContorl.temporaryCharacter.update(defaultAttr) CacheContorl.featuresList = {} CacheContorl.characterData['character'][ characterId] = CacheContorl.temporaryCharacter.copy() CacheContorl.temporaryCharacter = CacheContorl.temporaryCharacterBak.copy()
def initCharacter(nowId: int, character: dict): ''' 按id生成角色属性 Keyword arguments: nowId -- 角色id character -- 角色生成模板数据 ''' AttrCalculation.initTemporaryCharacter() characterId = str(nowId) CacheContorl.characterData['character'][ characterId] = CacheContorl.temporaryCharacter.copy() AttrCalculation.setDefaultCache() characterName = character['Name'] characterSex = character['Sex'] CacheContorl.characterData['character'][characterId]['Sex'] = characterSex defaultAttr = AttrCalculation.getAttr(characterSex) defaultAttr['Name'] = characterName defaultAttr['Sex'] = characterSex AttrCalculation.setSexCache(characterSex) defaultAttr['Features'] = CacheContorl.featuresList.copy() if 'MotherTongue' in character: defaultAttr['Language'][character['MotherTongue']] = 10000 defaultAttr['MotherTongue'] = character['MotherTongue'] else: defaultAttr['Language']['Chinese'] = 10000 if 'Age' in character: ageTem = character['Age'] characterAge = AttrCalculation.getAge(ageTem) defaultAttr['Age'] = characterAge characterAgeFeatureHandle(ageTem, characterSex) defaultAttr['Features'] = CacheContorl.featuresList.copy() elif 'Features' in character: AttrCalculation.setAddFeatures(character['Features']) defaultAttr['Features'] = CacheContorl.featuresList.copy() if 'Features' in character: height = AttrCalculation.getHeight(characterSex, defaultAttr['Age'], character['Features']) else: height = AttrCalculation.getHeight(characterSex, defaultAttr['Age'], {}) defaultAttr['Height'] = height if 'Weight' in character: weightTemName = character['Weight'] else: weightTemName = 'Ordinary' if 'BodyFat' in character: bodyFatTem = character['BodyFat'] else: bodyFatTem = weightTemName bmi = AttrCalculation.getBMI(weightTemName) weight = AttrCalculation.getWeight(bmi, height['NowHeight']) defaultAttr['Weight'] = weight if defaultAttr['Age'] <= 18 and defaultAttr['Age'] >= 7: classGrade = str(defaultAttr['Age'] - 6) defaultAttr['Class'] = random.choice( CacheContorl.placeData["Classroom_" + classGrade]) bodyFat = AttrCalculation.getBodyFat(characterSex, bodyFatTem) measurements = AttrCalculation.getMeasurements(characterSex, height['NowHeight'], weight, bodyFat, bodyFatTem) defaultAttr['Measirements'] = measurements defaultAttr['Knowledge'] = {} if "SexExperience" in character: sexExperienceTem = character['SexExperience'] else: sexExperienceTem = getRandNpcSexExperienceTem(defaultAttr['Age'], defaultAttr['Sex']) defaultAttr['SexExperience'] = AttrCalculation.getSexExperience( sexExperienceTem) defaultAttr['SexGrade'] = AttrCalculation.getSexGrade( defaultAttr['SexExperience']) if 'Clothing' in character: clothingTem = character['Clothing'] else: clothingTem = 'Uniform' defaultClothingData = Clothing.creatorSuit(clothingTem, characterSex) for clothing in defaultClothingData: defaultAttr['Clothing'][clothing][ uuid.uuid1()] = defaultClothingData[clothing] CacheContorl.temporaryCharacter.update(defaultAttr) CacheContorl.featuresList = {} CacheContorl.characterData['character'][ characterId] = CacheContorl.temporaryCharacter.copy() Clothing.characterPutOnClothing(characterId) CacheContorl.temporaryCharacter = CacheContorl.temporaryCharacterBak.copy()