From 38c69309b122bbbc4077fb275cd63f916106e996 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 23 一月 2026 19:53:29 +0800
Subject: [PATCH] 0312 战力计算

---
 Main/System/Main/FightPowerManager.cs |  198 +++++++++++++++++++++++++++++--------------------
 1 files changed, 117 insertions(+), 81 deletions(-)

diff --git a/Main/System/Main/FightPowerManager.cs b/Main/System/Main/FightPowerManager.cs
index 4055c16..d6518d9 100644
--- a/Main/System/Main/FightPowerManager.cs
+++ b/Main/System/Main/FightPowerManager.cs
@@ -156,7 +156,8 @@
         dropIndexCalc = dropindex;
         minggeDropIndex = _minggeDropIndex;
 #if UNITY_EDITOR
-        FightPowerDebug("鎴樺姏锛氬垵濮嬪寲鍙傛暟 dropIndex锛�" + dropIndexCalc + " 闃靛瀷锛�" + teamTypeCalc + " ispreview:" + ispreview);
+        FightPowerDebug("鎴樺姏锛氬垵濮嬪寲鍙傛暟 dropIndex锛�" + dropIndexCalc + " 闃靛瀷锛�" + teamTypeCalc + " ispreview:" + ispreview
+        + " minggePresetID:" + _minggePresetID + " minggeDropIndex:" + _minggeDropIndex);
 #endif
     }
     #endregion
@@ -166,16 +167,16 @@
     #region 鍏堣绠楁墍鏈夊姛鑳界殑姹囨�诲睘鎬�
 
     //鍔熻兘灞炴�� 绫诲瀷锛氬��
-    public Dictionary<int, int> lvAttrs = new Dictionary<int, int>();  //绛夌骇灞炴��
-    public Dictionary<int, int> officialAttrs = new Dictionary<int, int>();  //瀹樿亴灞炴��
+    public Dictionary<int, long> lvAttrs = new Dictionary<int, long>();  //绛夌骇灞炴��
+    public Dictionary<int, long> officialAttrs = new Dictionary<int, long>();  //瀹樿亴灞炴��
 
     //鍒嗗紑瀛樺偍棰勮鍜� 鐪熷疄灞炴��
-    public Dictionary<int, int> equipAttrs = new Dictionary<int, int>();   //瑁呭灞炴��
+    public Dictionary<int, long> equipAttrs = new Dictionary<int, long>();   //瑁呭灞炴��
     // public Dictionary<string, int> lineUpPerDict = new Dictionary<string, int>();  //闃靛灞炴�у姞鎴�
     public Dictionary<int, int> countryAttrs = new Dictionary<int, int>();   //闃靛鍥藉锛堝厜鐜級灞炴��
-    public Dictionary<int, int> minggeAttrs = new Dictionary<int, int>();   //鍛芥牸灞炴�� 鎶�鑳芥垬鍔涗负鍥哄畾鐨勫彧绠椾釜鏁板尯鍒嵆鍙�
+    public Dictionary<int, long> minggeAttrs = new Dictionary<int, long>();   //鍛芥牸灞炴��
 
-    float allHeroAddPer = 0;  //鎵�鏈夋灏嗗姞鎴�
+    double allHeroAddPer = 0;  //鎵�鏈夋灏嗗姞鎴�
 
     //绛夌骇灞炴��
     void RefreshLVAttrs()
@@ -298,7 +299,7 @@
         //闃靛灞炴��
         // 闃靛锛氭墍鏈夋灏嗕笂闃靛睘鎬�
         // lineUpPerDict = HeroUIManager.Instance.GetLineupPer(teamTypeCalc, isPreviewTeamPower);
-        allHeroAddPer = HeroUIManager.Instance.GetAllHeroPer() / 10000.0f;
+        allHeroAddPer = HeroUIManager.Instance.GetAllHeroPer() / 10000.0;
 #if UNITY_EDITOR
         // Debug.Log("鎴樺姏锛氫笂闃靛睘鎬� " + JsonMapper.ToJson(lineUpPerDict));
 #endif
@@ -306,6 +307,7 @@
         countryAttrs = HeroUIManager.Instance.GetCountryAttrs(teamTypeCalc, isPreviewTeamPower);
 #if UNITY_EDITOR
         FightPowerDebug("鎴樺姏锛氬浗瀹讹紙鍏夌幆锛夊睘鎬� " + JsonMapper.ToJson(countryAttrs));
+        FightPowerDebug("鎴樺姏锛氭灏嗘墍鏈夊姞鎴� " + allHeroAddPer);
 #endif
     }
 
@@ -362,6 +364,17 @@
     }
 
 
+    public int GetAttrPer(int attrID, Dictionary<int, long> attrDic)
+    {
+        if (PlayerPropertyConfig.baseAttr2perDict.ContainsKey(attrID))
+        {
+            var pertype = PlayerPropertyConfig.baseAttr2perDict[attrID];
+            attrDic.TryGetValue(pertype, out long value);
+            return (int)(value);
+        }
+        return 0;
+    }
+
     #endregion
 
     //鍗曞睘鎬у叕寮忓垎鍩虹涓夌淮鍜屾垬鏂楀睘鎬�
@@ -395,59 +408,79 @@
         propertyVariables[EQUIP_VALUE] = equipAttrs.ContainsKey(attrType) ? equipAttrs[attrType] : 0;
         // propertyVariables[BOOK_VALUE] = 0;
         propertyVariables[REALM_VALUE] = officialAttrs.ContainsKey(attrType) ? officialAttrs[attrType] : 0;
-        propertyVariables[REALM_PER] = GetOfficialPer(attrType) / 10000.0f;
-        // propertyVariables[BOOK_PER] = GetBookPer(attrType) / 10000.0f;
+        propertyVariables[REALM_PER] = GetAttrPer(attrType, officialAttrs) / 10000.0;
+        // propertyVariables[BOOK_PER] = GetBookPer(attrType) / 10000.0;
         propertyVariables[GUBAO_VALUE] = GubaoManager.Instance.GetAttrValue(attrType);
-        propertyVariables[GUBAO_PER] = GubaoManager.Instance.GetAttrPer(attrType) / 10000.0f;
+        propertyVariables[GUBAO_PER] = GubaoManager.Instance.GetAttrPer(attrType) / 10000.0;
         propertyVariables[HJG_VALUE] = PhantasmPavilionManager.Instance.GetAttrValue(attrType);
-        propertyVariables[HJG_PER] = PhantasmPavilionManager.Instance.GetAttrPer(attrType) / 10000.0f;
+        propertyVariables[HJG_PER] = PhantasmPavilionManager.Instance.GetAttrPer(attrType) / 10000.0;
         propertyVariables[HORSE_VALUE] = HorseManager.Instance.GetAttrValue(attrType);
-        propertyVariables[HORSE_PER] = HorseManager.Instance.GetAttrPer(attrType) / 10000.0f;
+        propertyVariables[HORSE_PER] = HorseManager.Instance.GetAttrPer(attrType) / 10000.0;
         propertyVariables[BEAUTY_VALUE] = BeautyMMManager.Instance.GetAttrValue(attrType);
-        propertyVariables[BEAUTY_PER] = BeautyMMManager.Instance.GetAttrPer(attrType) / 10000.0f;
+        propertyVariables[BEAUTY_PER] = BeautyMMManager.Instance.GetAttrPer(attrType) / 10000.0;
         propertyVariables[FATES_VALUE] = HeroFatesManager.Instance.GetAttrValue(attrType);
-        propertyVariables[FATES_PER] = HeroFatesManager.Instance.GetAttrPer(attrType) / 10000.0f;
+        propertyVariables[FATES_PER] = HeroFatesManager.Instance.GetAttrPer(attrType) / 10000.0;
         propertyVariables[DINGJUNGE_VALUE] = 0; //榛樿涓嶉渶瑕佸姞锛岀埇濉旂壒娈婄敤锛岄厤鍚堝叕寮�
         propertyVariables[DINGJUNGE_PER] = 0;   //榛樿涓嶉渶瑕佸姞锛岀埇濉旂壒娈婄敤锛岄厤鍚堝叕寮�
         propertyVariables[MINGGE_VALUE] = minggeAttrs.ContainsKey(attrType) ? minggeAttrs[attrType] : 0;
-        propertyVariables[MINGGE_PER] = (minggeAttrs.ContainsKey(attrType) ? minggeAttrs[attrType] : 0) / 10000.0f;
+        propertyVariables[MINGGE_PER] = GetAttrPer(attrType, minggeAttrs) / 10000.0;
 
         //鍏ㄤ綋鍗$墝鍔犳垚
-        propertyVariables[HERO_CARDPER] = allHeroAddPer;
+        if (attrType == 6 || attrType == 7 || attrType == 8)
+        {
+            propertyVariables[HERO_CARDPER] = allHeroAddPer;
+        }
+        else
+        {
+            propertyVariables[HERO_CARDPER] = 0;
+        }
         //锛侊紒锛佸崟姝﹀皢鎴樺姏棰勮鐨勮瘽闇�瑕佹帓闄ら槦浼嶅奖鍝嶆垬鍔涳紝鍙畻姝﹀皢鑷韩鐨勪笂闃靛睘鎬�
-        // propertyVariables[LINEUP_INIT_ADD_PER] = GetLineUpPer(attrType, LINEUP_INIT_ADD_PER) / 10000.0f;
-        // propertyVariables[LINEUP_LV_ADD_PER] = GetLineUpPer(attrType, LINEUP_LV_ADD_PER) / 10000.0f;
-        // propertyVariables[LINEUP_BREAK_LV_ADD_PER] = GetLineUpPer(attrType, LINEUP_BREAK_LV_ADD_PER) / 10000.0f;
-        // propertyVariables[LINEUP_STAR_ADD_PER] = GetLineUpPer(attrType, LINEUP_STAR_ADD_PER) / 10000.0f;
+        // propertyVariables[LINEUP_INIT_ADD_PER] = GetLineUpPer(attrType, LINEUP_INIT_ADD_PER) / 10000.0;
+        // propertyVariables[LINEUP_LV_ADD_PER] = GetLineUpPer(attrType, LINEUP_LV_ADD_PER) / 10000.0;
+        // propertyVariables[LINEUP_BREAK_LV_ADD_PER] = GetLineUpPer(attrType, LINEUP_BREAK_LV_ADD_PER) / 10000.0;
+        // propertyVariables[LINEUP_STAR_ADD_PER] = GetLineUpPer(attrType, LINEUP_STAR_ADD_PER) / 10000.0;
 
         //闃靛鍏夌幆 涓夊洿鐧惧垎姣斿姞鎴�
         propertyVariables[LINEUP_HALO_VALUE] = countryAttrs.ContainsKey(attrType) ? countryAttrs[attrType] : 0;
-        propertyVariables[LINEUP_HALO_PER] = GetCountryPer(attrType) / 10000.0f;
+        propertyVariables[LINEUP_HALO_PER] = GetCountryPer(attrType) / 10000.0;
 
         //姝﹀皢灞炴��
-        propertyVariables[INHERIT_PER] = hero.GetInheritAttrPer(attrType) / 10000.0f;
+        propertyVariables[INHERIT_PER] = hero.GetInheritAttrPer(attrType) / 10000.0;
         propertyVariables[HERO_SELF_VALUE] = hero.GetSelfAddValue(attrType);
-        propertyVariables[HERO_SELF_PER] = hero.GetSelfAddPer(attrType) / 10000.0f;
+        propertyVariables[HERO_SELF_PER] = hero.GetSelfAddPer(attrType) / 10000.0;
         propertyVariables[STAR_TALENT_VALUE] = hero.GetTalentAttrValue(attrType);
-        propertyVariables[STAR_TALENT_PER] = hero.GetTalentAttrPer(attrType) / 10000.0f;
+        propertyVariables[STAR_TALENT_PER] = hero.GetTalentAttrPer(attrType) / 10000.0;
         propertyVariables[BREAK_LV_VALUE] = hero.GetBreakAttrValue(attrType);
-        propertyVariables[BREAK_LV_PER] = hero.GetBreakAttrPer(attrType) / 10000.0f;
+        propertyVariables[BREAK_LV_PER] = hero.GetBreakAttrPer(attrType) / 10000.0;
         propertyVariables[AWAKE_TALENT_VALUE] = hero.GetAwakeAttrValue(attrType);
-        propertyVariables[AWAKE_TALENT_PER] = hero.GetAwakeAttrPer(attrType) / 10000.0f;
+        propertyVariables[AWAKE_TALENT_PER] = hero.GetAwakeAttrPer(attrType) / 10000.0;
         propertyVariables[FETTER_VALUE] = hero.GetFetterAttrValue(attrType);
-        propertyVariables[FETTER_PER] = hero.GetFetterAttrPer(attrType) / 10000.0f;
+        propertyVariables[FETTER_PER] = hero.GetFetterAttrPer(attrType) / 10000.0;
         propertyVariables[HERO_LV_VALUE] = hero.GetHeroLVValue(attrType);
-        propertyVariables[HERO_LV_PER] = hero.GetHeroLVPer(attrType) / 10000.0f;
+        propertyVariables[HERO_LV_PER] = hero.GetHeroLVPer(attrType) / 10000.0;
+
+        double value;
+        if (type == 0)
+        {
+            value = FightPowerFormula.GetBaseAttr(propertyVariables);
+        }
+        else
+        {
+            value = FightPowerFormula.GetFightAttr(propertyVariables);
+        }
+
+        //淇濈暀2浣嶅皬鏁� 
+        value = Math.Round(value, 2);
+        
 #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)}";
+        {
+            FightPowerDebug($"鎴樺姏锛氭灏咺D {hero.heroId} 灞炴�D {attrType} 鍊� {value} - {JsonMapper.ToJson(tmpPropertyVariables)}");
+        }
 #endif
-        if (type == 0)
-            return FightPowerFormula.GetBaseAttr(propertyVariables);
-        else
-            return FightPowerFormula.GetFightAttr(propertyVariables);
+        return value;
     }
 
 
@@ -472,16 +505,6 @@
     //     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)
     {
@@ -547,9 +570,7 @@
         return fightPower;
     }
 
-#if UNITY_EDITOR
-    string propertyStrForDebug = "";
-#endif
+
 
     //璁$畻闃靛涓灏嗘垬鍔�
     public long CalculateTeamHeroPower(HeroInfo hero)
@@ -558,16 +579,16 @@
         fightPowerVariables.Clear();
         hero.RefreshFetterAttrsWhenCalcPower(teamTypeCalc); //缇佺粖灞炴�ц瀹炴椂绠�
 
-#if UNITY_EDITOR
-        propertyStrForDebug = "";
-#endif
+
         foreach (var config in pConfig)
         {
             if (config.showType < 1 || config.showType > 4)
             {
                 continue;
             }
-            if (config.showType == 1)
+
+            //绾﹀畾姝� 鍙湁3缁存墠鏄熀纭�灞炴��
+            if (config.showType == 1 && config.ID != 11)
             {
                 fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, 0), 3);
             }
@@ -577,9 +598,7 @@
             }
         }
 
-#if UNITY_EDITOR
-        FightPowerDebug($"鎴樺姏锛氭灏咺D {hero.heroId} 灞炴�т俊鎭� {propertyStrForDebug}");
-#endif
+
 
         //灞炴�х郴鏁版牴鎹畼鑱岀瓑绾х殑鍔犳垚
         var fightPowerRatioConfig = FightPowerRatioConfig.Get(PlayerDatas.Instance.baseData.realmLevel);
@@ -659,12 +678,11 @@
             return fightPower + skillPower;
     }
 
-    //鍛芥牸鎶�鑳芥垬鍔涳細鎶�鑳芥垬鍔�*涓暟锛涘鏋滄槸鏇挎崲鐨勮鍒ゆ柇鏄惁鎶�鑳戒釜鏁板彉鍖�
+    //鍛芥牸鎶�鑳芥垬鍔涳細鎸変釜鏁拌幏鍙栧搴旂瓑绾х殑鎶�鑳芥垬鍔�
     long GetMinggeSkillPower()
     {
         //褰撳墠鏂规鎶�鑳戒俊鎭�
-        int _skillTypeID = 0;    //鍙栧叾涓竴涓敤浜庤绠楀嵆鍙�
-        var count = MinggeManager.Instance.GetMinggeSkillCountByPresetID(minggePresetID, out _skillTypeID);
+        var dict = MinggeManager.Instance.GetMinggeSkillCountDictByPresetID(minggePresetID);
         
         ItemModel dropEquip = null;
         if (minggeDropIndex != -1)
@@ -673,34 +691,57 @@
             //甯︽妧鑳界殑鍛芥牸 闇�鍒ゆ柇鏄惁鎶�鑳戒釜鏁板彉鍖�
             if (MinggeManager.Instance.minggeSkillEquipPlaceList.Contains(dropEquip.config.EquipPlace))
             {
-                var packIndex = MinggeManager.Instance.GetPackIndex(minggePresetID, minggeDropIndex);
+                var packIndex = MinggeManager.Instance.GetPackIndex(minggePresetID, dropEquip.config.EquipPlace);
                 //瑕佸姣旂殑瑁呭
                 var equip = PackManager.Instance.GetItemByIndex(PackType.Mingge, packIndex);
+                var _skillTypeID = EquipModel.Instance.GetEquipSkillID(dropEquip);
                 if (equip == null)
                 {
-                    count++;
-                    if (_skillTypeID == 0)
+                    if (dict.ContainsKey(_skillTypeID))
                     {
-                        _skillTypeID = EquipModel.Instance.GetEquipSkillID(dropEquip);
+                        dict[_skillTypeID] += 1;
+                    }
+                }
+                else
+                {
+                    var oldSkillTypeID = EquipModel.Instance.GetEquipSkillID(equip);
+                    if (oldSkillTypeID != _skillTypeID)
+                    {
+
+                        if (dict.ContainsKey(_skillTypeID))
+                        {
+                            dict[_skillTypeID] += 1;
+                        }
+                        else
+                        {
+                            dict[_skillTypeID] = 1;
+                        }
+                        if (dict.ContainsKey(oldSkillTypeID))
+                        {
+                            dict[oldSkillTypeID] -= 1;
+                        }
                     }
                 }
 
             }
         }
 
-        if (_skillTypeID == 0)
-            return 0;
+        long skillPower = 0;
 
+        foreach (var item in dict)
+        {
+            // //鍔犱笂鎶�鑳芥垬鍔�
+            fightPowerVariables.Clear();
+            fightPowerVariables[PLAYER_LV] = PlayerDatas.Instance.baseData.LV;
+            fightPowerVariables[OFFICIAL_LV] = PlayerDatas.Instance.baseData.realmLevel;
+            fightPowerVariables[SKILL_POWER] = SkillConfig.Get(item.Key + item.Value - 1).FightPower;
+            skillPower += (long)FightPowerFormula.GetSkillsFightPower(fightPowerVariables);
+        }
 
-        //鍔犱笂鎶�鑳芥垬鍔�
-        fightPowerVariables.Clear();
-        fightPowerVariables[PLAYER_LV] = PlayerDatas.Instance.baseData.LV;
-        fightPowerVariables[OFFICIAL_LV] = PlayerDatas.Instance.baseData.realmLevel;
-        fightPowerVariables[SKILL_POWER] = SkillConfig.Get(_skillTypeID).FightPower;
-
-        long skillPower = (long)FightPowerFormula.GetSkillsFightPower(fightPowerVariables);
-
-        return skillPower * count;
+#if UNITY_EDITOR
+            FightPowerDebug($"鍛芥牸鎶�鑳芥垬鍔� {skillPower}");
+#endif
+        return skillPower;
     }
 
 
@@ -788,17 +829,14 @@
         Dictionary<int, long> tmpAttrs = new Dictionary<int, long>();
         hero.RefreshFetterAttrsWhenCalcPower(TeamManager.Instance.GetMainTeamID()); //缇佺粖灞炴�ц瀹炴椂绠�
 
-#if UNITY_EDITOR
-        propertyStrForDebug = "";
-#endif
-
         foreach (var config in pConfig)
         {
             if (config.showType < 1 || config.showType > 4)
             {
                 continue;
             }
-            if (config.showType == 1)
+            //绾﹀畾姝� 鍙湁3缁存墠鏄熀纭�灞炴��
+            if (config.showType == 1 && config.ID != 11)
             {
                 tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, 0);
             }
@@ -807,20 +845,18 @@
                 tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, 1);
             }
         }
-#if UNITY_EDITOR
-        FightPowerDebug($"鎴樺姏锛氭灏咺D {hero.heroId} 灞炴�т俊鎭� {propertyStrForDebug}");
-#endif
+
         return tmpAttrs;
     }
 
 
-    bool openLog = true;
+    bool openLog = false;
     void FightPowerDebug(string msg)
     {
 #if UNITY_EDITOR
         if (!openLog) return;
         Debug.Log(msg);
-        #endif
+#endif
     }
 }
 

--
Gitblit v1.8.0