def inputNamePanel(): characterId = CacheContorl.characterData['characterId'] CacheContorl.characterData['character'][ characterId] = CacheContorl.temporaryCharacter.copy() AttrCalculation.setDefaultCache() EraPrint.pline() EraPrint.pl(TextLoading.getTextData(TextLoading.messagePath, '4')) yrn = CmdButtonQueue.optionint(CmdButtonQueue.currencymenu, 1) EraPrint.p('\n') return yrn
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()