using System.Collections; 
 | 
using System.Collections.Generic; 
 | 
using UnityEngine; 
 | 
  
 | 
  
 | 
public class EquipFightPower : Singleton<EquipFightPower> 
 | 
{ 
 | 
    string scoreFormula; 
 | 
    string propertyFormula; 
 | 
  
 | 
    public EquipFightPower() 
 | 
    { 
 | 
        var config = FuncConfigConfig.Get("FightpowerFormula"); 
 | 
        propertyFormula = config.Numerical1; 
 | 
        scoreFormula = config.Numerical2; 
 | 
    } 
 | 
  
 | 
    public int GetSpiritWeaponPower(int itemId) 
 | 
    { 
 | 
        var score = ItemLogicUtility.Instance.GetEquipScore(itemId); 
 | 
        Equation.Instance.Clear(); 
 | 
        Equation.Instance.AddKeyValue("equipScoreTotal", score); 
 | 
        return Equation.Instance.Eval<int>(scoreFormula); 
 | 
    } 
 | 
  
 | 
    public int CalculatePower(int level) 
 | 
    { 
 | 
        Equation.Instance.Clear(); 
 | 
        Equation.Instance.AddKeyValue("equipScoreTotal", CountEquipScore(level)); 
 | 
        var power = Equation.Instance.Eval<int>(scoreFormula); 
 | 
  
 | 
        var propertyContainer = new Properties(); 
 | 
  
 | 
        Equation.Instance.Clear(); 
 | 
        var keys = propertyContainer.keys; 
 | 
        for (int i = 0; i < keys.Count; i++) 
 | 
        { 
 | 
            var id = keys[i]; 
 | 
            var value = propertyContainer[id]; 
 | 
            var config = PlayerPropertyConfig.Get(id); 
 | 
            Equation.Instance.AddKeyValue(config.Parameter, value); 
 | 
        } 
 | 
  
 | 
        var propertyPower = Equation.Instance.Eval<int>(propertyFormula); 
 | 
        power += propertyPower; 
 | 
  
 | 
  
 | 
        return power; 
 | 
    } 
 | 
  
 | 
    private int CountEquipScore(int level) 
 | 
    { 
 | 
        var score = 0; 
 | 
        // for (int i = 1; i <= 12; i++) 
 | 
        // { 
 | 
        //     var equipPosition = new Int2(level, i); 
 | 
        //     var guid = equipModel.GetEquip(equipPosition); 
 | 
        //     if (string.IsNullOrEmpty(guid)) 
 | 
        //     { 
 | 
        //         continue; 
 | 
        //     } 
 | 
  
 | 
        //     var equip = packModel.GetItemByGuid(guid); 
 | 
        //     if (equip == null) 
 | 
        //     { 
 | 
        //         continue; 
 | 
        //     } 
 | 
  
 | 
        //     score += equip.score; 
 | 
        // } 
 | 
  
 | 
        return score; 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
    public int CalculatePower(int job, int level, List<EquipInfo> equipInfos) 
 | 
    { 
 | 
        var propertyContainer = new Properties(); 
 | 
        var totalScore = 0; 
 | 
  
 | 
  
 | 
        Equation.Instance.Clear(); 
 | 
        Equation.Instance.AddKeyValue("equipScoreTotal", totalScore); 
 | 
        var power = Equation.Instance.Eval<int>(scoreFormula); 
 | 
  
 | 
        Equation.Instance.Clear(); 
 | 
        var keys = propertyContainer.keys; 
 | 
        for (int i = 0; i < keys.Count; i++) 
 | 
        { 
 | 
            var id = keys[i]; 
 | 
            var value = propertyContainer[id]; 
 | 
            var config = PlayerPropertyConfig.Get(id); 
 | 
            if (config != null) 
 | 
            { 
 | 
                Equation.Instance.AddKeyValue(config.Parameter, value); 
 | 
            } 
 | 
  
 | 
        } 
 | 
  
 | 
        power += Equation.Instance.Eval<int>(propertyFormula); 
 | 
  
 | 
        return power; 
 | 
    } 
 | 
  
 | 
    class Properties 
 | 
    { 
 | 
        Dictionary<int, int> tables = new Dictionary<int, int>(); 
 | 
  
 | 
        public List<int> keys { get { return new List<int>(tables.Keys); } } 
 | 
  
 | 
        public int this[int id] { get { return tables[id]; } } 
 | 
  
 | 
        public void Add(int id, int value) 
 | 
        { 
 | 
            if (id == 7) 
 | 
            { 
 | 
                Add(67, value); 
 | 
                Add(68, value); 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                if (tables.ContainsKey(id)) 
 | 
                { 
 | 
                    tables[id] = tables[id] + value; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    tables[id] = value; 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
  
 | 
        public void AddRange(List<int> ids, List<int> values) 
 | 
        { 
 | 
            if (ids.IsNullOrEmpty() || values.IsNullOrEmpty()) 
 | 
            { 
 | 
                return; 
 | 
            } 
 | 
  
 | 
            var count = Mathf.Min(ids.Count, values.Count); 
 | 
            for (int i = 0; i < count; i++) 
 | 
            { 
 | 
                Add(ids[i], values[i]); 
 | 
            } 
 | 
        } 
 | 
  
 | 
    } 
 | 
  
 | 
    public struct EquipInfo 
 | 
    { 
 | 
        public int itemId; 
 | 
        public int score; 
 | 
  
 | 
    } 
 | 
  
 | 
} 
 |