少年修仙传客户端代码仓库
client_Wu Xijin
2019-02-22 2777956c464377d678ae6626e7d21e3d01834b5e
3335 物品相关类型重构
1个文件已修改
488 ■■■■■ 已修改文件
System/KnapSack/Logic/ItemLegendPropertyUtility.cs 488 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/KnapSack/Logic/ItemLegendPropertyUtility.cs
@@ -5,32 +5,96 @@
public class ItemLegendPropertyUtility
{
    public Dictionary<string, Dictionary<LegendAttrType, int>> legendAttrCntPreviewDict { get; private set; } // key 品质+星级  value 属性条目数
    public Dictionary<int, Dictionary<LegendAttrType, List<int>>> legendAttrIDPreviewDict { get; private set; } // key 装备位 value 属性类型,属性ID
    public Dictionary<int, Dictionary<int, int>> legendAttrColorValuePreviewDict { get; private set; } // key 属性ID value 装备品质,属性数值
    public Dictionary<int, Dictionary<int, int>> legendAttrLvValuePreviewDict { get; private set; } // key 属性ID value 装备阶级,属性数值
    public Dictionary<int, int> wingsLegendAttrCntPreviewDict { get; private set; } //key 阶数 value属性数
    public Dictionary<int, Dictionary<int, List<int>>> wingsLegendAttrValuePreviewDict { get; private set; } //key 阶数 value 属性ID 属性数值
    public Dictionary<int, Dictionary<LegendAttrType, List<int>>> dogzLegendAttrIDPreviewDict { get; private set; } // key 装备位 value 属性类型,属性ID
    public Dictionary<int, Dictionary<int, int>> dogzLegendAttrColorValuePreviewDict { get; private set; } // key 属性ID value 装备品质,属性数值
    Dictionary<string, Dictionary<LegendAttrType, int>> dogzLegendAttrCntPreviewDict { get; set; } // key 品质+星级  value 属性条目数
    Dictionary<int, List<int>> dogzLegendAttrTypeDict { get; set; }
    static PropertyColor propertyColor;
    static EquipPropertyMap equipPropertyMap;
    static DogzPropertyMap dogzPropertyMap;
    static EquipPropertyCount equipPropertyCount;
    static DogzPropertyCount dogzPropertyCount;
    static EquipQualityPropertyValue equipQualityPropertyValue;
    static DogzQualityPropertyValue dogzQualityPropertyValue;
    static EquipLevelPropertyValue equipLevelPropertyValue;
    static WingPropertyCount wingPropertyCount;
    static WingPropertyValue wingPropertyValue;
    public static void Init()
    {
        propertyColor = new PropertyColor("LegendAttrColor");
        equipPropertyMap = new EquipPropertyMap(FuncConfigConfig.Get("LegendAttrRulePreview").Numerical1);
        dogzPropertyMap = new DogzPropertyMap(FuncConfigConfig.Get("DogzLegendAttrRulePreview").Numerical1);
        equipPropertyCount = new EquipPropertyCount(FuncConfigConfig.Get(" LegendAttrCountPreview").Numerical1);
        dogzPropertyCount = new DogzPropertyCount(FuncConfigConfig.Get("DogzLegendAttrCountPreview").Numerical1);
        equipQualityPropertyValue = new EquipQualityPropertyValue(FuncConfigConfig.Get("LegendAttrValueByColorPreview").Numerical1);
        dogzQualityPropertyValue = new DogzQualityPropertyValue(FuncConfigConfig.Get("DogzLegendAttrValueByColorPreview").Numerical1);
        equipLevelPropertyValue = new EquipLevelPropertyValue(FuncConfigConfig.Get("LegendAttrValueByClassLVPreview").Numerical1);
        wingPropertyCount = new WingPropertyCount();
        wingPropertyValue = new WingPropertyValue();
    }
    public static bool HasPropertyColor(int propertyId)
    {
        return propertyColor.HasPropertyType(propertyId);
    }
    public class LegendPropertyColor
    public static LegendAttrType GetPropertyType(int propertyId)
    {
        return propertyColor.GetPropertyType(propertyId);
    }
    public static string GetWingPropertyColor(int propertyId, int value)
    {
        return propertyColor.GetWingPropertyColor(propertyId, value);
    }
    public static bool IsEquipPlaceHasLegendProperty(int place)
    {
        return equipPropertyMap.HasPlace(place);
    }
    public static bool HasEquipPlaceLegendProperty(int place, int propertyId)
    {
        return equipPropertyMap.HasProperty(place, propertyId);
    }
    public static List<int> GetEquipPlaceProperties(int place)
    {
        return equipPropertyMap.GetProperties(place);
    }
    public static List<int> GetEquipPlaceProperties(int place, LegendAttrType type)
    {
        return equipPropertyMap.GetProperties(place, type);
    }
    public static bool IsDogzPlaceHasLegendProperty(int place)
    {
        return dogzPropertyMap.HasPlace(place);
    }
    public static bool HasDogzPlaceLegendProperty(int place, int propertyId)
    {
        return dogzPropertyMap.HasProperty(place, propertyId);
    }
    public static List<int> GetDogzPlaceProperties(int place)
    {
        return dogzPropertyMap.GetProperties(place);
    }
    public static List<int> GetDogzPlaceProperties(int place, LegendAttrType type)
    {
        return dogzPropertyMap.GetProperties(place, type);
    }
    public class PropertyColor
    {
        Dictionary<int, LegendAttrType> equipLegendPropertyColors = new Dictionary<int, LegendAttrType>();
        Dictionary<int, Dictionary<int, string>> wingLegendPropertyColors = new Dictionary<int, Dictionary<int, string>>();
        public LegendPropertyColor(string configId)
        public PropertyColor(string configId)
        {
            var config = FuncConfigConfig.Get(configId);
@@ -109,26 +173,142 @@
    }
    public class LegendPropertyCount
    public class PropertyMap
    {
        Dictionary<int, StarLegendPropertyCount> qualityToStarLegendPropertyCounts = new Dictionary<int, StarLegendPropertyCount>();
        // key 装备位 value 属性ID,属性类型
        Dictionary<int, Dictionary<int, LegendAttrType>> placeToProperties = new Dictionary<int, Dictionary<int, LegendAttrType>>();
        public LegendPropertyCount(string configId)
        public PropertyMap(string config)
        {
            var config = FuncConfigConfig.Get(configId);
            var json = JsonMapper.ToObject(config.Numerical1);
            var json = JsonMapper.ToObject(config);
            foreach (var key in json.Keys)
            {
                var quality = int.Parse(key);
                qualityToStarLegendPropertyCounts[quality] = new StarLegendPropertyCount(json[key]);
                var equipPlace = int.Parse(key);
                var propertyDictionary = new Dictionary<int, LegendAttrType>();
                placeToProperties.Add(equipPlace, propertyDictionary);
                if (json[key].IsArray)
                {
                    var subJson = json[key];
                    foreach (var type in subJson.Keys)
                    {
                        var legendPropertyType = (LegendAttrType)int.Parse(type);
                        for (var i = 0; i < subJson[type].Count; i++)
                        {
                            var propertyId = (int)subJson[type][i];
                            propertyDictionary[propertyId] = legendPropertyType;
                        }
                    }
                }
            }
        }
        class StarLegendPropertyCount
        public bool HasPlace(int place)
        {
            return placeToProperties.ContainsKey(place);
        }
        public bool HasProperty(int place, int propertyId)
        {
            if (!placeToProperties.ContainsKey(place))
            {
                return false;
            }
            return placeToProperties[place].ContainsKey(propertyId);
        }
        public List<int> GetProperties(int place)
        {
            if (HasPlace(place))
            {
                return new List<int>(placeToProperties[place].Keys);
            }
            else
            {
                return null;
            }
        }
        public List<int> GetProperties(int place, LegendAttrType type)
        {
            if (!HasPlace(place))
            {
                return null;
            }
            var properties = new List<int>();
            foreach (var item in placeToProperties[place])
            {
                if (item.Value == type)
                {
                    properties.Add(item.Key);
                }
            }
            return properties;
        }
    }
    public class EquipPropertyMap : PropertyMap
    {
        public EquipPropertyMap(string configId) : base(configId)
        {
        }
    }
    public class DogzPropertyMap : PropertyMap
    {
        public DogzPropertyMap(string configId) : base(configId)
        {
        }
    }
    public class PropertyCount
    {
        Dictionary<int, StarPropertyCount> qualityToStarLegendPropertyCounts = new Dictionary<int, StarPropertyCount>();
        public PropertyCount(string config)
        {
            var json = JsonMapper.ToObject(config);
            foreach (var key in json.Keys)
            {
                var quality = int.Parse(key);
                qualityToStarLegendPropertyCounts[quality] = new StarPropertyCount(json[key]);
            }
        }
        public bool Has(int quality)
        {
            return qualityToStarLegendPropertyCounts.ContainsKey(quality);
        }
        public bool Has(int quality, int star)
        {
            if (!qualityToStarLegendPropertyCounts.ContainsKey(quality))
            {
                return false;
            }
            return qualityToStarLegendPropertyCounts[quality].Has(star);
        }
        public int GetCount(int quality, int star, LegendAttrType type)
        {
            if (!Has(quality, star))
            {
                return 0;
            }
            return qualityToStarLegendPropertyCounts[quality].GetCount(star, type);
        }
        class StarPropertyCount
        {
            Dictionary<int, Dictionary<LegendAttrType, int>> counts = new Dictionary<int, Dictionary<LegendAttrType, int>>();
            public StarLegendPropertyCount(JsonData json)
            public StarPropertyCount(JsonData json)
            {
                foreach (var key in json.Keys)
                {
@@ -143,9 +323,269 @@
                }
            }
            public bool Has(int star)
            {
                return counts.ContainsKey(star);
            }
            public int GetCount(int star, LegendAttrType type)
            {
                if (!counts.ContainsKey(star))
                {
                    return 0;
                }
                if (!counts[star].ContainsKey(type))
                {
                    return 0;
                }
                return counts[star][type];
            }
        }
    }
    public class EquipPropertyCount : PropertyCount
    {
        public EquipPropertyCount(string configId) : base(configId)
        {
        }
    }
    public class DogzPropertyCount : PropertyCount
    {
        public DogzPropertyCount(string configId) : base(configId)
        {
        }
    }
    public class QualityPropertyValue
    {
        // key 属性ID value 装备品质,属性数值
        Dictionary<int, Dictionary<int, int>> qualityValues = new Dictionary<int, Dictionary<int, int>>();
        public QualityPropertyValue(string config)
        {
            var json = JsonMapper.ToObject(config);
            foreach (var key in json.Keys)
            {
                var propertyId = int.Parse(key);
                var qualityToValue = new Dictionary<int, int>();
                qualityValues.Add(propertyId, qualityToValue);
                var subJson = json[key];
                for (var i = 0; i < subJson.Count; i++)
                {
                    qualityToValue[(int)subJson[i][0]] = (int)subJson[i][1];
                }
            }
        }
        public bool Has(int property)
        {
            return qualityValues.ContainsKey(property);
        }
        public bool Has(int property, int quality)
        {
            if (!qualityValues.ContainsKey(property))
            {
                return false;
            }
            return qualityValues[property].ContainsKey(property);
        }
        public int GetValue(int property, int quality)
        {
            if (Has(property, quality))
            {
                return qualityValues[property][quality];
            }
            else
            {
                return 0;
            }
        }
    }
    public class EquipQualityPropertyValue : QualityPropertyValue
    {
        public EquipQualityPropertyValue(string config) : base(config)
        {
        }
    }
    public class DogzQualityPropertyValue : QualityPropertyValue
    {
        public DogzQualityPropertyValue(string config) : base(config)
        {
        }
    }
    public class LevelPropertyValue
    {
        // key 属性ID value 装备阶级,属性数值
        Dictionary<int, Dictionary<int, int>> levelValues = new Dictionary<int, Dictionary<int, int>>();
        public LevelPropertyValue(string config)
        {
            var json = JsonMapper.ToObject(config);
            levelValues = new Dictionary<int, Dictionary<int, int>>();
            foreach (var key in json.Keys)
            {
                var propertyId = int.Parse(key);
                var levelToValue = new Dictionary<int, int>();
                levelValues.Add(int.Parse(key), levelToValue);
                var subJson = json[key];
                for (var i = 0; i < subJson.Count; i++)
                {
                    levelToValue[(int)subJson[i][0]] = (int)subJson[i][1];
                }
            }
        }
        public bool Has(int property)
        {
            return levelValues.ContainsKey(property);
        }
        public bool Has(int property, int quality)
        {
            if (!levelValues.ContainsKey(property))
            {
                return false;
            }
            return levelValues[property].ContainsKey(property);
        }
        public int GetValue(int property, int quality)
        {
            if (Has(property, quality))
            {
                return levelValues[property][quality];
            }
            else
            {
                return 0;
            }
        }
    }
    public class EquipLevelPropertyValue : LevelPropertyValue
    {
        public EquipLevelPropertyValue(string config) : base(config)
        {
        }
    }
    public class DogzLevelPropertyValue : LevelPropertyValue
    {
        public DogzLevelPropertyValue(string config) : base(config)
        {
        }
    }
    public class WingPropertyCount
    {
        Dictionary<int, int> counts = new Dictionary<int, int>();
        public WingPropertyCount()
        {
            var json = JsonMapper.ToObject(FuncConfigConfig.Get("WingLegendAttrCountPreview").Numerical1);
            for (int i = 0; i < json.Count; i++)
            {
                counts[(int)json[i][0]] = (int)json[i][1];
            }
        }
        public bool Has(int level)
        {
            return counts.ContainsKey(level);
        }
        public int GetValue(int level)
        {
            if (Has(level))
            {
                return counts[level];
            }
            else
            {
                return 0;
            }
        }
    }
    public class WingPropertyValue
    {
        Dictionary<int, Dictionary<int, Int2>> levelPropertyValues = new Dictionary<int, Dictionary<int, Int2>>();
        public WingPropertyValue()
        {
            var json = JsonMapper.ToObject(FuncConfigConfig.Get("WingLegendAttrValuePreview").Numerical1);
            foreach (var key in json.Keys)
            {
                var levelValues = new Dictionary<int, Int2>();
                levelPropertyValues.Add(int.Parse(key), levelValues);
                var subJson = json[key];
                foreach (var propertyId in subJson.Keys)
                {
                    var count = subJson[propertyId].Count;
                    var min = (int)subJson[propertyId][0];
                    var max = (int)subJson[propertyId][count - 1];
                    levelValues[int.Parse(propertyId)] = new Int2(min, max);
                }
            }
        }
        public bool Has(int level)
        {
            return levelPropertyValues.ContainsKey(level);
        }
        public bool Has(int level, int propertyId)
        {
            if (!levelPropertyValues.ContainsKey(level))
            {
                return false;
            }
            return levelPropertyValues[level].ContainsKey(propertyId);
        }
        public int GetMin(int level, int propertyId)
        {
            if (Has(level, propertyId))
            {
                return levelPropertyValues[level][propertyId].x;
            }
            else
            {
                return 0;
            }
        }
        public int GetMax(int level, int propertyId)
        {
            if (Has(level, propertyId))
            {
                return levelPropertyValues[level][propertyId].y;
            }
            else
            {
                return 0;
            }
        }
    }
}