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 acknowledgmentAttributeAns(inputList): characterId = CacheContorl.characterData['characterId'] yrn = GameInit.askfor_All(inputList) showAttrHandleData = TextLoading.getTextData(TextLoading.cmdPath, 'seeAttrPanelHandle') PyCmd.clr_cmd() if yrn in panelList: PanelStateHandle.panelStateChange(yrn) acknowledgmentAttribute_func() elif yrn == '0': GameTime.initTime() AttrCalculation.setAttrOver(characterId) CharacterHandle.initCharacterList() SeeCharacterAttrPanel.initShowAttrPanelList() characterPosition = CacheContorl.characterData['character'][ characterId]['Position'] MapHandle.characterMoveScene(['0'], characterPosition, characterId) from script.Flow import Main Main.mainFrame_func() elif yrn == '1': CacheContorl.wframeMouse['wFrameRePrint'] = 1 EraPrint.pnextscreen() SeeCharacterAttrPanel.initShowAttrPanelList() from script.Design import StartFlow StartFlow.main_func() elif yrn in showAttrHandleData: index = showAttrHandleData.index(yrn) index = str(index) CacheContorl.panelState['AttrShowHandlePanel'] = index acknowledgmentAttribute_func()
def acknowledgmentAttribute_func(): ''' 创建角色时用于查看角色属性的流程 ''' while (True): characterId = CacheContorl.characterData['characterId'] AttrCalculation.setAttrOver(characterId) inputS = [] attrInpurList = seeAttrInEveryTime_func() inputS = attrInpurList + inputS flowReturn = SeeCharacterAttrPanel.inputAttrOverPanel() inputS = flowReturn + inputS characterId = CacheContorl.characterData['characterId'] yrn = GameInit.askfor_All(inputS) showAttrHandleData = TextLoading.getTextData(TextLoading.cmdPath, 'seeAttrPanelHandle') PyCmd.clr_cmd() if yrn in panelList: PanelStateHandle.panelStateChange(yrn) elif yrn == '0': GameStartFlow.initGameStart() break elif yrn == '1': CacheContorl.wframeMouse['wFrameRePrint'] = 1 EraPrint.pnextscreen() SeeCharacterAttrPanel.initShowAttrPanelList() CacheContorl.nowFlowId = 'title_frame' break elif yrn in showAttrHandleData: CacheContorl.panelState['AttrShowHandlePanel'] = str( showAttrHandleData.index(yrn))
def attributeGenerationBranchPanel(): characterId = CacheContorl.characterData['characterId'] AttrCalculation.setAttrDefault(characterId) PyCmd.clr_cmd() EraPrint.pline() EraPrint.pl(TextLoading.getTextData(TextLoading.messagePath, '9')) yrn = CmdButtonQueue.optionint(CmdButtonQueue.currencymenu, 1) return yrn
def acknowledgmentAttribute_func(): characterId = CacheContorl.characterData['characterId'] AttrCalculation.setAttrOver(characterId) inputS = [] attrInpurList = seeAttrInEveryTime_func() inputS = ValueHandle.listAppendToList(attrInpurList, inputS) flowReturn = SeeCharacterAttrPanel.inputAttrOverPanel() inputS = ValueHandle.listAppendToList(flowReturn, inputS) acknowledgmentAttributeAns(inputS)
def detailedSetting_func2(): ansList = TextLoading.getTextData(TextLoading.cmdPath, 'detailedSetting2') flowReturn = CreatorCharacterPanel.detailedSetting2Panel() if flowReturn == ansList[len(ansList)-1]: PyCmd.clr_cmd() detailedSetting_func3() else: PyCmd.clr_cmd() AttrCalculation.setAnimalCache(flowReturn) detailedSetting_func3()
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 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 detailedSetting_func3(): flowReturn = CreatorCharacterPanel.detailedSetting3Panel() sexTemDataList = ValueHandle.dictKeysToList(TextLoading.getTextData(TextLoading.attrTemplatePath,'SexExperience')) sexTemDataList = ValueHandle.reverseArrayList(sexTemDataList) sexTemName = sexTemDataList[flowReturn] if flowReturn != len(sexTemDataList) - 1: CacheContorl.featuresList['Chastity'] = '' else: pass characterSexExperienceData = AttrCalculation.getSexExperience(sexTemName) CacheContorl.temporaryCharacter['SexExperience'] = characterSexExperienceData CacheContorl.temporaryCharacter['SexGrade'] = AttrCalculation.getSexGrade(characterSexExperienceData) PyCmd.clr_cmd() detailedSetting_func4()
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 getLevelColorText(exp): ''' 计算经验对应等级并获取富文本 Keyword arguments: exp -- 经验 ''' return getLevelTextColor(AttrCalculation.judgeGrade(exp))
def createRandomNpc(id) -> dict: ''' 生成随机npc数据模板 ''' nowAgeWeight = random.randint(-1,ageWeightMax - 1) nowAgeWeightRegin = ValueHandle.getNextValueForList(nowAgeWeight,ageWeightReginList) ageWeightTem = ageWeightReginData[nowAgeWeightRegin] randomNpcSex = getRandNpcSex() randomNpcName = AttrText.getRandomNameForSex(randomNpcSex) randomNpcAgeTem = getRandNpcAgeTem(ageWeightTem) fatTem = getRandNpcFatTem(ageWeightTem) bodyFatTem = getRandNpcBodyFatTem(ageWeightTem,fatTem) randomNpcNewData = { "Name":randomNpcName, "Sex":randomNpcSex, "Age":randomNpcAgeTem, "Position":["0"], "AdvNpc":"1", "Weight":fatTem, "BodyFat":bodyFatTem } if randomNpcSex in {"Woman":1,"Futa":1}: randomNpcNewData['Chest'] = AttrCalculation.getRandNpcChestTem() else: randomNpcNewData['Chest'] = 'Precipice' CacheContorl.randomNpcList.append(randomNpcNewData)
def initGameStart(): ''' 用于结束角色创建正式开始游戏的初始化流程 ''' GameTime.initTime() AttrCalculation.setAttrOver('0') Course.initPhaseCourseHour() CharacterHandle.initCharacterList() Interest.initCharacterInterest() Course.initCharacterKnowledge() Course.initClassTeacher() Course.initClassTimeTable() SeeCharacterAttrPanel.initShowAttrPanelList() characterPosition = CacheContorl.characterData['character']['0'][ 'Position'] MapHandle.characterMoveScene(['0'], characterPosition, '0') CacheContorl.nowFlowId = 'main'
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 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 detailedSetting_func3(): ''' 询问玩家性经验程度流程 ''' flowReturn = CreatorCharacterPanel.detailedSetting3Panel() sexTemDataList = list( TextLoading.getTextData(TextLoading.attrTemplatePath, 'SexExperience').keys()) sexTemDataList.reverse() sexTemName = sexTemDataList[flowReturn] if flowReturn != len(sexTemDataList) - 1: CacheContorl.featuresList['Chastity'] = '' characterSexExperienceData = AttrCalculation.getSexExperience(sexTemName) CacheContorl.temporaryCharacter[ 'SexExperience'] = characterSexExperienceData CacheContorl.temporaryCharacter['SexGrade'] = AttrCalculation.getSexGrade( characterSexExperienceData) PyCmd.clr_cmd() detailedSetting_func4()
def detailedSetting_func3(): ''' 询问玩家性经验程度流程 ''' flowReturn = CreatorCharacterPanel.detailedSetting3Panel() sexTemDataList = list(TextLoading.getTextData(TextLoading.attrTemplatePath,'SexExperience').keys()) sexTemDataList.reverse() sexTemName = sexTemDataList[flowReturn] characterSexExperienceData = AttrCalculation.getSexExperience(sexTemName) CacheContorl.characterData['character'][0].SexExperienceTem = sexTemName PyCmd.clr_cmd() detailedSetting_func8()
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 initGameStart(): ''' 用于结束角色创建正式开始游戏的初始化流程 ''' GameTime.initTime() AttrCalculation.setAttrOver('0') Course.initPhaseCourseHour() CharacterHandle.initCharacterList() characterSuit = Clothing.creatorSuit( 'Uniform', CacheContorl.characterData['character']['0']['Sex']) for clothing in characterSuit: CacheContorl.characterData['character']['0']['Clothing'][clothing][ uuid.uuid1()] = characterSuit[clothing] Clothing.characterPutOnClothing('0') Interest.initCharacterInterest() Course.initCharacterKnowledge() Course.initClassTeacher() Course.initClassTimeTable() SeeCharacterAttrPanel.initShowAttrPanelList() characterPosition = CacheContorl.characterData['character']['0'][ 'Position'] MapHandle.characterMoveScene(['0'], characterPosition, '0') CacheContorl.nowFlowId = 'main'
def indexCharacterAverageValue(): ''' 统计各年龄段所有角色各属性总值 ''' for character in CacheContorl.characterData['character']: characterData = CacheContorl.characterData['character'][character] ageTem = AttrCalculation.judgeAgeGroup(characterData.Age) CacheContorl.TotalHeightByage.setdefault(ageTem,{}) CacheContorl.TotalHeightByage[ageTem].setdefault(characterData.Sex,0) CacheContorl.TotalHeightByage[ageTem][characterData.Sex] += characterData.Height['NowHeight'] CacheContorl.TotalNumberOfPeopleOfAllAges.setdefault(ageTem,{}) CacheContorl.TotalNumberOfPeopleOfAllAges[ageTem].setdefault(characterData.Sex,0) CacheContorl.TotalNumberOfPeopleOfAllAges[ageTem][characterData.Sex] += 1 CacheContorl.TotalBodyFatByage.setdefault(ageTem,{}) CacheContorl.TotalBodyFatByage[ageTem].setdefault(characterData.Sex,0) CacheContorl.TotalBodyFatByage[ageTem][characterData.Sex] += characterData.BodyFat
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()
import os, random from concurrent.futures import thread from script.Core import CacheContorl, ValueHandle, GameData, TextLoading, GamePathConfig, GameConfig from script.Design import AttrCalculation, MapHandle, AttrText language = GameConfig.language gamepath = GamePathConfig.gamepath featuresList = AttrCalculation.getFeaturesList() sexList = list(TextLoading.getTextData(TextLoading.rolePath, 'Sex')) ageTemList = list( TextLoading.getTextData(TextLoading.attrTemplatePath, 'AgeTem')) characterListPath = os.path.join(gamepath, 'data', language, 'character') characterList = GameData.getPathList(characterListPath) # 初始化角色数据 def initCharacterList(): initCharacterThreadPool = thread.ThreadPoolExecutor( max_workers=GameConfig.threading_pool_max) initCharacterTem() characterList = CacheContorl.npcTemData i = 1 for character in characterList: initCharacterThreadPool.submit(initCharacter, i, character) i += 1 initCharacterThreadPool.shutdown() initCharacterPosition() # 按id生成角色属性 def initCharacter(nowId, character):
def seeCharacterMainAttrPanel(characterId:int): ''' 查看角色主属性面板 Keyword arguments: characterId -- 角色Id ''' title1 = TextLoading.getTextData(TextLoading.stageWordPath, '1') EraPrint.plt(title1) characterIdText = f"{TextLoading.getTextData(TextLoading.stageWordPath, '0')}{characterId}" characterData = CacheContorl.characterData['character'][characterId] name = characterData.Name nickName = characterData.NickName characterName = TextLoading.getTextData(TextLoading.stageWordPath,'13') + name characterNickName = TextLoading.getTextData(TextLoading.stageWordPath,'12') + nickName sex = characterData.Sex sexText = TextLoading.getTextData(TextLoading.stageWordPath, '2') + AttrText.getSexText(sex) nameText = characterIdText + ' ' + characterName + ' ' + characterNickName + ' ' + sexText hpBar = AttrPrint.getHpOrMpBar(characterId,'HitPoint',GameConfig.text_width / 2 - 4) EraPrint.plist([nameText,hpBar],2,'center') EraPrint.pl() stateText = AttrText.getStateText(characterId) mpBar = AttrPrint.getHpOrMpBar(characterId,'ManaPoint',GameConfig.text_width / 2 - 4) EraPrint.plist([stateText,mpBar],2,'center') EraPrint.pl() EraPrint.plittleline() statureText = AttrText.getStatureText(characterId) EraPrint.pl(statureText) EraPrint.pline('.') EraPrint.pl(AttrText.getCharacterDormitoryPathText(characterId)) EraPrint.plittleline() characterSpecies = f"{TextLoading.getTextData(TextLoading.stageWordPath, '15')}{characterData.Species}" characterAge = f"{TextLoading.getTextData(TextLoading.stageWordPath, '3')}{characterData.Age}" birthdayText = f"{TextLoading.getTextData(TextLoading.stageWordPath,'140')}{characterData.Birthday['month']}{TextLoading.getTextData(TextLoading.stageWordPath,'60')}{characterData.Birthday['day']}{TextLoading.getTextData(TextLoading.stageWordPath,'61')}" EraPrint.plist([characterSpecies,characterAge,birthdayText],3,'center') EraPrint.pline('.') characterIntimate = f"{TextLoading.getTextData(TextLoading.stageWordPath, '16')}{characterData.Intimate}" characterGraces = f"{TextLoading.getTextData(TextLoading.stageWordPath, '17')}{characterData.Graces}" EraPrint.plist([characterIntimate,characterGraces],2,'center') EraPrint.pline('.') characterChest = characterData.Chest['NowChest'] chestGroup = AttrCalculation.judgeChestGroup(characterChest) chestText = TextLoading.getTextData(TextLoading.stageWordPath,'141') + TextLoading.getTextData(TextLoading.stageWordPath,'142')[chestGroup] EraPrint.plist([chestText],1,'center') EraPrint.pline('.') characterHeight = characterData.Height['NowHeight'] characterWeight = characterData.Weight characterHeightText = str(round(characterHeight,2)) characterWeightText = str(round(characterWeight,2)) characterHeightInfo = TextLoading.getTextData(TextLoading.stageWordPath,'80') + characterHeightText characterWeightInfo = TextLoading.getTextData(TextLoading.stageWordPath,'81') + characterWeightText EraPrint.plist([characterHeightInfo,characterWeightInfo],2,'center') EraPrint.pline('.') characterMeasurements = characterData.Measurements characterBust = str(round(characterMeasurements['Bust'],2)) characterWaist = str(round(characterMeasurements['Waist'],2)) characterHip = str(round(characterMeasurements['Hip'],2)) characterBustInfo = TextLoading.getTextData(TextLoading.stageWordPath,'82') + characterBust characterWaistInfo = TextLoading.getTextData(TextLoading.stageWordPath,'83') + characterWaist characterHipInfo = TextLoading.getTextData(TextLoading.stageWordPath,'84') + characterHip EraPrint.plist([characterBustInfo,characterWaistInfo,characterHipInfo],3,'center') EraPrint.pline('.')
def judgeCharacterStature(characterId): ''' 校验身材信息 Keyword arguments: characterId -- 角色Id ''' characterData = CacheContorl.characterData['character'][characterId] selfSex = CacheContorl.characterData['character'][0].Sex targetSex = characterData.Sex ageJudge = 'Similar' selfAge = CacheContorl.characterData['character'][0].Age targetAge = characterData.Age ageDisparity = selfAge - targetAge if ageDisparity < -2 and ageDisparity >= -5: ageJudge = 'SlightlyHigh' elif ageDisparity < -5 and ageDisparity >= -15: ageJudge = 'High' elif ageDisparity < -15 and ageDisparity >= -30: ageJudge = 'VeryHigh' elif ageDisparity < -30 and ageDisparity >= -60: ageJudge = 'SuperHigh' elif ageDisparity < -60: ageJudge = 'ExtremelyHigh' elif ageDisparity > 2 and ageDisparity <= 5: ageJudge = 'SlightlyLow' elif ageDisparity > 5 and ageDisparity <= 15: ageJudge = 'Low' elif ageDisparity > 15 and ageDisparity <= 30: ageJudge = 'VeryLow' elif ageDisparity > 30 and ageDisparity <= 60: ageJudge = 'SuperLow' elif ageDisparity > 60: ageJudge = 'ExtremelyLow' bodyFat = characterData.BodyFat ageTem = AttrCalculation.judgeAgeGroup(targetAge) averageBodyFat = CacheContorl.AverageBodyFatByage[ageTem][targetSex] bodyFatJudge = 'Similar' if bodyFat < averageBodyFat * 1.15 and bodyFat >= averageBodyFat * 1.05: bodyFatJudge = 'SlilghtlyHeight' elif bodyFat < averageBodyFat * 1.25 and bodyFat >= averageBodyFat * 1.15: bodyFatJudge = 'Height' elif bodyFat < averageBodyFat * 1.35 and bodyFat >= averageBodyFat * 1.25: bodyFatJudge = 'VeryHeight' elif bodyFat < averageBodyFat * 1.45 and bodyFat >= averageBodyFat * 1.35: bodyFatJudge = 'SuperHeight' elif bodyFat > averageBodyFat * 1.45: bodyFatJudge = 'ExtremelyHeight' elif bodyFat < averageBodyFat * 0.95 and bodyFat >= averageBodyFat * 0.85: bodyFatJudge = 'SlilghtlyLow' elif bodyFat < averageBodyFat * 0.85 and bodyFat >= averageBodyFat * 0.75: bodyFatJudge = 'Low' elif bodyFat < averageBodyFat * 0.75 and bodyFat >= averageBodyFat * 0.65: bodyFatJudge = 'VeryLow' elif bodyFat < averageBodyFat * 0.65 and bodyFat >= averageBodyFat * 0.55: bodyFatJudge = 'SuperLow' elif bodyFat < averageBodyFat * 0.55: bodyFatJudge = 'ExtremelyLow' averageHeight = CacheContorl.AverageHeightByage[ageTem][targetSex] height = characterData.Height['NowHeight'] heightJudge = 'Similar' if height < averageHeight * 1.15 and height >= averageHeight * 1.05: heightJudge = 'SlilghtlyHeight' elif height < averageHeight * 1.25 and height >= averageHeight * 1.15: heightJudge = 'Height' elif height < averageHeight * 1.35 and height >= averageHeight * 1.25: heightJudge = 'VeryHeight' elif height < averageHeight * 1.45 and height >= averageHeight * 1.35: heightJudge = 'SuperHeight' elif height > averageHeight * 1.45: heightJudge = 'ExtremelyHeight' elif height < averageHeight * 0.95 and height >= averageHeight * 0.85: heightJudge = 'SlilghtlyLow' elif height < averageHeight * 0.85 and height >= averageHeight * 0.75: heightJudge = 'Low' elif height < averageHeight * 0.75 and height >= averageHeight * 0.65: heightJudge = 'VeryLow' elif height < averageHeight * 0.65 and height >= averageHeight * 0.55: heightJudge = 'SuperLow' elif height < averageHeight: heightJudge = 'ExtremelyLow' playerBodyFat = characterData.BodyFat playerBodyFatJudge = 'Similar' if bodyFat < playerBodyFat * 1.15 and bodyFat >= playerBodyFat * 1.05: playerBodyFatJudge = 'SlilghtlyHeight' elif bodyFat < playerBodyFat * 1.25 and bodyFat >= playerBodyFat * 1.15: playerBodyFatJudge = 'Height' elif bodyFat < playerBodyFat * 1.35 and bodyFat >= playerBodyFat * 1.25: playerBodyFatJudge = 'VeryHeight' elif bodyFat < playerBodyFat * 1.45 and bodyFat >= playerBodyFat * 1.35: playerBodyFatJudge = 'SuperHeight' elif bodyFat > playerBodyFat * 1.45: playerBodyFatJudge = 'ExtremelyHeight' elif bodyFat < playerBodyFat * 0.95 and bodyFat >= playerBodyFat * 0.85: playerBodyFatJudge = 'SlilghtlyLow' elif bodyFat < playerBodyFat * 0.85 and bodyFat >= playerBodyFat * 0.75: playerBodyFatJudge = 'Low' elif bodyFat < playerBodyFat * 0.75 and bodyFat >= playerBodyFat * 0.65: playerBodyFatJudge = 'VeryLow' elif bodyFat < playerBodyFat * 0.65 and bodyFat >= playerBodyFat * 0.55: playerBodyFatJudge = 'SuperLow' elif bodyFat < playerBodyFat * 0.55: playerBodyFatJudge = 'ExtremelyLow' playerHeight = CacheContorl.characterData['character'][0].Height[ 'NowHeight'] playerHeightJudge = 'Similar' if height < playerHeight * 1.15 and height >= playerHeight * 1.05: playerHeightJudge = 'SlilghtlyHeight' elif height < playerHeight * 1.25 and height >= playerHeight * 1.15: playerHeightJudge = 'Height' elif height < playerHeight * 1.35 and height >= playerHeight * 1.25: playerHeightJudge = 'VeryHeight' elif height < playerHeight * 1.45 and height >= playerHeight * 1.35: playerHeightJudge = 'SuperHeight' elif height > playerHeight * 1.45: playerHeightJudge = 'ExtremelyHeight' elif height < playerHeight * 0.95 and height >= playerHeight * 0.85: playerHeightJudge = 'SlilghtlyLow' elif height < playerHeight * 0.85 and height >= playerHeight * 0.75: playerHeightJudge = 'Low' elif height < playerHeight * 0.75 and height >= playerHeight * 0.65: playerHeightJudge = 'VeryLow' elif height < playerHeight * 0.65 and height >= playerHeight * 0.55: playerHeightJudge = 'SuperLow' elif height < playerHeight * 0.55: playerHeightJudge = 'ExtremelyLow' playerSex = CacheContorl.characterData['character'][0].Sex playerAge = CacheContorl.characterData['character'][0].Age playerAgeTem = AttrCalculation.judgeAgeGroup( CacheContorl.characterData['character'][0].Age) averageBodyFat = CacheContorl.AverageBodyFatByage[playerAgeTem][playerSex] averageHeight = CacheContorl.AverageHeightByage[playerAgeTem][playerSex] playerAverageBodyFatJudge = 'Similar' if playerBodyFat < averageBodyFat * 1.15 and playerBodyFat >= averageBodyFat * 1.05: playerAverageBodyFatJudge = 'SlilghtlyHeight' elif playerBodyFat < averageBodyFat * 1.25 and playerBodyFat >= averageBodyFat * 1.15: playerAverageBodyFatJudge = 'Height' elif playerBodyFat < averageBodyFat * 1.35 and playerBodyFat >= averageBodyFat * 1.25: playerAverageBodyFatJudge = 'VeryHeight' elif playerBodyFat < averageBodyFat * 1.45 and playerBodyFat >= averageBodyFat * 1.35: playerAverageBodyFatJudge = 'SuperHeight' elif playerBodyFat > averageBodyFat * 1.45: playerAverageBodyFatJudge = 'ExtremelyHeight' elif playerBodyFat < averageBodyFat * 0.95 and playerBodyFat >= averageBodyFat * 0.85: playerAverageBodyFatJudge = 'SlilghtlyLow' elif playerBodyFat < averageBodyFat * 0.85 and playerBodyFat >= averageBodyFat * 0.75: playerAverageBodyFatJudge = 'Low' elif playerBodyFat < averageBodyFat * 0.75 and playerBodyFat >= averageBodyFat * 0.65: playerAverageBodyFatJudge = 'VeryLow' elif playerBodyFat < averageBodyFat * 0.65 and playerBodyFat >= averageBodyFat * 0.55: playerAverageBodyFatJudge = 'SuperLow' elif playerBodyFat < averageBodyFat * 0.55: playerAverageBodyFatJudge = 'ExtremelyLow' playerAverageHeightJudge = 'Similar' if playerHeight < averageHeight * 1.15 and playerHeight >= averageHeight * 1.05: playerAverageHeightJudge = 'SlilghtlyHeight' elif playerHeight < averageHeight * 1.25 and playerHeight >= averageHeight * 1.15: playerAverageHeightJudge = 'Height' elif playerHeight < averageHeight * 1.35 and playerHeight >= averageHeight * 1.25: playerAverageHeightJudge = 'VeryHeight' elif playerHeight < averageHeight * 1.45 and playerHeight >= averageHeight * 1.35: playerAverageHeightJudge = 'SuperHeight' elif playerHeight > averageHeight * 1.45: playerAverageHeightJudge = 'ExtremelyHeight' elif playerHeight < averageHeight * 0.95 and playerHeight >= averageHeight * 0.85: playerAverageHeightJudge = 'SlilghtlyLow' elif playerHeight < averageHeight * 0.85 and playerHeight >= averageHeight * 0.75: playerAverageHeightJudge = 'Low' elif playerHeight < averageHeight * 0.75 and playerHeight >= averageHeight * 0.65: playerAverageHeightJudge = 'VeryLow' elif playerHeight < averageHeight * 0.65 and playerHeight >= averageHeight * 0.55: playerAverageHeightJudge = 'SuperLow' elif playerHeight < averageHeight * 0.55: playerAverageHeightJudge = 'ExtremelyLow' targetJudge = 'Target' if characterId == 0: targetJudge = 'Self' return { "SelfSex": playerSex, "TargetSex": characterData.Sex, "AgeJudge": ageJudge, "AgeTem": ageTem, "SelfAgeTem": playerAgeTem, "SelfAge": playerAge, "TargetAge": targetAge, "AverageHeight": heightJudge, "AverageStature": bodyFatJudge, "RelativeHeight": playerHeightJudge, "RelativeStature": playerBodyFatJudge, "PlayerAverageHeight": playerAverageHeightJudge, "PlayerAverageStature": playerAverageBodyFatJudge, "Target": targetJudge }
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: 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()