Example #1
0
def characterPutOnClothing(characterId: str):
    '''
    角色自动选择并穿戴服装
    Keyword arguments:
    characterId -- 角色id
    putOnData -- 与主进程共享的dict
    '''
    collocationData = {}
    characterClothingData = CacheContorl.characterData['character'][
        characterId]['Clothing']
    clothingsNameData = getClothingNameData(characterClothingData)
    clothingsPriceData = getClothingPriceData(characterClothingData)
    for clothingType in clothingsNameData:
        clothingTypeData = clothingsNameData[clothingType]
        for clothingName in clothingTypeData:
            clothingNameData = clothingTypeData[clothingName]
            clothingId = list(clothingNameData.keys())[-1]
            clothingData = characterClothingData[clothingType][clothingId]
            nowCollocationData = getClothingCollocationData(
                clothingData, clothingType, clothingsNameData,
                clothingsPriceData, characterClothingData)
            if nowCollocationData != 'None':
                nowCollocationData[clothingType] = clothingId
                nowCollocationData['Price'] += clothingsPriceData[
                    clothingType][clothingId]
                collocationData[clothingId] = nowCollocationData
    collocationPriceData = {
        collocation: collocationData[collocation]['Price']
        for collocation in collocationData
    }
    collocationId = list(
        ValueHandle.sortedDictForValues(collocationPriceData).keys())[-1]
    CacheContorl.characterData['character'][characterId][
        'PutOn'] = collocationData[collocationId]
Example #2
0
def getAppointNamesClothingTop(appointNameList:list,clothingTypeNameData:dict) -> str:
    '''
    获取指定服装类型数据下指定名称的服装中价值最高的服装
    Keyword arguments:
    appointNameList -- 要获取的服装名字列表
    clothingTypeNameData -- 以名字为分类的已排序的要查询的服装数据
    '''
    clothingData = {list(clothingTypeNameData[appoint].keys())[-1]:clothingTypeNameData[appoint][list(clothingTypeNameData[appoint].keys())[-1]] for appoint in appointNameList if appoint in clothingTypeNameData}
    if clothingData != {}:
        return list(ValueHandle.sortedDictForValues(clothingData).keys())[-1]
    return 'None'
Example #3
0
def getClothingNameData(clothingsData:dict) -> dict:
    '''
    按服装的具体名称对服装进行分类,获取同类下各服装的价值数据
    Keyword arguments:
    clothingsData -- 要分类的所有服装数据
    '''
    clothingNameData = {}
    for clothingType in clothingsData:
        clothingTypeData = clothingsData[clothingType]
        clothingNameData.setdefault(clothingType,{})
        for clothing in clothingTypeData:
            clothingData = clothingTypeData[clothing]
            clothingName = clothingData['Name']
            clothingNameData[clothingType].setdefault(clothingName,{})
            clothingNameData[clothingType][clothingName][clothing] = clothingData['Price'] + clothingData['Cleanliness']
        clothingNameData[clothingType] = {clothingName:ValueHandle.sortedDictForValues(clothingNameData[clothingType][clothingName]) for clothingName in clothingNameData[clothingType]}
    return clothingNameData
Example #4
0
 def putOn(self):
     '''
     角色自动选择并穿戴服装
     Keyword arguments:
     characterId -- 角色服装数据
     '''
     characterClothingData = self.Clothing
     collocationData = {}
     clothingsNameData = Clothing.getClothingNameData(characterClothingData)
     clothingsPriceData = Clothing.getClothingPriceData(characterClothingData)
     for clothingType in clothingsNameData:
         clothingTypeData = clothingsNameData[clothingType]
         for clothingName in clothingTypeData:
             clothingNameData = clothingTypeData[clothingName]
             clothingId = list(clothingNameData.keys())[-1]
             clothingData = characterClothingData[clothingType][clothingId]
             nowCollocationData = Clothing.getClothingCollocationData(clothingData,clothingType,clothingsNameData,clothingsPriceData,characterClothingData)
             if nowCollocationData != 'None':
                 nowCollocationData[clothingType] = clothingId
                 nowCollocationData['Price'] += clothingsPriceData[clothingType][clothingId]
                 collocationData[clothingId] = nowCollocationData
     collocationPriceData = {collocation:collocationData[collocation]['Price'] for collocation in collocationData}
     collocationId = list(ValueHandle.sortedDictForValues(collocationPriceData).keys())[-1]
     self.PutOn = collocationData[collocationId]