using System; 
 | 
using System.Collections.Generic; 
 | 
using System.Linq; 
 | 
using System.Text.RegularExpressions; 
 | 
  
 | 
public partial class PlayerPropertyConfig : ConfigBase<int, PlayerPropertyConfig> 
 | 
{ 
 | 
    public const int baseType = 1;  //基础属性 
 | 
    public const int fightType = 2; //战斗属性 
 | 
    public const int fightAntiType = 3; //战斗抗性 
 | 
    public const int specialType = 4; //特殊属性 
 | 
  
 | 
    // 按显示类型分 
 | 
    private static Dictionary<int, List<int>> m_PlayerPropertyDict = new Dictionary<int, List<int>>(); 
 | 
    public static Dictionary<int, List<int>> playerPropertyDict 
 | 
    { 
 | 
        get 
 | 
        { 
 | 
            if (m_PlayerPropertyDict.IsNullOrEmpty()) 
 | 
                RefreshShowDict(); 
 | 
            return m_PlayerPropertyDict; 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public static int[] inheritAttrs = new int[] { 13, 14, 15 }; 
 | 
  
 | 
  
 | 
    //不同的功能表调用对应自己的功能含义和使用方式,如阵容光环配置就用在对应计算层 
 | 
    public static int[] basePerAttrs = new int[] { 16, 17, 18 }; 
 | 
  
 | 
    public static int[] baseAttrs = new int[] { 6, 7, 8 }; 
 | 
  
 | 
    // 映射对应的百分比属性,方便使用,如计算属性需要找对应的百分比加成 
 | 
    public static Dictionary<int, int> baseAttr2perDict = new Dictionary<int, int>() 
 | 
    { 
 | 
        { 6,16 }, 
 | 
        { 7,17 }, 
 | 
        { 8,18 } 
 | 
    }; 
 | 
  
 | 
    private static Dictionary<int, List<int>> RefreshShowDict() 
 | 
    { 
 | 
        if (m_PlayerPropertyDict.IsNullOrEmpty()) 
 | 
        { 
 | 
            var keys = GetKeys(); 
 | 
            for (int i = 0; i < keys.Count; i++) 
 | 
            { 
 | 
                int id = keys[i]; 
 | 
                int showType = Get(id).showType; 
 | 
                if (showType == 0)  //为0时不显示 
 | 
                    continue; 
 | 
                if (!m_PlayerPropertyDict.ContainsKey(showType)) 
 | 
                { 
 | 
                    m_PlayerPropertyDict[showType] = new List<int> { id }; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    m_PlayerPropertyDict[showType].Add(id); 
 | 
                } 
 | 
            } 
 | 
            foreach (var showType in m_PlayerPropertyDict.Keys) 
 | 
            { 
 | 
                m_PlayerPropertyDict[showType].Sort(cmp); 
 | 
            } 
 | 
        } 
 | 
        return m_PlayerPropertyDict; 
 | 
    } 
 | 
  
 | 
    static int cmp(int id1, int id2) 
 | 
    { 
 | 
        var config1 = Get(id1); 
 | 
        var config2 = Get(id2); 
 | 
  
 | 
        return config1.showSequence.CompareTo(config2.showSequence); 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
    public static string GetFullDescription(Int2 property) 
 | 
    { 
 | 
        return GetFullDescription(property.x, property.y); 
 | 
    } 
 | 
  
 | 
    public static string GetFullDescription(int id, long value, string format="{0}+{1}") 
 | 
    { 
 | 
        var config = Get(id); 
 | 
        if (config == null) 
 | 
        { 
 | 
            return string.Empty; 
 | 
        } 
 | 
  
 | 
        if (config.ShowName.Contains("%s")) 
 | 
        { 
 | 
            // if (id == 52) 
 | 
            // { 
 | 
            //     return Regex.Replace(config.ShowName, "%s", (value * 0.0001f).ToString("f2")); 
 | 
            // } 
 | 
            // else 
 | 
            { 
 | 
                return Regex.Replace(config.ShowName, "%s", value.ToString()); 
 | 
            } 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            return string.Format(format, config.ShowName, GetValueDescription(id, value)); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public static string GetValueDescription(int id, long value) 
 | 
    { 
 | 
        return GetValueDescription(id, value, true); 
 | 
    } 
 | 
  
 | 
    public static string GetValueDescription(int id, long value, bool largeValue) 
 | 
    { 
 | 
        var config = Get(id); 
 | 
        if (config == null) 
 | 
        { 
 | 
            return string.Empty; 
 | 
        } 
 | 
  
 | 
        double result = 0f; 
 | 
        if (config.ISPercentage == 0) 
 | 
        { 
 | 
            result = value; 
 | 
        } 
 | 
        else if (config.ISPercentage == 1) 
 | 
        { 
 | 
            result = (double)Math.Round(value / 100f, config.decimalCount); 
 | 
        } 
 | 
        else if (config.ISPercentage == 2) 
 | 
        { 
 | 
            result = (double)Math.Round(value / 100f, config.decimalCount); 
 | 
        } 
 | 
  
 | 
        var label = string.Empty; 
 | 
        if (largeValue) 
 | 
        { 
 | 
            label = UIHelper.ReplaceLargeNum(result); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            label = result.ToString(); 
 | 
        } 
 | 
  
 | 
        return config.ISPercentage == 1 ? (label + "%") : label; 
 | 
    } 
 | 
} 
 |