From 9d6b41ab1727ea544629dfc81e5395b2eb6964b5 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期一, 29 九月 2025 02:31:49 +0800
Subject: [PATCH] 197 子 【内政】淘金系统 / 【内政】淘金系统-客户端

---
 Main/System/Main/FightPowerManager.cs |  717 +++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 521 insertions(+), 196 deletions(-)

diff --git a/Main/System/Main/FightPowerManager.cs b/Main/System/Main/FightPowerManager.cs
index dfc2a0f..37b1765 100644
--- a/Main/System/Main/FightPowerManager.cs
+++ b/Main/System/Main/FightPowerManager.cs
@@ -1,236 +1,561 @@
-锘縰sing System.Collections;
+锘縰sing System;
+using System.Collections;
 using System.Collections.Generic;
+using System.Linq;
 using UnityEngine;
+using LitJson;
+using Spine;
 
-
+//锛佸崟鑻遍泟鏌ョ湅鎴樺姏 鍙畻鑷繁鐨勪笂闃靛睘鎬�  涓嶇畻缇佺粖 鎬讳笂闃靛睘鎬�  鍏夌幆
+// 鎴樺姏鐨勮绠楁柟寮�
+//  鍏堢畻涓婇樀鐨勫崟姝﹀皢鎴樺姏鎸夊叕寮忎竴涓�绠楀嚭鍚勪釜灞炴�э紙鍩虹/鎴樻枟锛夛紝鍐嶆妸绠楀嚭鏉ョ殑鍚勪釜灞炴�т唬鍏ュ埌鎴樺姏鍏紡
+//  鎵�鏈夋灏嗘垬鍔涘姞璧锋潵 + 鎶�鑳芥垬鍔涙眹鎬伙紙鍏紡锛夊氨鏄暣涓彿鐨勬垬鍔�
 public class FightPowerManager : Singleton<FightPowerManager>
 {
-    string propertyFormula;
+    public string propertyFormula;
+    public string fightPropertyFormula;
+    public string fightPowerFormula;
+    public string skillFightPowerFormula;
+
+    Dictionary<string, double> propertyVariables = new Dictionary<string, double>();
+    Dictionary<string, double> fightPowerVariables = new Dictionary<string, double>();  //鎬绘垬鍔涗腑鐨勫崟姝﹀皢鎴樺姏
+
 
     public FightPowerManager()
     {
+        // 鏁板��1锛氬熀纭�涓夌淮灞炴�ц绠楀叕寮�
+        // 鏁板��2锛氭垬鏂楀睘鎬�/鎴樻枟鎶楁��/鐗规畩灞炴�ц绠楀叕寮�
+        // 鏁板��3锛氬睘鎬ф垬鍔涜绠楀叕寮忥紝璁$畻鍙傛暟璇﹁ S.灞炴�ф潯鐩厤缃�
         var config = FuncConfigConfig.Get("HeroAttrFormula");
         propertyFormula = config.Numerical1;
+        fightPropertyFormula = config.Numerical2;
+        fightPowerFormula = config.Numerical3;
+        skillFightPowerFormula = config.Numerical4;
+        JaceCalculator.Init();
     }
 
+    #region 鍒濆鍖栨垬鍔涜绠楃殑淇℃伅
+    TeamType teamTypeCalc = TeamType.Story; //涓嶅悓闃靛鎴樺姏涓嶅悓
+    bool isPreviewTeamPower;  //棰勮闃靛锛堥槦浼嶏級鎴樺姏
+    int dropIndexCalc = -1; //鎺夎惤瑁呭鍦ㄩ樀瀹圭殑绱㈠紩锛岀敤浜庨瑙堟垬鍔涘姣�
 
-    //瑁呭鎴樺姏涓烘渶缁堟�绘垬鍔涚殑缁撴灉姣旓紙鎻愬崌鏁翠釜瑙掕壊鎬绘垬鍔涳級
-    public int CalculatePower(int level)
+    //璁$畻闃靛鎴樺姏锛岃澶囧姣旂瓑鎯呭喌闇�瑕佷唬鍏�
+    /// <summary>
+    /// 
+    /// </summary>
+    /// <param name="teamType">闃靛绫诲瀷</param>
+    /// <param name="dropindex">鎺夎惤瑁呭鐨勭储寮曪紝-1浠h〃涓嶆浛鎹㈣绠�</param>
+    /// <param name="ispreview">棰勮闃靛鎴樺姏</param>
+    public void InitFightPowerParam(TeamType teamType = TeamType.Story, int dropindex = -1, bool ispreview = false)
     {
-        // Equation.Instance.Clear();
-        // Equation.Instance.AddKeyValue("equipScoreTotal", CountEquipScore(level));
-        // var power = Equation.Instance.Eval<int>(scoreFormula);
+        teamTypeCalc = teamType;
+        isPreviewTeamPower = ispreview;
 
-        // 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;
+        dropIndexCalc = dropindex;
+#if UNITY_EDITOR
+        Debug.Log("鎴樺姏锛氬垵濮嬪寲鍙傛暟 dropIndex锛�" + dropIndexCalc + " 闃靛瀷锛�" + teamTypeCalc + " ispreview:" + ispreview);
+#endif
+    }
+    #endregion
 
 
-        return 0;
+
+    #region 鍏堣绠楁墍鏈夊姛鑳界殑姹囨�诲睘鎬�
+
+    //鍔熻兘灞炴�� 绫诲瀷锛氬��
+    public Dictionary<int, int> lvAttrs = new Dictionary<int, int>();  //绛夌骇灞炴��
+    public Dictionary<int, int> officialAttrs = new Dictionary<int, int>();  //瀹樿亴灞炴��
+
+    //鍒嗗紑瀛樺偍棰勮鍜� 鐪熷疄灞炴��
+    public Dictionary<int, int> equipAttrs = new Dictionary<int, int>();   //瑁呭灞炴��
+    public Dictionary<string, int> lineUpPerDict = new Dictionary<string, int>();  //闃靛灞炴�у姞鎴�
+    public Dictionary<int, int> countryAttrs = new Dictionary<int, int>();   //闃靛鍥藉锛堝厜鐜級灞炴��
+
+    //绛夌骇灞炴��
+    void RefreshLVAttrs()
+    {
+        lvAttrs.Clear();
+        var playerLVConfig = PlayerLVConfig.Get(PlayerDatas.Instance.baseData.LV);
+        foreach (var attrType in PlayerPropertyConfig.baseAttrs)
+        {
+            lvAttrs[attrType] = GetPlayerLVValue(playerLVConfig, attrType);
+        }
+#if UNITY_EDITOR
+        Debug.Log("鎴樺姏锛氱瓑绾у睘鎬� " + JsonMapper.ToJson(lvAttrs));
+#endif
+
     }
 
-    //鍜岃韩涓婅澶囧姣�
-    public long GetFightPowerChange(ItemModel item)
+    public int GetPlayerLVValue(PlayerLVConfig config, int type)
     {
+        if (type == 6)
+        {
+            return config.Atk;
+        }
+        else if (type == 7)
+        {
+            return config.Def;
+        }
+        else if (type == 8)
+        {
+            return config.MaxHP;
+        }
         return 0;
     }
 
 
-
-
-    class Properties
+    //瀹樿亴灞炴��
+    void RefreshOfficialAttrs()
     {
-        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)
+        officialAttrs.Clear();
+        var config = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel);
+        for (int i = 0; i < config.AddAttrType.Length; i++)
         {
-            if (id == 7)
-            {
-                Add(67, value);
-                Add(68, value);
-            }
-            else
-            {
-                if (tables.ContainsKey(id))
-                {
-                    tables[id] = tables[id] + value;
-                }
-                else
-                {
-                    tables[id] = value;
-                }
-            }
+            var id = config.AddAttrType[i];
+            officialAttrs[id] = config.AddAttrNum[i];
         }
-
-        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]);
-            }
-        }
+#if UNITY_EDITOR
+        Debug.Log("鎴樺姏锛氬畼鑱屽睘鎬� " + JsonMapper.ToJson(officialAttrs));
+#endif
 
     }
 
+    //瑁呭灞炴��:韬笂瑁呭姹囨��
+    void RefrehEquipAttrs()
+    {
+        equipAttrs.Clear();  //韬笂瑁呭灞炴�ч噸缃�
+        for (int i = 0; i < EquipModel.TotleEquip; i++)
+        {
+            var equip = EquipModel.Instance.GetEquip(i);
+            if (dropIndexCalc != -1)
+            {
+                var dropEquip = PackManager.Instance.GetItemByIndex(PackType.DropItem, dropIndexCalc);
+                if (dropEquip.config.EquipPlace - 1 == i)
+                {
+                    equip = dropEquip;  //鏇挎崲璁$畻鎬绘垬鍔�
+                }
+            }
+            if (equip == null)
+            {
+                continue;
+            }
+            var baseIDAttrs = EquipModel.Instance.GetEquipBaseAttrs(equip);
+            var baseVauleAttrs = EquipModel.Instance.GetEquipBaseValues(equip);
+            if (baseIDAttrs != null)
+            {
+                for (int j = 0; j < baseIDAttrs.Count; j++)
+                {
+                    if (!equipAttrs.ContainsKey(baseIDAttrs[j]))
+                    {
+                        equipAttrs[baseIDAttrs[j]] = baseVauleAttrs[j];
+                    }
+                    else
+                    {
+                        equipAttrs[baseIDAttrs[j]] += baseVauleAttrs[j];
+                    }
+                }
+            }
 
+            var fightIDAttrs = EquipModel.Instance.GetEquipFightAttrs(equip);
+            var fightValueAttrs = EquipModel.Instance.GetEquipFightValues(equip);
+            if (fightIDAttrs != null)
+            {
+                for (int j = 0; j < fightIDAttrs.Count; j++)
+                {
+                    if (!equipAttrs.ContainsKey(fightIDAttrs[j]))
+                    {
+                        equipAttrs[fightIDAttrs[j]] = fightValueAttrs[j];
+                    }
+                    else
+                    {
+                        equipAttrs[fightIDAttrs[j]] += fightValueAttrs[j];
+                    }
+                }
+            }
+        }
 
-    #region 璁$畻鎴樻枟鍔�
-    public static readonly string FightPowerFormula = "FightpowerFormula";
+#if UNITY_EDITOR
+        Debug.Log("鎴樺姏锛氳澶囧睘鎬� " + JsonMapper.ToJson(equipAttrs));
+#endif
+    }
 
-    // public static int GetFightPower(Dictionary<int, int> _propertyDict)
-    // {
-    //     Equation.Instance.Clear();
-    //     if (_propertyDict == null || _propertyDict.Count == 0)
-    //     {
-    //         return 0;
-    //     }
+    // 璁$畻闃熶紞涓笂闃电殑鎵�鏈夋灏嗙殑涓婇樀灞炴�� 鍜� 鍏夌幆
+    void RefreshTeamAttrs()
+    {
+        //闃靛灞炴��
+        // 闃靛锛氭墍鏈夋灏嗕笂闃靛睘鎬�
+        lineUpPerDict = HeroUIManager.Instance.GetLineupPer(teamTypeCalc, isPreviewTeamPower);
 
-    //     foreach (var _key in _propertyDict.Keys)
-    //     {
-    //         PlayerPropertyConfig cfg = PlayerPropertyConfig.Get(_key);
-    //         if (cfg != null)
-    //         {
-    //             if (_key == 7)
-    //             {
-    //                 Equation.Instance.AddKeyValue("MinAtk", _propertyDict[_key]);
-    //                 Equation.Instance.AddKeyValue("MaxAtk", _propertyDict[_key]);
-    //             }
-    //             else if (_key == 24)
-    //             {
-    //                 Equation.Instance.AddKeyValue("PetMinAtk", _propertyDict[_key]);
-    //                 Equation.Instance.AddKeyValue("PetMaxAtk", _propertyDict[_key]);
-    //             }
-    //             else
-    //             {
-    //                 ulong attrValue = (ulong)_propertyDict[_key];
-    //                 var fightParm = GetFightPowerParmByAttrId(_key);
-    //                 if (_key == 11)
-    //                 {
-    //                     var playerLv = PlayerDatas.Instance.baseData.LV;
-    //                     var paramConfig = FightPowerParamConfig.Get(playerLv);
-    //                     Equation.Instance.AddKeyValue("AtkSpeedParameter", paramConfig.AtkSpeedParameter);
-    //                 }
-    //                 else
-    //                 {
-    //                     if (fightParm != 0)
-    //                     {
-    //                         attrValue = attrValue * (ulong)fightParm;
-    //                     }
-    //                 }
-    //                 Equation.Instance.AddKeyValue(cfg.Parameter, attrValue);
-    //             }
-    //         }
-
-    //     }
-    //     FuncConfigConfig funcCfg = FuncConfigConfig.Get(FightPowerFormula);
-    //     return Equation.Instance.Eval<int>(funcCfg.Numerical1);
-    // }
-
-    // public static int GetFightPowerParmByAttrId(int attrId)
-    // {
-    //     int playerLv = PlayerDatas.Instance.baseData.LV;
-    //     FightPowerParamConfig paramConfig = FightPowerParamConfig.Get(playerLv);
-    //     PlayerPropertyConfig cfg = PlayerPropertyConfig.Get(attrId);
-    //     if (paramConfig == null || cfg == null) return 0;
-
-    //     switch (cfg.Parameter)
-    //     {
-    //         case "Hit":
-    //             return paramConfig.Hit;
-    //         case "Miss":
-    //             return paramConfig.Miss;
-    //         case "IgnoreDefRate":
-    //             return paramConfig.IgnoreDefRate;
-    //         case "DamChanceDef":
-    //             return paramConfig.DamChanceDef;
-    //         case "FaintRate":
-    //             return paramConfig.FaintRate;
-    //         case "LuckyHitRateReduce":
-    //             return paramConfig.LuckyHitRateReduce;
-    //         case "SkillAtkRate":
-    //             return paramConfig.SkillAtkRate;
-    //         case "SkillAtkRateReduce":
-    //             return paramConfig.SkillAtkRateReduce;
-    //         case "DamagePerPVP":
-    //             return paramConfig.DamagePerPVP;
-    //         case "DamagePerPVPReduce":
-    //             return paramConfig.DamagePerPVPReduce;
-    //         case "DamBackPer":
-    //             return paramConfig.DamBackPer;
-    //         case "IgnoreDefRateReduce":
-    //             return paramConfig.IgnoreDefRateReduce;
-    //         case "FaintDefRate":
-    //             return paramConfig.FaintDefRate;
-    //         case "AtkSpeedParameter":
-    //             return paramConfig.AtkSpeedParameter;
-    //         case "JobAHurtAddPer":
-    //             return paramConfig.JobAHurtAddPer;
-    //         case "JobBHurtAddPer":
-    //             return paramConfig.JobBHurtAddPer;
-    //         case "JobCHurtAddPer":
-    //             return paramConfig.JobCHurtAddPer;
-    //         case "JobAAtkReducePer":
-    //             return paramConfig.JobAAtkReducePer;
-    //         case "JobBAtkReducePer":
-    //             return paramConfig.JobBAtkReducePer;
-    //         case "JobCAtkReducePer":
-    //             return paramConfig.JobCAtkReducePer;
-    //         case "SuperHitRate":
-    //             return paramConfig.SuperHitRate;
-    //         case "LuckyHitRate":
-    //             return paramConfig.LuckyHitRate;
-    //         case "SuperHitRateReduce":
-    //             return paramConfig.SuperHitRateReduce;
-    //         case "FinalHurtPer":
-    //             return paramConfig.FinalHurtPer;
-    //         case "FinalHurtReducePer":
-    //             return paramConfig.FinalHurtReducePer;
-    //         case "NPCHurtAddPer":
-    //             return paramConfig.NPCHurtAddPer;
-    //         case "NormalHurtPer":
-    //             return paramConfig.NormalHurtPer;
-    //         case "FabaoHurtPer":
-    //             return paramConfig.FabaoHurtPer;
-    //         case "AffairSpeedPer":
-    //             return paramConfig.AffairSpeedPer;
-    //         case "FamilyBossHurtPer":
-    //             return paramConfig.FamilyBossHurtPer;
-    //         case "FamilyWarHPPer":
-    //             return paramConfig.FamilyWarHPPer;
-    //         case "FamilyWarAtkPer":
-    //             return paramConfig.FamilyWarAtkPer;
-    //         case "FamilySitExpPer":
-    //             return paramConfig.FamilySitExpPer;
-    //         case "BossFinalHurtPer":
-    //             return paramConfig.BossFinalHurtPer;
-    //     }
-
-    //     return 0;
-    // }
+#if UNITY_EDITOR
+        Debug.Log("鎴樺姏锛氫笂闃靛睘鎬� " + JsonMapper.ToJson(lineUpPerDict));
+#endif
+        // 闃靛锛氬浗瀹讹紙鍏夌幆锛夊睘鎬�
+        countryAttrs = HeroUIManager.Instance.GetCountryAttrs(teamTypeCalc, isPreviewTeamPower);
+#if UNITY_EDITOR
+        Debug.Log("鎴樺姏锛氬浗瀹讹紙鍏夌幆锛夊睘鎬� " + JsonMapper.ToJson(countryAttrs));
+#endif
+    }
 
     #endregion
 
+    //鍗曞睘鎬у叕寮忓垎鍩虹涓夌淮鍜屾垬鏂楀睘鎬�
+    // 銆愪富鍏睘鎬с��
+    // 绛夌骇灞炴��    lvValue
+    // 瑁呭灞炴��    equipValue
+    // 鍥鹃壌灞炴��    bookValue 銆� bookPer
+
+    // 銆愰樀瀹瑰睘鎬с�� - 璇ラ樀瀹规墍鏈夋灏嗘湁鏁�
+    // 鍒濆鍔犳垚    lineupInitAddPer
+    // 鍗囩骇鍔犳垚    lineupLVAddPer
+    // 绐佺牬鍔犳垚    lineupBreakLVAddPer
+    // 鍚炲櫖鍔犳垚    lineupStarAddPer
+    // 闃靛鍏夌幆    lineupHaloValue 銆� lineupHaloPer
+
+    // 銆愭灏嗗睘鎬с��
+    // 缁ф壙姣斾緥    inheritPer
+    // 鑷韩灞炴��    heroSelfValue 銆� heroSelfPer
+    // 鍚炲櫖灞炴��    starTalentValue 銆� starTalentPer
+    // 绐佺牬灞炴��    breakLVValue 銆� breakLVPer
+    // 瑙夐啋灞炴��    awakeTalentValue 銆� awakeTalentPer
+    // 缇佺粖灞炴��    fetterValue 銆� fetterPer
+
+    #region 灞炴�у叕寮�
+    // 鍗曞熀纭�灞炴�ц绠�
+    public double GetPropertyVaule(int attrType, HeroInfo hero, string formula)
+    {
+        propertyVariables.Clear();
+        propertyVariables["lvValue"] = lvAttrs.ContainsKey(attrType) ? lvAttrs[attrType] : 0;
+        propertyVariables["equipValue"] = equipAttrs.ContainsKey(attrType) ? equipAttrs[attrType] : 0;
+        propertyVariables["bookValue"] = 0;
+        propertyVariables["bookPer"] = GetBookPer(attrType) / 10000.0f;
+        propertyVariables["realmValue"] = officialAttrs.ContainsKey(attrType) ? officialAttrs[attrType] : 0;
+        propertyVariables["realmPer"] = GetOfficialPer(attrType) / 10000.0f;
+
+        //锛侊紒锛佸崟姝﹀皢鎴樺姏棰勮鐨勮瘽闇�瑕佹帓闄ら槦浼嶅奖鍝嶆垬鍔涳紝鍙畻姝﹀皢鑷韩鐨勪笂闃靛睘鎬�
+        propertyVariables["lineupInitAddPer"] = GetLineUpPer(attrType, "lineupInitAddPer") / 10000.0f;
+        propertyVariables["lineupLVAddPer"] = GetLineUpPer(attrType, "lineupLVAddPer") / 10000.0f;
+        propertyVariables["lineupBreakLVAddPer"] = GetLineUpPer(attrType, "lineupBreakLVAddPer") / 10000.0f;
+        propertyVariables["lineupStarAddPer"] = GetLineUpPer(attrType, "lineupStarAddPer") / 10000.0f;
+
+        //闃靛鍏夌幆 涓夊洿鐧惧垎姣斿姞鎴�
+        propertyVariables["lineupHaloValue"] = countryAttrs.ContainsKey(attrType) ? countryAttrs[attrType] : 0;
+        propertyVariables["lineupHaloPer"] = GetCountryPer(attrType) / 10000.0f;
+
+
+        //姝﹀皢灞炴��
+        propertyVariables["inheritPer"] = hero.GetInheritAttrPer(attrType) / 10000.0f;
+        propertyVariables["heroSelfValue"] = hero.GetSelfAddValue(attrType);
+        propertyVariables["heroSelfPer"] = hero.GetSelfAddPer(attrType) / 10000.0f;
+        propertyVariables["starTalentValue"] = hero.GetTalentAttrValue(attrType);
+        propertyVariables["starTalentPer"] = hero.GetTalentAttrPer(attrType) / 10000.0f;
+        propertyVariables["breakLVValue"] = hero.GetBreakAttrValue(attrType);
+        propertyVariables["breakLVPer"] = hero.GetBreakAttrPer(attrType) / 10000.0f;
+        propertyVariables["awakeTalentValue"] = hero.GetAwakeAttrValue(attrType);
+        propertyVariables["awakeTalentPer"] = hero.GetAwakeAttrPer(attrType) / 10000.0f;
+        propertyVariables["fetterValue"] = hero.GetFetterAttrValue(attrType);
+        propertyVariables["fetterPer"] = hero.GetFetterAttrPer(attrType) / 10000.0f;
+
+#if UNITY_EDITOR
+        //鎺掗櫎鍊间负0鐨勫睘鎬ц緭鍑�
+        var tmpPropertyVariables = propertyVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value);
+        if (!tmpPropertyVariables.IsNullOrEmpty())
+            propertyStrForDebug += $"灞炴�D {attrType} - {JsonMapper.ToJson(tmpPropertyVariables)}";
+#endif
+        return JaceCalculator.Calculate(formula, propertyVariables);
+    }
+
+
+    int GetLineUpPer(int attrType, string key)
+    {
+        if (!PlayerPropertyConfig.baseAttrs.Contains(attrType))
+        {
+            return 0;
+        }
+
+        return lineUpPerDict[key];
+    }
+
+    int GetBookPer(int attrType)
+    {
+        if (!PlayerPropertyConfig.baseAttrs.Contains(attrType))
+        {
+            return 0;
+        }
+        return HeroUIManager.Instance.allHeroBookPer;
+    }
+
+    int GetOfficialPer(int attrType)
+    {
+        if (PlayerPropertyConfig.baseAttr2perDict.ContainsKey(attrType))
+        {
+            var pertype = PlayerPropertyConfig.baseAttr2perDict[attrType];
+            return officialAttrs.ContainsKey(pertype) ? officialAttrs[pertype] : 0;
+        }
+
+        return 0;
+    }
+
+    int GetCountryPer(int attrType)
+    {
+        if (PlayerPropertyConfig.baseAttr2perDict.ContainsKey(attrType))
+        {
+            var pertype = PlayerPropertyConfig.baseAttr2perDict[attrType];
+            return countryAttrs.ContainsKey(pertype) ? countryAttrs[pertype] : 0;
+        }
+
+        return 0;
+    }
+
+
+
+    #endregion
+
+
+    #region 璁$畻鎴樺姏
+    //濡傛灉鏈嶅姟绔垬鍔涜绠楁湁鍘嬪姏锛屽彲鏀规垚鍏抽敭鐐圭粨绠楋紙濡傚悓姝ユ帓琛屾璺ㄦ湇绛夛級锛岃〃鐜扮敱瀹㈡埛绔嚜宸辫绠�
+    //瑁呭鎴樺姏涓烘渶缁堟�绘垬鍔涚殑缁撴灉姣旓紙鎻愬崌鏁翠釜瑙掕壊鎬绘垬鍔涳級
+
+    //璁$畻鎬绘垬鍔涗腑鐨勬灏嗘垬鍔涳紝鍑犱釜姝﹀皢鍔犺捣鏉ュ氨鏄�绘垬鍔涳紝鍏朵粬鍔熻兘灞炴�ц绠楀簲璇ユ兜鐩栧湪鑻遍泟閲�
+    public long CalculatePower()
+    {
+#if UNITY_EDITOR
+        Debug.Log("鎴樺姏锛氬紑濮嬭绠�");
+#endif
+        // --- 鍏堣绠楁墍鏈夊姛鑳界殑姹囨�诲睘鎬� ---
+        RefreshLVAttrs();
+        RefreshOfficialAttrs();
+        RefrehEquipAttrs();
+        RefreshTeamAttrs();
+
+
+        // --- 绠楀崟姝﹀皢鍔熻兘灞炴�ф垬鍔� 鍚庣浉鍔�---
+        long fightPower = 0;
+        var team = TeamManager.Instance.GetTeam(teamTypeCalc);
+        if (team == null)
+        {
+            return fightPower;
+        }
+        TeamHero[] teamHeroes = isPreviewTeamPower ? team.tempHeroes : team.serverHeroes;
+        foreach (var hero in teamHeroes)
+        {
+            if (hero == null)
+            {
+                continue;
+            }
+            HeroInfo heroInfo = HeroManager.Instance.GetHero(hero.guid);
+            if (heroInfo == null)
+            {
+                continue;
+            }
+
+            fightPower += CalculateTeamHeroPower(heroInfo);
+
+        }
+
+#if UNITY_EDITOR
+        Debug.Log("鎴樺姏锛氳绠楀畬姣� " + fightPower);
+#endif
+        return fightPower;
+    }
+
+#if UNITY_EDITOR
+    string propertyStrForDebug = "";
+#endif
+
+    //璁$畻闃靛涓灏嗘垬鍔�
+    public long CalculateTeamHeroPower(HeroInfo hero)
+    {
+
+        fightPowerVariables.Clear();
+        hero.RefreshFetterAttrsWhenCalcPower(teamTypeCalc); //缇佺粖灞炴�ц瀹炴椂绠�
+
+#if UNITY_EDITOR
+        propertyStrForDebug = "";
+#endif
+        foreach (var config in PlayerPropertyConfig.GetValues())
+        {
+            if (config.showType < 1 || config.showType > 4)
+            {
+                continue;
+            }
+            if (config.showType == 1)
+            {
+                fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, propertyFormula), 3);
+            }
+            else
+            {
+                fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, fightPropertyFormula), 3);
+            }
+        }
+
+#if UNITY_EDITOR
+        Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 灞炴�т俊鎭� {propertyStrForDebug}");
+#endif
+
+        //灞炴�х郴鏁版牴鎹畼鑱岀瓑绾х殑鍔犳垚
+        var fightPowerRatioConfig = FightPowerRatioConfig.Get(PlayerDatas.Instance.baseData.realmLevel);
+
+        fightPowerVariables["AtkRatio"] = fightPowerRatioConfig.AtkRatio;
+        fightPowerVariables["MaxHPRatio"] = fightPowerRatioConfig.MaxHPRatio;
+        fightPowerVariables["DefRatio"] = fightPowerRatioConfig.DefRatio;
+        fightPowerVariables["StunRateRatio"] = fightPowerRatioConfig.StunRateRatio;
+        fightPowerVariables["SuperHitRateRatio"] = fightPowerRatioConfig.SuperHitRateRatio;
+        fightPowerVariables["ComboRateRatio"] = fightPowerRatioConfig.ComboRateRatio;
+        fightPowerVariables["MissRateRatio"] = fightPowerRatioConfig.MissRateRatio;
+        fightPowerVariables["ParryRateRatio"] = fightPowerRatioConfig.ParryRateRatio;
+        fightPowerVariables["SuckHPPerRatio"] = fightPowerRatioConfig.SuckHPPerRatio;
+        fightPowerVariables["StunRateDefRatio"] = fightPowerRatioConfig.StunRateDefRatio;
+        fightPowerVariables["SuperHitRateDefRatio"] = fightPowerRatioConfig.SuperHitRateDefRatio;
+        fightPowerVariables["ComboRateDefRatio"] = fightPowerRatioConfig.ComboRateDefRatio;
+        fightPowerVariables["MissRateDefRatio"] = fightPowerRatioConfig.MissRateDefRatio;
+        fightPowerVariables["ParryRateDefRatio"] = fightPowerRatioConfig.ParryRateDefRatio;
+        fightPowerVariables["SuckHPPerDefRatio"] = fightPowerRatioConfig.SuckHPPerDefRatio;
+        fightPowerVariables["NormalSkillPerRatio"] = fightPowerRatioConfig.NormalSkillPerRatio;
+        fightPowerVariables["NormalSkillPerDefRatio"] = fightPowerRatioConfig.NormalSkillPerDefRatio;
+        fightPowerVariables["AngerSkillPerRatio"] = fightPowerRatioConfig.AngerSkillPerRatio;
+        fightPowerVariables["AngerSkillPerDefRatio"] = fightPowerRatioConfig.AngerSkillPerDefRatio;
+        fightPowerVariables["SuperDamPerRatio"] = fightPowerRatioConfig.SuperDamPerRatio;
+        fightPowerVariables["SuperDamPerDefRatio"] = fightPowerRatioConfig.SuperDamPerDefRatio;
+        fightPowerVariables["ShieldPerRatio"] = fightPowerRatioConfig.ShieldPerRatio;
+        fightPowerVariables["ShieldPerDefRatio"] = fightPowerRatioConfig.ShieldPerDefRatio;
+        fightPowerVariables["DOTPerRatio"] = fightPowerRatioConfig.DOTPerRatio;
+        fightPowerVariables["DOTPerDefRatio"] = fightPowerRatioConfig.DOTPerDefRatio;
+        fightPowerVariables["WeiFinalDamPerRatio"] = fightPowerRatioConfig.WeiFinalDamPerRatio;
+        fightPowerVariables["WeiFinalDamPerDefRatio"] = fightPowerRatioConfig.WeiFinalDamPerDefRatio;
+        fightPowerVariables["ShuFinalDamPerRatio"] = fightPowerRatioConfig.ShuFinalDamPerRatio;
+        fightPowerVariables["ShuFinalDamPerDefRatio"] = fightPowerRatioConfig.ShuFinalDamPerDefRatio;
+        fightPowerVariables["WuFinalDamPerRatio"] = fightPowerRatioConfig.WuFinalDamPerRatio;
+        fightPowerVariables["WuFinalDamPerDefRatio"] = fightPowerRatioConfig.WuFinalDamPerDefRatio;
+        fightPowerVariables["QunFinalDamPerRatio"] = fightPowerRatioConfig.QunFinalDamPerRatio;
+        fightPowerVariables["QunFinalDamPerDefRatio"] = fightPowerRatioConfig.QunFinalDamPerDefRatio;
+        fightPowerVariables["FinalDamPerRatio"] = fightPowerRatioConfig.FinalDamPerRatio;
+        fightPowerVariables["FinalDamPerDefRatio"] = fightPowerRatioConfig.FinalDamPerDefRatio;
+        fightPowerVariables["PhyDamPerRatio"] = fightPowerRatioConfig.PhyDamPerRatio;
+        fightPowerVariables["PhyDamPerDefRatio"] = fightPowerRatioConfig.PhyDamPerDefRatio;
+        fightPowerVariables["MagDamPerRatio"] = fightPowerRatioConfig.MagDamPerRatio;
+        fightPowerVariables["MagDamPerDefRatio"] = fightPowerRatioConfig.MagDamPerDefRatio;
+        fightPowerVariables["CurePerRatio"] = fightPowerRatioConfig.CurePerRatio;
+        fightPowerVariables["CurePerDefRatio"] = fightPowerRatioConfig.CurePerDefRatio;
+
+
+        long fightPower = (long)JaceCalculator.Calculate(fightPowerFormula, fightPowerVariables);
+#if UNITY_EDITOR
+        //鎺掗櫎鍊间负0鐨勫睘鎬ц緭鍑�
+        var tmpFightPowerVariables = fightPowerVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value);
+        if (!tmpFightPowerVariables.IsNullOrEmpty())
+            Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 灞炴�ф垬鍔� {fightPower} 灞炴�ф垬鍔涘弬鏁� {JsonMapper.ToJson(tmpFightPowerVariables)}");
+#endif
+
+        //鍔犱笂鎶�鑳芥垬鍔�
+        fightPowerVariables.Clear();
+        fightPowerVariables["PlayerLV"] = PlayerDatas.Instance.baseData.LV;
+        fightPowerVariables["OfficialLV"] = PlayerDatas.Instance.baseData.realmLevel;
+        fightPowerVariables["SkillPower"] = hero.GetSkillsFightPower();
+
+        long skillPower = (long)JaceCalculator.Calculate(skillFightPowerFormula, fightPowerVariables);
+
+#if UNITY_EDITOR
+        Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 鎶�鑳芥垬鍔� {skillPower} 鎶�鑳藉弬鏁� {JsonMapper.ToJson(fightPowerVariables)}");
+
+        Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 鎬绘垬鍔� {fightPower + skillPower}");
+#endif
+
+        return fightPower + skillPower;
+    }
+
+
+    /// <summary>
+    /// 鍜岃韩涓婅澶囧姣斿樊
+    /// </summary>
+    /// <param name="item">鍦版澘瑁呭</param>
+    /// <returns></returns>
+    public long GetFightPowerChange(ItemModel item)
+    {
+        InitFightPowerParam();
+        var fightPower = CalculatePower();
+
+        InitFightPowerParam(dropindex: item.gridIndex);
+        var tmpFightPower = CalculatePower();
+        return tmpFightPower - fightPower;
+    }
+
+
+    // 鍗曡嫳闆勬煡鐪嬫垬鍔� 
+    // 1. 涓婇樀鑻遍泟鏄剧ず锛屽湪涓荤嚎闃靛涓嬬殑鎴樺姏
+    // 2. 闈炰笂闃垫垨鍏朵粬涓婇樀闃靛锛氫笂闃典笉瓒�6涓汉鐨勶紝鎸夊鍔犵殑鏂瑰紡鐨勮绠楋紱浜烘暟婊$殑鎯呭喌涓嬫寜鏇挎崲6鍙蜂綅璁$畻
+    public long GetHeroFightPower(HeroInfo heroInfo)
+    {
+        bool ispreview = false;
+        var team = TeamManager.Instance.GetTeam(TeamType.Story);
+        if (!team.HasHero(heroInfo.itemHero.guid))
+        {
+            //鏇挎崲涓婇樀浣嶇疆
+            ispreview = true;
+            var index = team.GetEmptyPosition();
+            if (index < 0)
+            {
+                team.AddHero(heroInfo, 5);
+            }
+            else
+            {
+                team.AddHero(heroInfo, index);
+            }
+        }
+
+        InitFightPowerParam(ispreview: ispreview);
+        RefreshLVAttrs();
+        RefreshOfficialAttrs();
+        RefrehEquipAttrs();
+        RefreshTeamAttrs();
+
+        var fightPower = CalculateTeamHeroPower(heroInfo);
+
+        //璁$畻瀹屾仮澶嶉槦浼�
+        if (ispreview)
+            team.RestoreTeam();
+        return fightPower;
+    }
+
+
+    //鏌ョ湅闃靛鎴樺姏
+    public long GetTeamFightPower(TeamType team, bool isPreview)
+    {
+        InitFightPowerParam(team, -1, isPreview);
+        return CalculatePower();
+    }
+    #endregion
+
+
+    public Dictionary<int, long> GetHeroTotalAttr(HeroInfo hero)
+    {
+
+        Dictionary<int, long> tmpAttrs = new Dictionary<int, long>();
+        hero.RefreshFetterAttrsWhenCalcPower(TeamType.Story); //缇佺粖灞炴�ц瀹炴椂绠�
+
+#if UNITY_EDITOR
+        propertyStrForDebug = "";
+#endif
+
+        foreach (var config in PlayerPropertyConfig.GetValues())
+        {
+            if (config.showType < 1 || config.showType > 4)
+            {
+                continue;
+            }
+            if (config.showType == 1)
+            {
+                tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, propertyFormula);
+            }
+            else
+            {
+                tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, fightPropertyFormula);
+            }
+        }
+#if UNITY_EDITOR
+        Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 灞炴�т俊鎭� {propertyStrForDebug}");
+#endif
+        return tmpAttrs;
+    }
 }
 
 

--
Gitblit v1.8.0