def detailedSetting_func1(): flowRetun = CreatorCharacterPanel.detailedSetting1Panel() characterSex = CacheContorl.characterData['character']['0']['Sex'] sexList = list(TextLoading.getTextData(TextLoading.rolePath, 'Sex')) if flowRetun == 0: CacheContorl.featuresList['Age'] = featuresList["Age"][3] elif flowRetun == 4: if characterSex == sexList[0]: CacheContorl.featuresList['Age'] = featuresList["Age"][0] elif characterSex == sexList[1]: CacheContorl.featuresList['Age'] = featuresList["Age"][1] else: CacheContorl.featuresList['Age'] = featuresList["Age"][2] PyCmd.clr_cmd() CacheContorl.temporaryCharacter['Features'] = CacheContorl.featuresList.copy() characterAgeTemName = AttrCalculation.getAgeTemList()[flowRetun] characterAge = AttrCalculation.getAge(characterAgeTemName) characterTem = characterSex characterHeigt = AttrCalculation.getHeight(characterTem,characterAge,CacheContorl.temporaryCharacter['Features']) characterBmi = AttrCalculation.getBMI('Ordinary') characterWeight = AttrCalculation.getWeight(characterBmi,characterHeigt['NowHeight']) characterBodyFat = AttrCalculation.getBodyFat(characterSex,'Ordinary') characterMeasurements = AttrCalculation.getMeasurements(characterSex,characterHeigt['NowHeight'],characterWeight,characterBodyFat,'Ordinary') CacheContorl.temporaryCharacter['Age'] = characterAge CacheContorl.temporaryCharacter['Height'] = characterHeigt CacheContorl.temporaryCharacter['Weight'] = characterWeight CacheContorl.temporaryCharacter['BodyFat'] = characterBodyFat CacheContorl.temporaryCharacter['Measurements'] = characterMeasurements PyCmd.clr_cmd() detailedSetting_func2()
def detailedSetting_func1(): ''' 询问玩家年龄模板流程 ''' flowRetun = CreatorCharacterPanel.detailedSetting1Panel() characterSex = CacheContorl.characterData['character'][0].Sex sexList = list(TextLoading.getTextData(TextLoading.rolePath, 'Sex')) characterAgeTemName = AttrCalculation.getAgeTemList()[flowRetun] CacheContorl.characterData['character'][0].Age = AttrCalculation.getAge(characterAgeTemName) PyCmd.clr_cmd() detailedSetting_func3()
def initCharacter(characterId: int, character: dict): ''' 按id生成角色属性 Keyword arguments: characterId -- 角色id character -- 角色生成模板数据 ''' nowCharacter = Character.Character() nowCharacter.Name = character['Name'] nowCharacter.Sex = character['Sex'] if 'MotherTongue' in character: nowCharacter.MotherTongue = character['MotherTongue'] if 'Age' in character: nowCharacter.Age = AttrCalculation.getAge(character['Age']) if 'Weight' in character: nowCharacter.WeigtTem = character['Weight'] if 'BodyFat' in character: nowCharacter.BodyFatTem = character['BodyFat'] else: nowCharacter.BodyFatTem = nowCharacter.WeigtTem nowCharacter.initAttr() CacheContorl.characterData['character'][characterId] = nowCharacter
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()