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_func8(): flowReturn = CreatorCharacterPanel.detailedSetting8Panel() weightTemData = TextLoading.getTextData(TextLoading.attrTemplatePath,'WeightTem') weightTemList = ValueHandle.dictKeysToList(weightTemData) weightTem = weightTemList[int(flowReturn)] characterHeight = CacheContorl.temporaryCharacter['Height'] characterBmi = AttrCalculation.getBMI(weightTem) characterWeight = AttrCalculation.getWeight(characterBmi, characterHeight['NowHeight']) characterSex = CacheContorl.temporaryCharacter['Sex'] characterBodyFat = AttrCalculation.getBodyFat(characterSex,weightTem) characterMeasurements = AttrCalculation.getMeasurements(characterSex, characterHeight['NowHeight'], characterWeight,characterBodyFat,weightTem) CacheContorl.temporaryCharacter['Weight'] = characterWeight CacheContorl.temporaryCharacter['BodyFat'] = characterBodyFat CacheContorl.temporaryCharacter['Measurements'] = characterMeasurements SeeCharacterAttr.acknowledgmentAttribute_func()
def detailedSetting_func8(): ''' 询问玩家肥胖程度流程 ''' flowReturn = CreatorCharacterPanel.detailedSetting8Panel() weightTemData = TextLoading.getTextData(TextLoading.attrTemplatePath, 'WeightTem') weightTemList = list(weightTemData.keys()) weightTem = weightTemList[int(flowReturn)] characterHeight = CacheContorl.temporaryCharacter['Height'] characterBmi = AttrCalculation.getBMI(weightTem) characterWeight = AttrCalculation.getWeight(characterBmi, characterHeight['NowHeight']) characterSex = CacheContorl.temporaryCharacter['Sex'] characterBodyFat = AttrCalculation.getBodyFat(characterSex, weightTem) characterMeasurements = AttrCalculation.getMeasurements( characterSex, characterHeight['NowHeight'], characterWeight, characterBodyFat, weightTem) CacheContorl.temporaryCharacter['Weight'] = characterWeight CacheContorl.temporaryCharacter['BodyFat'] = characterBodyFat CacheContorl.temporaryCharacter['Measurements'] = characterMeasurements CacheContorl.nowFlowId = 'acknowledgment_attribute'
def initAttr(self): ''' 随机生成角色属性 ''' self.Language[self.MotherTongue] = 10000 self.Birthday = AttrCalculation.getRandNpcBirthDay(self.Age) self.Height = AttrCalculation.getHeight(self.Sex,self.Age,{}) bmi = AttrCalculation.getBMI(self.WeigtTem) self.Weight = AttrCalculation.getWeight(bmi,self.Height['NowHeight']) self.BodyFat = AttrCalculation.getBodyFat(self.Sex,self.BodyFatTem) self.Measurements = AttrCalculation.getMeasurements(self.Sex,self.Height['NowHeight'],self.Weight,self.BodyFat,self.BodyFatTem) self.SexExperience = AttrCalculation.getSexExperience(self.SexExperienceTem) self.SexGrade = AttrCalculation.getSexGrade(self.SexExperience) defaultClothingData = Clothing.creatorSuit(self.ClothingTem,self.Sex) self.Clothing = {clothing:{uuid.uuid1():defaultClothingData[clothing]} if clothing in defaultClothingData else {} for clothing in self.Clothing} self.Chest = AttrCalculation.getChest(self.ChestTem,self.Birthday) self.HitPointMax = AttrCalculation.getMaxHitPoint(self.HitPointTem) self.HitPoint = self.HitPointMax self.ManaPointMax = AttrCalculation.getMaxManaPoint(self.ManaPointTem) self.ManaPoint = self.ManaPointMax self.Nature = Nature.getRandomNature() self.Status = TextLoading.getGameData(TextLoading.characterStatePath) self.WearItem = { "Wear":{key:{} for key in TextLoading.getGameData(TextLoading.wearItemPath)['Wear']}, "Item":{}, } self.Engraving = { "Pain":0, "Happy":0, "Yield":0, "Fear":0, "Resistance":0 } self.SocialContact = {social:{} for social in TextLoading.getTextData(TextLoading.stageWordPath,'144')} self.initClass() self.putOn()
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()