Пример #1
0
def loadDirNow(dataPath:str):
    '''
    获取路径下的游戏数据
    Keyword arguments:
    dataPath -- 要载入数据的路径
    '''
    nowData = {}
    if os.listdir(dataPath):
        for i in os.listdir(dataPath):
            nowPath = os.path.join(dataPath,i)
            if os.path.isfile(nowPath):
                nowFile = i.split('.')
                if len(nowFile) > 1:
                    if nowFile[1] == 'json':
                        if nowFile[0] == 'Scene':
                            nowSceneData = {}
                            mapSystemPath = getMapSystemPathForPath(nowPath)
                            mapSystemPathStr = getMapSystemPathStr(mapSystemPath)
                            loadSceneData = JsonHandle._loadjson(nowPath)
                            nowSceneData.update(loadSceneData)
                            nowSceneData['SceneCharacterData'] = {}
                            nowSceneData['ScenePath'] = mapSystemPath
                            nowSceneData = {mapSystemPathStr:nowSceneData}
                            sceneData.update(nowSceneData)
                            nowSceneTag = loadSceneData['SceneTag']
                            if nowSceneTag not in CacheContorl.placeData:
                                CacheContorl.placeData[nowSceneTag] = []
                            CacheContorl.placeData[nowSceneTag].append(mapSystemPathStr)
                        elif nowFile[0] == 'Map':
                            nowMapData = {}
                            mapSystemPath = getMapSystemPathForPath(nowPath)
                            nowMapData['MapPath'] = mapSystemPath
                            with open(os.path.join(dataPath,"Map"), 'r') as nowReadFile:
                                drawData = nowReadFile.read()
                                nowMapData['MapDraw'] = getPrintMapData(drawData)
                            mapSystemPathStr = getMapSystemPathStr(mapSystemPath)
                            nowMapData.update(JsonHandle._loadjson(nowPath))
                            CacheContorl.nowInitMapId = mapSystemPathStr
                            sortedPathData = getSortedMapPathData(nowMapData['PathEdge'])
                            nowMapData['SortedPath'] = sortedPathData
                            mapData[mapSystemPathStr] = nowMapData
                        else:
                            if nowFile[0] == "NameIndex":
                                data = JsonHandle._loadjson(nowPath)
                                initNameRegion(data['Boys'],0)
                                initNameRegion(data['Girls'],1)
                            elif nowFile[0] == "FamilyIndex":
                                data = JsonHandle._loadjson(nowPath)
                                initNameRegion(data['FamilyNameList'],2)
                            else:
                                nowData[nowFile[0]] = JsonHandle._loadjson(nowPath)
                                if nowFile[0] == 'Equipment':
                                    initClothingData(nowData[nowFile[0]]['Clothing'])
                                elif nowFile[0] == 'StatureDescription':
                                    initStatureDescription(nowData[nowFile[0]]['Priority'])
                                elif nowFile[0] == 'WearItem':
                                    initWearItemTypeData(nowData[nowFile[0]]['Item'])
            else:
                nowData[i] = loadDirNow(nowPath)
    return nowData
Пример #2
0
def loadConfigData() -> dict:
    '''
    读取游戏配置数据
    '''
    configPath = os.path.join(gamepath, 'data', 'core_cfg.json')
    configData = JsonHandle._loadjson(configPath)
    return configData
Пример #3
0
def getFontDataList() -> list:
    '''
    读取游戏字体样式配置列表
    '''
    FontPath = os.path.join(gamepath, 'data', 'FontConfig.json')
    FontData = JsonHandle._loadjson(FontPath)
    fontList = list(FontData.keys())
    return fontList
Пример #4
0
def getFontData(fontId: str) -> dict:
    '''
    读取游戏字体样式配置数据
    Keyword arguments:
    listId -- 字体样式
    '''
    FontPath = os.path.join(gamepath, 'data', 'FontConfig.json')
    FontData = JsonHandle._loadjson(FontPath)
    return FontData[fontId]
Пример #5
0
import os
import random
from script.Core import CacheContorl, GameConfig, GamePathConfig, TextLoading, JsonHandle

language = GameConfig.language
gamepath = GamePathConfig.gamepath
roleAttrPath = os.path.join(gamepath, 'data', language, 'RoleAttributes.json')
roleAttrData = JsonHandle._loadjson(roleAttrPath)


def getTemList() -> dict:
    '''
    获取人物生成模板
    '''
    return TextLoading.getTextData(TextLoading.attrTemplatePath, 'TemList')


def getFeaturesList() -> dict:
    '''
    获取特征模板
    '''
    return roleAttrData['Features']


def getAgeTemList() -> list:
    '''
    获取年龄模板
    '''
    return list(
        TextLoading.getTextData(TextLoading.attrTemplatePath, 'AgeTem').keys())
Пример #6
0
import os, random, bisect
from script.Core import TextLoading, CacheContorl, GameConfig, GamePathConfig, ValueHandle, JsonHandle
from script.Design import ProportionalBar, AttrPrint

language = GameConfig.language
gamepath = GamePathConfig.gamepath

roleAttrPath = os.path.join(gamepath, 'data', language, 'RoleAttributes.json')
roleAttrData = JsonHandle._loadjson(roleAttrPath)
sexData = roleAttrData['Sex']
equipmentPath = os.path.join(gamepath, 'data', language, 'Equipment.json')
equipmentData = JsonHandle._loadjson(equipmentPath)
boysNameListData = TextLoading.getTextData(TextLoading.nameListPath, 'Boys')
girlsNameListData = TextLoading.getTextData(TextLoading.nameListPath, 'Girls')
familyNameListData = TextLoading.getTextData(TextLoading.familyNameListPath,
                                             'FamilyNameList')
sortFamilyIndex = sorted(familyNameListData.items(), key=lambda x: x[1])

familyRegionList = ValueHandle.getReginList(familyNameListData)
boysRegionList = ValueHandle.getReginList(boysNameListData)
girlsRegionList = ValueHandle.getReginList(girlsNameListData)

familyRegionIntList = list(map(int, familyRegionList))
boysRegionIntList = list(map(int, boysRegionList))
girlsRegionIntList = list(map(int, girlsRegionList))


def getSexExperienceText(sexExperienceData: dict, sexName: str) -> list:
    '''
    获取性经验描述文本
    Keyword arguments: