hch
2026-01-26 aa84cb62bebb9c8a4e586bcc1ec28eb7a16a8860
Main/System/Main/FightPowerManager.cs
@@ -1,10 +1,10 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using LitJson;
using Spine;
//!单英雄查看战力 只算自己的上阵属性  不算羁绊 总上阵属性  光环
// 战力的计算方式
@@ -12,48 +12,152 @@
//  所有武将战力加起来 + 技能战力汇总(公式)就是整个号的战力
public class FightPowerManager : Singleton<FightPowerManager>
{
    public string propertyFormula;
    public string fightPropertyFormula;
    public string fightPowerFormula;
    public string skillFightPowerFormula;
    // 属性变量常量
    private const string LV_VALUE = "lvValue";
    private const string EQUIP_VALUE = "equipValue";
    private const string BOOK_VALUE = "bookValue";
    private const string BOOK_PER = "bookPer";
    private const string REALM_VALUE = "realmValue";
    private const string REALM_PER = "realmPer";
    private const string GUBAO_VALUE = "gubaoValue";
    private const string GUBAO_PER = "gubaoPer";
    private const string HJG_VALUE = "hjgValue";
    private const string HJG_PER = "hjgPer";
    private const string HORSE_VALUE = "horseValue";
    private const string HORSE_PER = "horsePer";
    private const string BEAUTY_VALUE = "beautyValue";
    private const string BEAUTY_PER = "beautyPer";
    private const string FATES_VALUE = "fatesValue";
    private const string FATES_PER = "fatesPer";
    private const string LINEUP_HALO_VALUE = "lineupHaloValue";
    private const string LINEUP_HALO_PER = "lineupHaloPer";
    private const string INHERIT_PER = "inheritPer";
    private const string HERO_SELF_VALUE = "heroSelfValue";
    private const string HERO_SELF_PER = "heroSelfPer";
    private const string STAR_TALENT_VALUE = "starTalentValue";
    private const string STAR_TALENT_PER = "starTalentPer";
    private const string BREAK_LV_VALUE = "breakLVValue";
    private const string BREAK_LV_PER = "breakLVPer";
    private const string AWAKE_TALENT_VALUE = "awakeTalentValue";
    private const string AWAKE_TALENT_PER = "awakeTalentPer";
    private const string FETTER_VALUE = "fetterValue";
    private const string FETTER_PER = "fetterPer";
    private const string HERO_LV_VALUE = "heroLVValue";
    private const string HERO_LV_PER = "heroLVPer";
    private const string HERO_CARDPER = "cardPer";
    private const string DINGJUNGE_VALUE = "dingjungeValue";
    private const string DINGJUNGE_PER = "dingjungePer";
    private const string MINGGE_VALUE = "minggeValue";
    private const string MINGGE_PER = "minggePer";
    // 战力变量常量
    private const string ATK_RATIO = "AtkRatio";
    private const string MAX_HP_RATIO = "MaxHPRatio";
    private const string DEF_RATIO = "DefRatio";
    private const string STUN_RATE_RATIO = "StunRateRatio";
    private const string SUPER_HIT_RATE_RATIO = "SuperHitRateRatio";
    private const string COMBO_RATE_RATIO = "ComboRateRatio";
    private const string MISS_RATE_RATIO = "MissRateRatio";
    private const string PARRY_RATE_RATIO = "ParryRateRatio";
    private const string SUCK_HP_PER_RATIO = "SuckHPPerRatio";
    private const string STUN_RATE_DEF_RATIO = "StunRateDefRatio";
    private const string SUPER_HIT_RATE_DEF_RATIO = "SuperHitRateDefRatio";
    private const string COMBO_RATE_DEF_RATIO = "ComboRateDefRatio";
    private const string MISS_RATE_DEF_RATIO = "MissRateDefRatio";
    private const string PARRY_RATE_DEF_RATIO = "ParryRateDefRatio";
    private const string SUCK_HP_PER_DEF_RATIO = "SuckHPPerDefRatio";
    private const string NORMAL_SKILL_PER_RATIO = "NormalSkillPerRatio";
    private const string NORMAL_SKILL_PER_DEF_RATIO = "NormalSkillPerDefRatio";
    private const string ANGER_SKILL_PER_RATIO = "AngerSkillPerRatio";
    private const string ANGER_SKILL_PER_DEF_RATIO = "AngerSkillPerDefRatio";
    private const string SUPER_DAM_PER_RATIO = "SuperDamPerRatio";
    private const string SUPER_DAM_PER_DEF_RATIO = "SuperDamPerDefRatio";
    private const string SHIELD_PER_RATIO = "ShieldPerRatio";
    private const string SHIELD_PER_DEF_RATIO = "ShieldPerDefRatio";
    private const string DOT_PER_RATIO = "DOTPerRatio";
    private const string DOT_PER_DEF_RATIO = "DOTPerDefRatio";
    private const string WEI_FINAL_DAM_PER_RATIO = "WeiFinalDamPerRatio";
    private const string WEI_FINAL_DAM_PER_DEF_RATIO = "WeiFinalDamPerDefRatio";
    private const string SHU_FINAL_DAM_PER_RATIO = "ShuFinalDamPerRatio";
    private const string SHU_FINAL_DAM_PER_DEF_RATIO = "ShuFinalDamPerDefRatio";
    private const string WU_FINAL_DAM_PER_RATIO = "WuFinalDamPerRatio";
    private const string WU_FINAL_DAM_PER_DEF_RATIO = "WuFinalDamPerDefRatio";
    private const string QUN_FINAL_DAM_PER_RATIO = "QunFinalDamPerRatio";
    private const string QUN_FINAL_DAM_PER_DEF_RATIO = "QunFinalDamPerDefRatio";
    private const string FINAL_DAM_PER_RATIO = "FinalDamPerRatio";
    private const string FINAL_DAM_PER_DEF_RATIO = "FinalDamPerDefRatio";
    private const string PHY_DAM_PER_RATIO = "PhyDamPerRatio";
    private const string PHY_DAM_PER_DEF_RATIO = "PhyDamPerDefRatio";
    private const string MAG_DAM_PER_RATIO = "MagDamPerRatio";
    private const string MAG_DAM_PER_DEF_RATIO = "MagDamPerDefRatio";
    private const string CURE_PER_RATIO = "CurePerRatio";
    private const string CURE_PER_DEF_RATIO = "CurePerDefRatio";
    private const string PVP_DAM_PER_RATIO = "PVPDamPerRatio";
    private const string PVP_DAM_PER_DEF_RATIO = "PVPDamPerDefRatio";
    private const string GUANCHUAN_RATIO = "GuanchuanRatio";
    private const string GUANCHUAN_DEF_RATIO = "GuanchuanDefRatio";
    private const string ZHAOJIA_RATIO = "ZhaojiaRatio";
    private const string ZHAOJIA_DEF_RATIO = "ZhaojiaDefRatio";
    private const string ATKSPEEDRATIO_VALUE = "AtkSpeedRatio";
    private const string PLAYER_LV = "PlayerLV";
    private const string OFFICIAL_LV = "OfficialLV";
    private const string SKILL_POWER = "SkillPower";
    Dictionary<string, double> propertyVariables = new Dictionary<string, double>();
    Dictionary<string, double> fightPowerVariables = new Dictionary<string, double>();  //总战力中的单武将战力
    List<PlayerPropertyConfig> pConfig = new List<PlayerPropertyConfig>();
    public FightPowerManager()
    {
        // 数值1:基础三维属性计算公式
        // 数值2:战斗属性/战斗抗性/特殊属性计算公式
        // 数值3:属性战力计算公式,计算参数详见 S.属性条目配置
        var config = FuncConfigConfig.Get("HeroAttrFormula");
        propertyFormula = config.Numerical1;
        fightPropertyFormula = config.Numerical2;
        fightPowerFormula = config.Numerical3;
        skillFightPowerFormula = config.Numerical4;
        pConfig = PlayerPropertyConfig.GetValues();
        JaceCalculator.Init();
    }
    #region 初始化战力计算的信息
    TeamType teamTypeCalc = TeamType.Story; //不同阵容战力不同
    int teamTypeCalc = 1; //不同阵容战力不同
    bool isPreviewTeamPower;  //预览阵容(队伍)战力
    int dropIndexCalc = -1; //掉落装备在阵容的索引,用于预览战力对比
    int minggePresetID; //命格预设ID
    int minggeDropIndex;    //掉落命格在背包的索引 ,用于预览战力对比
    //计算阵容战力,装备对比等情况需要代入
    /// <summary>
    /// 
    /// </summary>
    /// <param name="teamType">阵容类型</param>
    /// <param name="teamType">阵容类型:方案ID下的队伍</param>
    /// <param name="dropindex">掉落装备的索引,-1代表不替换计算</param>
    /// <param name="ispreview">预览阵容战力</param>
    public void InitFightPowerParam(TeamType teamType = TeamType.Story, int dropindex = -1, bool ispreview = false)
    public void InitFightPowerParam(int teamType = 0, int dropindex = -1, bool ispreview = false,
    int _minggePresetID = 0, int _minggeDropIndex = -1)
    {
#if !UNITY_EDITOR
        openLog = false;
#endif
        if (teamType == 0)
        {
            // 没有设置默认使用主阵容
            teamType = TeamManager.Instance.GetMainTeamID();
        }
        if (_minggePresetID == 0)
        {
            // 没有设置默认当前流派下命格方案
            _minggePresetID = FuncPresetManager.Instance.GetFuncPresetID((int)FuncPresetType.Mingge);
        }
        teamTypeCalc = teamType;
        minggePresetID = _minggePresetID;
        isPreviewTeamPower = ispreview;
        dropIndexCalc = dropindex;
        minggeDropIndex = _minggeDropIndex;
#if UNITY_EDITOR
        Debug.Log("战力:初始化参数 dropIndex:" + dropIndexCalc + " 阵型:" + teamTypeCalc + " ispreview:" + ispreview);
        FightPowerDebug("战力:初始化参数 dropIndex:" + dropIndexCalc + " 阵型:" + teamTypeCalc + " ispreview:" + ispreview
        + " minggePresetID:" + _minggePresetID + " minggeDropIndex:" + _minggeDropIndex);
#endif
    }
    #endregion
@@ -63,13 +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<string, int> lineUpPerDict = new Dictionary<string, 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, long> minggeAttrs = new Dictionary<int, long>();   //命格属性
    double allHeroAddPer = 0;  //所有武将加成
    //等级属性
    void RefreshLVAttrs()
@@ -81,7 +188,9 @@
            lvAttrs[attrType] = GetPlayerLVValue(playerLVConfig, attrType);
        }
#if UNITY_EDITOR
        Debug.Log("战力:等级属性 " + JsonMapper.ToJson(lvAttrs));
        FightPowerDebug("战力:等级属性 " + JsonMapper.ToJson(lvAttrs));
        FightPowerDebug("战力:红颜属性 " + JsonMapper.ToJson(BeautyMMManager.Instance.allMMTalentAttr));
        FightPowerDebug("战力:古宝属性 " + JsonMapper.ToJson(GubaoManager.Instance.gubaoAllAttrDict));
#endif
    }
@@ -115,7 +224,7 @@
            officialAttrs[id] = config.AddAttrNum[i];
        }
#if UNITY_EDITOR
        Debug.Log("战力:官职属性 " + JsonMapper.ToJson(officialAttrs));
        FightPowerDebug("战力:官职属性 " + JsonMapper.ToJson(officialAttrs));
#endif
    }
@@ -124,13 +233,18 @@
    void RefrehEquipAttrs()
    {
        equipAttrs.Clear();  //身上装备属性重置
        ItemModel dropEquip = null;
        if (dropIndexCalc != -1)
        {
            dropEquip = PackManager.Instance.GetItemByIndex(PackType.DropItem, dropIndexCalc);
        }
        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)
                if (dropEquip != null && dropEquip.config.EquipPlace - 1 == i)
                {
                    equip = dropEquip;  //替换计算总战力
                }
@@ -175,7 +289,7 @@
        }
#if UNITY_EDITOR
        Debug.Log("战力:装备属性 " + JsonMapper.ToJson(equipAttrs));
        FightPowerDebug("战力:装备属性 " + JsonMapper.ToJson(equipAttrs));
#endif
    }
@@ -184,16 +298,81 @@
    {
        //阵容属性
        // 阵容:所有武将上阵属性
        lineUpPerDict = HeroUIManager.Instance.GetLineupPer(teamTypeCalc, isPreviewTeamPower);
        // lineUpPerDict = HeroUIManager.Instance.GetLineupPer(teamTypeCalc, isPreviewTeamPower);
        allHeroAddPer = HeroUIManager.Instance.GetAllHeroPer() / 10000.0;
#if UNITY_EDITOR
        Debug.Log("战力:上阵属性 " + JsonMapper.ToJson(lineUpPerDict));
        // Debug.Log("战力:上阵属性 " + JsonMapper.ToJson(lineUpPerDict));
#endif
        // 阵容:国家(光环)属性
        countryAttrs = HeroUIManager.Instance.GetCountryAttrs(teamTypeCalc, isPreviewTeamPower);
#if UNITY_EDITOR
        Debug.Log("战力:国家(光环)属性 " + JsonMapper.ToJson(countryAttrs));
        FightPowerDebug("战力:国家(光环)属性 " + JsonMapper.ToJson(countryAttrs));
        FightPowerDebug("战力:武将所有加成 " + allHeroAddPer);
#endif
    }
    //类似装备需要实时替换对比;功能处查看重算一次显示
    void RefrehMinggeAttrs()
    {
        minggeAttrs.Clear();  //身上命格属性重置
        ItemModel dropEquip = null;
        int packIndex = -1;
        if (minggeDropIndex != -1)
        {
            dropEquip = PackManager.Instance.GetItemByIndex(PackType.MinggeDrop, minggeDropIndex);
            packIndex = MinggeManager.Instance.GetPackIndex(minggePresetID, dropEquip.config.EquipPlace);
        }
        var starIndex = (minggePresetID - 1) * MinggeManager.TotleEquip;
        for (int i = starIndex; i < starIndex + MinggeManager.TotleEquip; i++)
        {
            var equip = PackManager.Instance.GetItemByIndex(PackType.Mingge, i);
            if (minggeDropIndex != -1)
            {
                if (dropEquip != null && packIndex == i)
                {
                    equip = dropEquip;  //替换计算总战力
                }
            }
            if (equip == null)
            {
                continue;
            }
            var fightIDAttrs = EquipModel.Instance.GetEquipFightAttrs(equip);
            var fightValueAttrs = EquipModel.Instance.GetEquipFightValues(equip);
            if (fightIDAttrs != null)
            {
                for (int j = 0; j < fightIDAttrs.Count; j++)
                {
                    if (!minggeAttrs.ContainsKey(fightIDAttrs[j]))
                    {
                        minggeAttrs[fightIDAttrs[j]] = fightValueAttrs[j];
                    }
                    else
                    {
                        minggeAttrs[fightIDAttrs[j]] += fightValueAttrs[j];
                    }
                }
            }
        }
#if UNITY_EDITOR
        FightPowerDebug("战力:命格属性 " + JsonMapper.ToJson(minggeAttrs));
#endif
    }
    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
@@ -221,83 +400,111 @@
    #region 属性公式
    // 单基础属性计算
    public double GetPropertyVaule(int attrType, HeroInfo hero, string formula)
    public double GetPropertyVaule(int attrType, HeroInfo hero, int type)
    {
        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["gubaoValue"] = 0;
        propertyVariables["gubaoPer"] = 0;
        propertyVariables["hjgValue"] = 0;
        propertyVariables["hjgPer"] = 0;
        // propertyVariables.Clear();
        propertyVariables[LV_VALUE] = lvAttrs.ContainsKey(attrType) ? lvAttrs[attrType] : 0;
        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] = 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.0;
        propertyVariables[HJG_VALUE] = PhantasmPavilionManager.Instance.GetAttrValue(attrType);
        propertyVariables[HJG_PER] = PhantasmPavilionManager.Instance.GetAttrPer(attrType) / 10000.0;
        propertyVariables[HORSE_VALUE] = HorseManager.Instance.GetAttrValue(attrType);
        propertyVariables[HORSE_PER] = HorseManager.Instance.GetAttrPer(attrType) / 10000.0;
        propertyVariables[BEAUTY_VALUE] = BeautyMMManager.Instance.GetAttrValue(attrType);
        propertyVariables[BEAUTY_PER] = BeautyMMManager.Instance.GetAttrPer(attrType) / 10000.0;
        propertyVariables[FATES_VALUE] = HeroFatesManager.Instance.GetAttrValue(attrType);
        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] = GetAttrPer(attrType, minggeAttrs) / 10000.0;
        //全体卡牌加成
        if (attrType == 6 || attrType == 7 || attrType == 8)
        {
            propertyVariables[HERO_CARDPER] = allHeroAddPer;
        }
        else
        {
            propertyVariables[HERO_CARDPER] = 0;
        }
        //!!!单武将战力预览的话需要排除队伍影响战力,只算武将自身的上阵属性
        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[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["lineupHaloValue"] = countryAttrs.ContainsKey(attrType) ? countryAttrs[attrType] : 0;
        propertyVariables["lineupHaloPer"] = GetCountryPer(attrType) / 10000.0f;
        propertyVariables[LINEUP_HALO_VALUE] = countryAttrs.ContainsKey(attrType) ? countryAttrs[attrType] : 0;
        propertyVariables[LINEUP_HALO_PER] = GetCountryPer(attrType) / 10000.0;
        //武将属性
        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;
        propertyVariables[INHERIT_PER] = hero.GetInheritAttrPer(attrType) / 10000.0;
        propertyVariables[HERO_SELF_VALUE] = hero.GetSelfAddValue(attrType);
        propertyVariables[HERO_SELF_PER] = hero.GetSelfAddPer(attrType) / 10000.0;
        propertyVariables[STAR_TALENT_VALUE] = hero.GetTalentAttrValue(attrType);
        propertyVariables[STAR_TALENT_PER] = hero.GetTalentAttrPer(attrType) / 10000.0;
        propertyVariables[BREAK_LV_VALUE] = hero.GetBreakAttrValue(attrType);
        propertyVariables[BREAK_LV_PER] = hero.GetBreakAttrPer(attrType) / 10000.0;
        propertyVariables[AWAKE_TALENT_VALUE] = hero.GetAwakeAttrValue(attrType);
        propertyVariables[AWAKE_TALENT_PER] = hero.GetAwakeAttrPer(attrType) / 10000.0;
        propertyVariables[FETTER_VALUE] = hero.GetFetterAttrValue(attrType);
        propertyVariables[FETTER_PER] = hero.GetFetterAttrPer(attrType) / 10000.0;
        propertyVariables[HERO_LV_VALUE] = hero.GetHeroLVValue(attrType);
        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 += $"属性ID {attrType} - {JsonMapper.ToJson(tmpPropertyVariables)}";
        {
            FightPowerDebug($"战力:武将ID {hero.heroId} 属性ID {attrType} 值 {value} - {JsonMapper.ToJson(tmpPropertyVariables)}");
        }
#endif
        return JaceCalculator.Calculate(formula, propertyVariables);
        return value;
    }
    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 GetLineUpPer(int attrType, string key)
    // {
    //     if (!PlayerPropertyConfig.baseAttrs.Contains(attrType))
    //     {
    //         return 0;
    //     }
    int GetOfficialPer(int attrType)
    {
        if (PlayerPropertyConfig.baseAttr2perDict.ContainsKey(attrType))
        {
            var pertype = PlayerPropertyConfig.baseAttr2perDict[attrType];
            return officialAttrs.ContainsKey(pertype) ? officialAttrs[pertype] : 0;
        }
    //     return lineUpPerDict[key];
    // }
        return 0;
    }
    // int GetBookPer(int attrType)
    // {
    //     if (!PlayerPropertyConfig.baseAttrs.Contains(attrType))
    //     {
    //         return 0;
    //     }
    //     return HeroUIManager.Instance.allHeroBookPer;
    // }
    int GetCountryPer(int attrType)
    {
@@ -323,14 +530,14 @@
    public long CalculatePower()
    {
#if UNITY_EDITOR
        Debug.Log("战力:开始计算");
        FightPowerDebug("战力:开始计算");
#endif
        // --- 先计算所有功能的汇总属性 ---
        RefreshLVAttrs();
        RefreshOfficialAttrs();
        RefrehEquipAttrs();
        RefrehMinggeAttrs();
        RefreshTeamAttrs();
        // --- 算单武将功能属性战力 后相加---
        long fightPower = 0;
@@ -356,15 +563,14 @@
        }
#if UNITY_EDITOR
        Debug.Log("战力:计算完毕 " + fightPower);
#endif
        fightPower += GetMinggeSkillPower();
// #if UNITY_EDITOR
        FightPowerDebug("战力:计算完毕 " + fightPower);
// #endif
        return fightPower;
    }
#if UNITY_EDITOR
    string propertyStrForDebug = "";
#endif
    //计算阵容中武将战力
    public long CalculateTeamHeroPower(HeroInfo hero)
@@ -373,98 +579,179 @@
        fightPowerVariables.Clear();
        hero.RefreshFetterAttrsWhenCalcPower(teamTypeCalc); //羁绊属性要实时算
#if UNITY_EDITOR
        propertyStrForDebug = "";
#endif
        foreach (var config in PlayerPropertyConfig.GetValues())
        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, propertyFormula), 3);
                fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, 0), 3);
            }
            else
            {
                fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, fightPropertyFormula), 3);
                fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, 1), 3);
            }
        }
#if UNITY_EDITOR
        Debug.Log($"战力:武将ID {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;
        fightPowerVariables[ATK_RATIO] = fightPowerRatioConfig.AtkRatio;
        fightPowerVariables[MAX_HP_RATIO] = fightPowerRatioConfig.MaxHPRatio;
        fightPowerVariables[DEF_RATIO] = fightPowerRatioConfig.DefRatio;
        fightPowerVariables[STUN_RATE_RATIO] = fightPowerRatioConfig.StunRateRatio;
        fightPowerVariables[SUPER_HIT_RATE_RATIO] = fightPowerRatioConfig.SuperHitRateRatio;
        fightPowerVariables[COMBO_RATE_RATIO] = fightPowerRatioConfig.ComboRateRatio;
        fightPowerVariables[MISS_RATE_RATIO] = fightPowerRatioConfig.MissRateRatio;
        fightPowerVariables[PARRY_RATE_RATIO] = fightPowerRatioConfig.ParryRateRatio;
        fightPowerVariables[SUCK_HP_PER_RATIO] = fightPowerRatioConfig.SuckHPPerRatio;
        fightPowerVariables[STUN_RATE_DEF_RATIO] = fightPowerRatioConfig.StunRateDefRatio;
        fightPowerVariables[SUPER_HIT_RATE_DEF_RATIO] = fightPowerRatioConfig.SuperHitRateDefRatio;
        fightPowerVariables[COMBO_RATE_DEF_RATIO] = fightPowerRatioConfig.ComboRateDefRatio;
        fightPowerVariables[MISS_RATE_DEF_RATIO] = fightPowerRatioConfig.MissRateDefRatio;
        fightPowerVariables[PARRY_RATE_DEF_RATIO] = fightPowerRatioConfig.ParryRateDefRatio;
        fightPowerVariables[SUCK_HP_PER_DEF_RATIO] = fightPowerRatioConfig.SuckHPPerDefRatio;
        fightPowerVariables[NORMAL_SKILL_PER_RATIO] = fightPowerRatioConfig.NormalSkillPerRatio;
        fightPowerVariables[NORMAL_SKILL_PER_DEF_RATIO] = fightPowerRatioConfig.NormalSkillPerDefRatio;
        fightPowerVariables[ANGER_SKILL_PER_RATIO] = fightPowerRatioConfig.AngerSkillPerRatio;
        fightPowerVariables[ANGER_SKILL_PER_DEF_RATIO] = fightPowerRatioConfig.AngerSkillPerDefRatio;
        fightPowerVariables[SUPER_DAM_PER_RATIO] = fightPowerRatioConfig.SuperDamPerRatio;
        fightPowerVariables[SUPER_DAM_PER_DEF_RATIO] = fightPowerRatioConfig.SuperDamPerDefRatio;
        fightPowerVariables[SHIELD_PER_RATIO] = fightPowerRatioConfig.ShieldPerRatio;
        fightPowerVariables[SHIELD_PER_DEF_RATIO] = fightPowerRatioConfig.ShieldPerDefRatio;
        fightPowerVariables[DOT_PER_RATIO] = fightPowerRatioConfig.DOTPerRatio;
        fightPowerVariables[DOT_PER_DEF_RATIO] = fightPowerRatioConfig.DOTPerDefRatio;
        fightPowerVariables[WEI_FINAL_DAM_PER_RATIO] = fightPowerRatioConfig.WeiFinalDamPerRatio;
        fightPowerVariables[WEI_FINAL_DAM_PER_DEF_RATIO] = fightPowerRatioConfig.WeiFinalDamPerDefRatio;
        fightPowerVariables[SHU_FINAL_DAM_PER_RATIO] = fightPowerRatioConfig.ShuFinalDamPerRatio;
        fightPowerVariables[SHU_FINAL_DAM_PER_DEF_RATIO] = fightPowerRatioConfig.ShuFinalDamPerDefRatio;
        fightPowerVariables[WU_FINAL_DAM_PER_RATIO] = fightPowerRatioConfig.WuFinalDamPerRatio;
        fightPowerVariables[WU_FINAL_DAM_PER_DEF_RATIO] = fightPowerRatioConfig.WuFinalDamPerDefRatio;
        fightPowerVariables[QUN_FINAL_DAM_PER_RATIO] = fightPowerRatioConfig.QunFinalDamPerRatio;
        fightPowerVariables[QUN_FINAL_DAM_PER_DEF_RATIO] = fightPowerRatioConfig.QunFinalDamPerDefRatio;
        fightPowerVariables[FINAL_DAM_PER_RATIO] = fightPowerRatioConfig.FinalDamPerRatio;
        fightPowerVariables[FINAL_DAM_PER_DEF_RATIO] = fightPowerRatioConfig.FinalDamPerDefRatio;
        fightPowerVariables[PHY_DAM_PER_RATIO] = fightPowerRatioConfig.PhyDamPerRatio;
        fightPowerVariables[PHY_DAM_PER_DEF_RATIO] = fightPowerRatioConfig.PhyDamPerDefRatio;
        fightPowerVariables[MAG_DAM_PER_RATIO] = fightPowerRatioConfig.MagDamPerRatio;
        fightPowerVariables[MAG_DAM_PER_DEF_RATIO] = fightPowerRatioConfig.MagDamPerDefRatio;
        fightPowerVariables[CURE_PER_RATIO] = fightPowerRatioConfig.CurePerRatio;
        fightPowerVariables[CURE_PER_DEF_RATIO] = fightPowerRatioConfig.CurePerDefRatio;
        fightPowerVariables[PVP_DAM_PER_RATIO] = fightPowerRatioConfig.PVPDamPerRatio;
        fightPowerVariables[PVP_DAM_PER_DEF_RATIO] = fightPowerRatioConfig.PVPDamPerDefRatio;
        fightPowerVariables[GUANCHUAN_RATIO] = fightPowerRatioConfig.GuanchuanRatio;
        fightPowerVariables[GUANCHUAN_DEF_RATIO] = fightPowerRatioConfig.GuanchuanDefRatio;
        fightPowerVariables[ZHAOJIA_RATIO] = fightPowerRatioConfig.ZhaojiaRatio;
        fightPowerVariables[ZHAOJIA_DEF_RATIO] = fightPowerRatioConfig.ZhaojiaDefRatio;
        fightPowerVariables[ATKSPEEDRATIO_VALUE] = fightPowerRatioConfig.AtkSpeedRatio;
        long fightPower = (long)JaceCalculator.Calculate(fightPowerFormula, fightPowerVariables);
        long fightPower = (long)FightPowerFormula.GetFightPower(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($"战力:武将ID {hero.heroId} 属性战力 {fightPower} 属性战力参数 {JsonMapper.ToJson(tmpFightPowerVariables)}");
            //排除值为0的属性输出
            var tmpFightPowerVariables = fightPowerVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value);
            if (!tmpFightPowerVariables.IsNullOrEmpty())
                FightPowerDebug($"战力:武将ID {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();
        fightPowerVariables[PLAYER_LV] = PlayerDatas.Instance.baseData.LV;
        fightPowerVariables[OFFICIAL_LV] = PlayerDatas.Instance.baseData.realmLevel;
        fightPowerVariables[SKILL_POWER] = hero.GetSkillsFightPower();
        long skillPower = (long)JaceCalculator.Calculate(skillFightPowerFormula, fightPowerVariables);
        long skillPower = (long)FightPowerFormula.GetSkillsFightPower(fightPowerVariables);
#if UNITY_EDITOR
        Debug.Log($"战力:武将ID {hero.heroId} 技能战力 {skillPower} 技能参数 {JsonMapper.ToJson(fightPowerVariables)}");
            FightPowerDebug($"战力:武将ID {hero.heroId} 技能战力 {skillPower} 技能参数 {JsonMapper.ToJson(fightPowerVariables)}");
        Debug.Log($"战力:武将ID {hero.heroId} 总战力 {fightPower + skillPower}");
            FightPowerDebug($"战力:武将ID {hero.heroId} 总战力 {fightPower + skillPower}");
#endif
        return fightPower + skillPower;
            return fightPower + skillPower;
    }
    //命格技能战力:按个数获取对应等级的技能战力
    long GetMinggeSkillPower()
    {
        //当前方案技能信息
        var dict = MinggeManager.Instance.GetMinggeSkillCountDictByPresetID(minggePresetID);
        ItemModel dropEquip = null;
        if (minggeDropIndex != -1)
        {
            dropEquip = PackManager.Instance.GetItemByIndex(PackType.MinggeDrop, minggeDropIndex);
            //带技能的命格 需判断是否技能个数变化
            if (MinggeManager.Instance.minggeSkillEquipPlaceList.Contains(dropEquip.config.EquipPlace))
            {
                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)
                {
                    if (dict.ContainsKey(_skillTypeID))
                    {
                        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;
                        }
                    }
                }
            }
        }
        long skillPower = 0;
        foreach (var item in dict)
        {
            // //加上技能战力
            fightPowerVariables.Clear();
            fightPowerVariables[PLAYER_LV] = PlayerDatas.Instance.baseData.LV;
            fightPowerVariables[OFFICIAL_LV] = PlayerDatas.Instance.baseData.realmLevel;
            if (item.Value == 0)
            {
                continue;
            }
            var skill = SkillConfig.Get(item.Key + item.Value - 1);
            if (skill == null)
            {
                Debug.LogError("skill is null" + (item.Key + item.Value - 1));
                continue;
            }
            fightPowerVariables[SKILL_POWER] = skill.FightPower;
            skillPower += (long)FightPowerFormula.GetSkillsFightPower(fightPowerVariables);
        }
#if UNITY_EDITOR
            FightPowerDebug($"命格技能战力 {skillPower}");
#endif
        return skillPower;
    }
@@ -483,6 +770,20 @@
        return tmpFightPower - fightPower;
    }
    /// <summary>
    /// 命格装备对比
    /// </summary>
    /// minggePresetID 指要对比的哪套方案下的命格,玩家可以点击切换对比,自动默认会遍历所有激活方案
    public long GetFightPowerMinggeChange(ItemModel item, int minggePresetID)
    {
        InitFightPowerParam(_minggePresetID: minggePresetID);
        var fightPower = CalculatePower();
        InitFightPowerParam(_minggePresetID: minggePresetID, _minggeDropIndex: item.gridIndex);
        var tmpFightPower = CalculatePower();
        return tmpFightPower - fightPower;
    }
    // 单英雄查看战力 
    // 1. 上阵英雄显示,在主线阵容下的战力
@@ -490,7 +791,7 @@
    public long GetHeroFightPower(HeroInfo heroInfo)
    {
        bool ispreview = false;
        var team = TeamManager.Instance.GetTeam(TeamType.Story);
        var team = TeamManager.Instance.GetTeam(TeamManager.Instance.GetMainTeamID());
        if (!team.HasHero(heroInfo.itemHero.guid))
        {
            //替换上阵位置
@@ -509,11 +810,13 @@
        InitFightPowerParam(ispreview: ispreview);
        RefreshLVAttrs();
        RefreshOfficialAttrs();
        RefrehMinggeAttrs();
        RefrehEquipAttrs();
        RefreshTeamAttrs();
        var fightPower = CalculateTeamHeroPower(heroInfo);
        fightPower += GetMinggeSkillPower();
        //计算完恢复队伍
        if (ispreview)
            team.RestoreTeam();
@@ -522,9 +825,9 @@
    //查看阵容战力
    public long GetTeamFightPower(TeamType team, bool isPreview)
    public long GetTeamFightPower(int team, bool isPreview)
    {
        InitFightPowerParam(team, -1, isPreview);
        InitFightPowerParam(team, ispreview:isPreview);
        return CalculatePower();
    }
    #endregion
@@ -534,32 +837,37 @@
    {
        Dictionary<int, long> tmpAttrs = new Dictionary<int, long>();
        hero.RefreshFetterAttrsWhenCalcPower(TeamType.Story); //羁绊属性要实时算
        hero.RefreshFetterAttrsWhenCalcPower(TeamManager.Instance.GetMainTeamID()); //羁绊属性要实时算
#if UNITY_EDITOR
        propertyStrForDebug = "";
#endif
        foreach (var config in PlayerPropertyConfig.GetValues())
        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, propertyFormula);
                tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, 0);
            }
            else
            {
                tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, fightPropertyFormula);
                tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, 1);
            }
        }
#if UNITY_EDITOR
        Debug.Log($"战力:武将ID {hero.heroId} 属性信息 {propertyStrForDebug}");
#endif
        return tmpAttrs;
    }
    bool openLog = false;
    void FightPowerDebug(string msg)
    {
#if UNITY_EDITOR
        if (!openLog) return;
        Debug.Log(msg);
#endif
    }
}