少年修仙传客户端代码仓库
client_Wu Xijin
2019-02-22 19a1b278481b4d7ef75eb5b745b67ecc1959de80
3335 物品相关类型重构
2个文件已修改
285 ■■■■■ 已修改文件
System/KnapSack/Logic/ItemLegendPropertyUtility.cs 263 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/KnapSack/Logic/ItemTipsModel.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/KnapSack/Logic/ItemLegendPropertyUtility.cs
@@ -6,42 +6,36 @@
public class ItemLegendPropertyUtility
{
    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 PropertyMap equipPropertyMap;
    static PropertyMap dogzPropertyMap;
    static PropertyCount equipPropertyCount;
    static PropertyCount dogzPropertyCount;
    static QualityPropertyValue equipQualityPropertyValue;
    static QualityPropertyValue dogzQualityPropertyValue;
    static LevelPropertyValue 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);
        equipPropertyMap = new PropertyMap(FuncConfigConfig.Get("LegendAttrColor").Numerical1,
            FuncConfigConfig.Get("LegendAttrRulePreview").Numerical1);
        equipQualityPropertyValue = new EquipQualityPropertyValue(FuncConfigConfig.Get("LegendAttrValueByColorPreview").Numerical1);
        dogzQualityPropertyValue = new DogzQualityPropertyValue(FuncConfigConfig.Get("DogzLegendAttrValueByColorPreview").Numerical1);
        dogzPropertyMap = new PropertyMap(FuncConfigConfig.Get("DogzLegendAttrColor").Numerical1,
            FuncConfigConfig.Get("DogzLegendAttrRulePreview").Numerical1);
        equipLevelPropertyValue = new EquipLevelPropertyValue(FuncConfigConfig.Get("LegendAttrValueByClassLVPreview").Numerical1);
        equipPropertyCount = new PropertyCount(FuncConfigConfig.Get("LegendAttrCountPreview").Numerical1);
        dogzPropertyCount = new PropertyCount(FuncConfigConfig.Get("DogzLegendAttrCountPreview").Numerical1);
        equipQualityPropertyValue = new QualityPropertyValue(FuncConfigConfig.Get("LegendAttrValueByColorPreview").Numerical1);
        dogzQualityPropertyValue = new QualityPropertyValue(FuncConfigConfig.Get("DogzLegendAttrValueByColorPreview").Numerical1);
        equipLevelPropertyValue = new LevelPropertyValue(FuncConfigConfig.Get("LegendAttrValueByClassLVPreview").Numerical1);
        wingPropertyCount = new WingPropertyCount();
        wingPropertyValue = new WingPropertyValue();
    }
    public static bool HasPropertyColor(int propertyId)
    {
        return propertyColor.HasPropertyType(propertyId);
    }
    public static LegendAttrType GetPropertyType(int propertyId)
    {
        return propertyColor.GetPropertyType(propertyId);
    }
    public static string GetWingPropertyColor(int propertyId, int value)
@@ -49,14 +43,24 @@
        return propertyColor.GetWingPropertyColor(propertyId, value);
    }
    public static bool IsEquipPlaceHasLegendProperty(int place)
    public static LegendAttrType GetEquipPropertyType(int propertyId)
    {
        return equipPropertyMap.GetPropertyType(propertyId);
    }
    public static bool HasEquipPlace(int place)
    {
        return equipPropertyMap.HasPlace(place);
    }
    public static bool HasEquipPlaceLegendProperty(int place, int propertyId)
    public static bool HasEquipProperty(int place, int propertyId)
    {
        return equipPropertyMap.HasProperty(place, propertyId);
        if (!HasEquipPlace(place))
        {
            return false;
        }
        return equipPropertyMap.GetProperties(place).Contains(propertyId);
    }
    public static List<int> GetEquipPlaceProperties(int place)
@@ -64,19 +68,24 @@
        return equipPropertyMap.GetProperties(place);
    }
    public static List<int> GetEquipPlaceProperties(int place, LegendAttrType type)
    public static LegendAttrType GetDogzPropertyType(int propertyId)
    {
        return equipPropertyMap.GetProperties(place, type);
        return dogzPropertyMap.GetPropertyType(propertyId);
    }
    public static bool IsDogzPlaceHasLegendProperty(int place)
    public static bool HasDogzPlace(int place)
    {
        return dogzPropertyMap.HasPlace(place);
    }
    public static bool HasDogzPlaceLegendProperty(int place, int propertyId)
    public static bool HasDogzProperty(int place, int propertyId)
    {
        return dogzPropertyMap.HasProperty(place, propertyId);
        if (!HasEquipPlace(place))
        {
            return false;
        }
        return dogzPropertyMap.GetProperties(place).Contains(propertyId);
    }
    public static List<int> GetDogzPlaceProperties(int place)
@@ -84,14 +93,48 @@
        return dogzPropertyMap.GetProperties(place);
    }
    public static List<int> GetDogzPlaceProperties(int place, LegendAttrType type)
    public static int GetEquipPropertyCount(int quality, int star, LegendAttrType type)
    {
        return dogzPropertyMap.GetProperties(place, type);
        return equipPropertyCount.GetCount(quality, star, type);
    }
    public static int GetDogzPropertyCount(int quality, int star, LegendAttrType type)
    {
        return dogzPropertyCount.GetCount(quality, star, type);
    }
    public static int GetEquipQualityPropertyValue(int property, int quality)
    {
        return equipQualityPropertyValue.GetValue(property, quality);
    }
    public static int GetDogzQualityPropertyValue(int property, int quality)
    {
        return dogzQualityPropertyValue.GetValue(property, quality);
    }
    public static int GetEquipLevelPropertyValue(int property, int level)
    {
        return equipLevelPropertyValue.GetValue(property, level);
    }
    public static int GetWingPropertyCount(int level)
    {
        return wingPropertyCount.GetValue(level);
    }
    public static int GetWingPropertyMinValue(int level, int property)
    {
        return wingPropertyValue.GetMin(level, property);
    }
    public static int GetWingPropertyMaxValue(int level, int property)
    {
        return wingPropertyValue.GetMax(level, property);
    }
    public class PropertyColor
    {
        Dictionary<int, LegendAttrType> equipLegendPropertyColors = new Dictionary<int, LegendAttrType>();
        Dictionary<int, Dictionary<int, string>> wingLegendPropertyColors = new Dictionary<int, Dictionary<int, string>>();
        public PropertyColor(string configId)
@@ -129,23 +172,6 @@
        }
        public bool HasPropertyType(int propertyId)
        {
            return equipLegendPropertyColors.ContainsKey(propertyId);
        }
        public LegendAttrType GetPropertyType(int propertyId)
        {
            if (HasPropertyType(propertyId))
            {
                return equipLegendPropertyColors[propertyId];
            }
            else
            {
                return LegendAttrType.Normal;
            }
        }
        public string GetWingPropertyColor(int propertyId, int value)
        {
            if (!wingLegendPropertyColors.ContainsKey(propertyId))
@@ -170,52 +196,65 @@
            return color;
        }
    }
    public class PropertyMap
    {
        Dictionary<int, LegendAttrType> propertyTypes = new Dictionary<int, LegendAttrType>();
        // key 装备位 value 属性ID,属性类型
        Dictionary<int, Dictionary<int, LegendAttrType>> placeToProperties = new Dictionary<int, Dictionary<int, LegendAttrType>>();
        Dictionary<int, List<int>> placeToProperties = new Dictionary<int, List<int>>();
        public PropertyMap(string config)
        public PropertyMap(string typeConfig, string placeConfig)
        {
            var json = JsonMapper.ToObject(config);
            var json = JsonMapper.ToObject(typeConfig);
            foreach (var item in json.Keys)
            {
                var type = (LegendAttrType)(int.Parse(item) - 1);
                propertyTypes[(int)json[item]] = type;
            }
            json = JsonMapper.ToObject(placeConfig);
            foreach (var key in json.Keys)
            {
                var equipPlace = int.Parse(key);
                var propertyDictionary = new Dictionary<int, LegendAttrType>();
                placeToProperties.Add(equipPlace, propertyDictionary);
                var properties = new List<int>();
                placeToProperties.Add(equipPlace, properties);
                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;
                            properties.Add(propertyId);
                        }
                    }
                }
            }
        }
        public bool HasProperty(int propertyId)
        {
            return propertyTypes.ContainsKey(propertyId);
        }
        public LegendAttrType GetPropertyType(int propertyId)
        {
            if (HasProperty(propertyId))
            {
                return propertyTypes[propertyId];
            }
            else
            {
                return LegendAttrType.Normal;
            }
        }
        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)
@@ -230,39 +269,6 @@
            }
        }
        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
@@ -346,21 +352,6 @@
        }
    }
    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 装备品质,属性数值
@@ -411,20 +402,6 @@
        }
    }
    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 装备阶级,属性数值
@@ -453,7 +430,7 @@
            return levelValues.ContainsKey(property);
        }
        public bool Has(int property, int quality)
        public bool Has(int property, int level)
        {
            if (!levelValues.ContainsKey(property))
            {
@@ -463,11 +440,11 @@
            return levelValues[property].ContainsKey(property);
        }
        public int GetValue(int property, int quality)
        public int GetValue(int property, int level)
        {
            if (Has(property, quality))
            if (Has(property, level))
            {
                return levelValues[property][quality];
                return levelValues[property][level];
            }
            else
            {
@@ -475,20 +452,6 @@
            }
        }
    }
    public class EquipLevelPropertyValue : LevelPropertyValue
    {
        public EquipLevelPropertyValue(string config) : base(config)
        {
        }
    }
    public class DogzLevelPropertyValue : LevelPropertyValue
    {
        public DogzLevelPropertyValue(string config) : base(config)
        {
        }
    }
    public class WingPropertyCount
System/KnapSack/Logic/ItemTipsModel.cs
@@ -15,7 +15,6 @@
        FuncConfigConfig exhaustedFunc;
        Dictionary<int, List<int>> equipLegendAttrTypeDict { get; set; }
        Dictionary<int, Dictionary<int, string>> wingsLegendAttrColorDict { get; set; }
        public Dictionary<string, Dictionary<LegendAttrType, int>> legendAttrCntPreviewDict { get; private set; } // key 品质+星级  value 属性条目数
@@ -97,21 +96,9 @@
            PeerlessEquipIds = ConfigParse.GetMultipleStr<int>(EquipOutWordID.Numerical1);
            FuncConfigConfig legendAttrColor = FuncConfigConfig.Get("LegendAttrColor");
            equipLegendAttrTypeDict = new Dictionary<int, List<int>>();
            wingsLegendAttrColorDict = new Dictionary<int, Dictionary<int, string>>();
            if (legendAttrColor != null)
            {
                JsonData jsonData = JsonMapper.ToObject(legendAttrColor.Numerical1);
                foreach (var key in jsonData.Keys)
                {
                    List<int> attrIDlist = new List<int>();
                    equipLegendAttrTypeDict.Add(int.Parse(key), attrIDlist);
                    for (int i = 0; i < jsonData[key].Count; i++)
                    {
                        attrIDlist.Add((int)jsonData[key][i]);
                    }
                }
                JsonData jsonData2 = JsonMapper.ToObject(legendAttrColor.Numerical2);
                foreach (var key in jsonData2.Keys)
                {
@@ -2028,14 +2015,7 @@
        private int GetLegendType(int id)
        {
            foreach (var key in equipLegendAttrTypeDict.Keys)
            {
                if (equipLegendAttrTypeDict[key].Contains(id))
                {
                    return key;
                }
            }
            return 0;
            return (int)ItemLegendPropertyUtility.GetEquipPropertyType(id);
        }
        private int GetDogzLegendType(int id)