From eb27e5fd31f73b998a4bbd85511a31e40b8c61b7 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 21 十一月 2025 17:03:47 +0800
Subject: [PATCH] 0312 关闭游戏内日志

---
 Main/System/Invest/InvestModel.cs |  526 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 270 insertions(+), 256 deletions(-)

diff --git a/Main/System/Invest/InvestModel.cs b/Main/System/Invest/InvestModel.cs
index a1f8f9c..a11b019 100644
--- a/Main/System/Invest/InvestModel.cs
+++ b/Main/System/Invest/InvestModel.cs
@@ -6,44 +6,51 @@
 
 public class InvestModel : GameSystemManager<InvestModel>
 {
-    // public ILOpenServerActivityProxy activity;
-
-    public const int FuncID = 25;
+    public const int monthCardType = 1; // 鏈堝崱
+    public const int foreverCardType = 2; //姘镐箙鍗� 鏉冮檺 
 
 
     //鎶曡祫瀵瑰簲濂栧姳
-    Dictionary<int, Dictionary<int, List<Item>>> m_InvestItems = new Dictionary<int, Dictionary<int, List<Item>>>();
+    Dictionary<int, int[][]> m_InvestItems = new Dictionary<int, int[][]>();
+    Dictionary<int, int> m_InvestDays = new Dictionary<int, int>(); //鎶曡祫瀵瑰簲澶╂暟
+    Dictionary<int, int> m_InvestMaxDays = new Dictionary<int, int>();  //鎶曡祫瀵瑰簲鏈�澶ц喘涔扮疮鍔犲ぉ鏁�
+
     //鎶曡祫瀵瑰簲鍏呭�糏D
     Dictionary<int, int[]> m_InvestRechargeIds = new Dictionary<int, int[]>();
+    Dictionary<int, int> m_InvestCTGIDToType = new Dictionary<int, int>();
+
     //鎶曡祫瀵瑰簲璐拱鎯呭喌
     Dictionary<int, InvestInfo> m_InvestInfos = new Dictionary<int, InvestInfo>();
-    //{鎶曡祫绫诲瀷锛歔棰嗗彇澶╋紝褰撳墠澶} 澶╀粠1寮�濮�
-    Dictionary<int, List<List<int>>> m_InvestSingleInfos = new Dictionary<int, List<List<int>>>();
-    //鎶曡祫瀵瑰簲鐨勭孩鐐�
-    Dictionary<int, Redpoint> m_Redpoints = new Dictionary<int, Redpoint>();
     //鎶曡祫绫诲瀷
-    public List<int> investTypes = new List<int>();
 
+    //--鐗规潈--
+    //澧炲姞鍓湰璐拱娆℃暟
+    Dictionary<int, Dictionary<int, int>> m_InvestAddFBCount = new Dictionary<int, Dictionary<int, int>>();
+    //鍓湰璐拱娆℃暟鍏嶈垂鐨勫壇鏈琁D 鍜� m_InvestAddFBCount 閰嶅悎浣跨敤 鐩稿綋浜� 鐗规潈澧炲姞鍓湰涓婇檺浣嗘槸鍙戝寘娴佺▼闇�鍜屾湇鍔$鍟嗛噺
+    Dictionary<int, int[]> m_InvestFreeFBID = new Dictionary<int, int[]>();
+    //婕旀鍦哄鍔犱笂闄�
+    Dictionary<int, int> m_InvestArenaMaxCnt = new Dictionary<int, int>();
+    //绁濈鏍戣兘閲忓鍔犱笂闄�
+    Dictionary<int, int> m_InvestAddBlessEnergyCount = new Dictionary<int, int>();
 
-    //姘镐箙鍗� 鏉冮檺
-    public const int foreverCardType = 12; //鎶曡祫绫诲瀷   
-    public const int monthCardType = 7; // 鏈堝崱7
+    // 鐗规潈鏉冮檺鏁伴噺
+    Dictionary<int, int> m_PrivilegeLins = new Dictionary<int, int>();
+    // 鎴樻枟鍊嶆暟寮�鍚搴旂壒鏉�
+    Dictionary<int, int> m_PrivilegeFightSpeed = new Dictionary<int, int>();
+    // 鑻遍泟绉垎鎷涘嫙寮�鍚殑鐗规潈绫诲瀷
+    int[] heroScoreCallOpenType;
+        
 
-
-
-    public event Action onSelectUpdate;
     public event Action<int> onInvestUpdate;
 
-    public const int redpointID = 20931;
-    public Redpoint redpoint = new Redpoint(MainRedDot.REDPOINT_OPENSERVER, redpointID);
+    public Redpoint redpoint1 = new Redpoint(MainRedDot.RedPoint_PrivilegeCard, MainRedDot.RedPoint_PrivilegeCard * 10 + 1);
+    public Redpoint redpoint2 = new Redpoint(MainRedDot.RedPoint_PrivilegeCard, MainRedDot.RedPoint_PrivilegeCard * 10 + 2);
 
 
     public override void Init()
     {
-        FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
         DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
-        DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
-
+        RechargeManager.Instance.rechargeCountEvent += OnRechargeCountEvent;
         //閫氳繃閰嶇疆鍐冲畾鏄惁鏈夋鎶曡祫椤癸紝濡傛腐鍙版病鏈夌櫥褰曟姇璧�
         ParseConfig();
 
@@ -53,77 +60,225 @@
 
     public override void Release()
     {
-        FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
         DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
-        DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
+        RechargeManager.Instance.rechargeCountEvent -= OnRechargeCountEvent;
     }
 
     public bool IsOpen()
     {
-        return FuncOpen.Instance.IsFuncOpen(FuncID);
+        return FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.PrivilegeCard);
     }
 
     
     public void OnBeforePlayerDataInitialize()
     {
         m_InvestInfos.Clear();
-        m_InvestSingleInfos.Clear();
+        lastTotalBuyCountDict.Clear();
     }
 
-    public void OnPlayerLoginOk()
-    {
-        UpdateRedpoint();
-    }
 
 
     void ParseConfig()
     {
-        investTypes.Clear();
         var funcConfig = FuncConfigConfig.Get("InvestCost");
-        m_InvestRechargeIds = ConfigParse.ParseIntArrayDict(funcConfig.Numerical3);
-        //m_Redpoints
-
-        investTypes = m_InvestRechargeIds.Keys.ToList();
-
-        investTypes.Sort();
-
-        var configs = InvestConfig.GetValues();
-        for (int i = 0; i < configs.Count; i++)
+        m_InvestRechargeIds = ConfigParse.ParseIntArrayDict(funcConfig.Numerical1);
+        foreach (var item in m_InvestRechargeIds)
         {
-            var config = configs[i];
-            if (!investTypes.Contains(config.type))
-            {
-                continue;
-            }
+            m_InvestCTGIDToType[item.Value[0]] = item.Key;
+        }
 
-            Dictionary<int, List<Item>> dict;
-            if (!m_InvestItems.TryGetValue(config.type, out dict))
-            {
-                dict = new Dictionary<int, List<Item>>();
-                m_InvestItems.Add(config.type, dict);
-            }
+        funcConfig = FuncConfigConfig.Get("InvestDay");
+        m_InvestDays = ConfigParse.ParseIntDict(funcConfig.Numerical1);
+        m_InvestMaxDays = ConfigParse.ParseIntDict(funcConfig.Numerical2);
+        m_InvestItems = ConfigParse.ParseIntArray2Dict(funcConfig.Numerical3);
 
-            List<Item> items;
-            if (!dict.TryGetValue(config.id, out items))
-            {
-                items = new List<Item>();
-                dict.Add(config.id, items);
-            }
 
-            var itemArray = config.award[1];    //1鏆傛椂绾﹀畾鏈堝崱 姘镐箙鍗★紝鍏朵粬鐨勮嚜瀹氫箟鍚庣画鍐嶅畾
-            for (int j = 0; j < itemArray.Length; j++)
+        funcConfig = FuncConfigConfig.Get("InvestPower");
+        m_InvestAddFBCount = ConfigParse.ParseDictInDict(funcConfig.Numerical1);
+        m_InvestFreeFBID = ConfigParse.ParseIntArrayDict(funcConfig.Numerical2);
+        m_InvestArenaMaxCnt = ConfigParse.ParseIntDict(funcConfig.Numerical3);
+        m_InvestAddBlessEnergyCount = ConfigParse.ParseIntDict(funcConfig.Numerical4);
+
+        funcConfig = FuncConfigConfig.Get("PrivilegeCard");
+        m_PrivilegeLins = ConfigParse.ParseIntDict(funcConfig.Numerical1);
+        m_PrivilegeFightSpeed = ConfigParse.ParseIntDict(funcConfig.Numerical2);
+        heroScoreCallOpenType = JsonMapper.ToObject<int[]>(funcConfig.Numerical3);
+        
+    }
+
+    Dictionary<int, int> lastTotalBuyCountDict = new Dictionary<int, int>();
+    void OnRechargeCountEvent(int ctgID)
+    {
+
+        if (m_InvestCTGIDToType.ContainsKey(ctgID))
+        {
+            var type = m_InvestCTGIDToType[ctgID];
+            RechargeManager.Instance.TryGetRechargeCount(ctgID, out var rechargeCount);
+            if (!DTC0403_tagPlayerLoginLoadOK.finishedLogin)
             {
-                items.Add(new Item()
-                {
-                    id = itemArray[j][0],
-                    countEx = itemArray[j][1],
-                    bind = itemArray[j][2],
-                });
+                lastTotalBuyCountDict[type] = rechargeCount.totalCount;
+                return;
+            }
+            var count = 0;
+            lastTotalBuyCountDict.TryGetValue(type, out count);
+            if (count < rechargeCount.totalCount)
+            {
+                lastTotalBuyCountDict[type] = rechargeCount.totalCount;
+                UIManager.Instance.OpenWindow<PrivilegeActiveCardWin>(type);
             }
         }
     }
 
-    public OrderInfoConfig GetOrderInfoId(int type)
+
+
+    //鑾峰彇鎶曡祫鍓╀綑鏃堕棿 绉�
+    public int GetInvestLeftTime(int type)
+    {
+        if (type == 1 && m_InvestInfos[type].InvestEndTime > 0)
+        {
+            //鏈堝崱 闄愭椂绫诲瀷鐨勬姇璧� 鏈埌鏈熷氨绠楁姇璧�
+            return m_InvestInfos[type].InvestEndTime - TimeUtility.AllSeconds;
+        }
+        return 0;
+    }
+
+
+
+    //0-鏈姇璧� 1-鍙鍙� 2-宸查鍙�
+    public int GetInvestState(int type)
+    {
+        if (IsInvested(type))
+        {
+            if (m_InvestInfos[type].AwardState == 0)
+            {
+                return 1;
+            }
+            return 2;
+        }
+        return 0;
+    }
+
+
+    //鍒ゆ柇鏄惁璐拱浜嗘姇璧�
+    public bool IsInvested(int type)
+    {
+        if (!m_InvestInfos.ContainsKey(type))
+        {
+            return false;
+        }
+        if (type == 1)
+        {
+            //鏈堝崱 闄愭椂绫诲瀷鐨勬姇璧� 鏈埌鏈熷氨绠楁姇璧�
+            return m_InvestInfos[type].InvestEndTime > 0 && m_InvestInfos[type].InvestEndTime > TimeUtility.AllSeconds;
+        }
+        
+        //姘镐箙绫诲瀷鐨勬姇璧� 鍙璐拱浜嗗氨绠楁姇璧�
+        return m_InvestInfos[type].InvestBuyTime > 0;
+    }
+
+
+    //type 鎶曡祫绫诲瀷
+    public void SendGetReward(int type, int id = 0)
+    {
+        var pak = new CA541_tagCMGetInvestReward();
+        pak.InvestType = (byte)type;
+        pak.RewardIndex = (byte)id;
+        GameNetSystem.Instance.SendInfo(pak);
+    }
+
+    //璐拱鎶曡祫
+    public void BuyInvest(int type)
+    {
+        RechargeManager.Instance.CTG(GetOrderInfo(type));
+    }
+
+
+    public void UpdateInvestInfo(HA338_tagSCInvestInfo package)
+    {
+
+        m_InvestInfos[package.InvestType] = new InvestInfo()
+        {
+            InvestBuyTime = (int)package.InvestBuyTime,
+            InvestEndTime = (int)package.InvestEndTime,
+            AwardState = package.AwardState
+        };
+
+
+        UpdateRedpoint();
+
+        if (onInvestUpdate != null)
+        {
+            onInvestUpdate(package.InvestType);
+        }
+    }
+
+    void UpdateRedpoint()
+    {
+        if (!IsOpen())
+        {
+            return;
+        }
+
+        redpoint1.state = GetInvestState(monthCardType) == 1 ? RedPointState.Simple : RedPointState.None;
+        redpoint2.state = GetInvestState(foreverCardType) == 1 ? RedPointState.Simple : RedPointState.None;
+
+    }
+
+    #region 鐗规潈鎺ュ彛
+
+    //鍓湰澧炲姞鐨勮喘涔版鏁颁笂闄�
+    public int GetAddFBBuyCount(int _mapID)
+    {
+        int addCount = 0;
+        foreach (var item in m_InvestAddFBCount)
+        {
+            if (!IsInvested(item.Key))
+            {
+                continue;
+            }
+            foreach (var mapID in item.Value.Keys)
+            {
+                if (mapID == _mapID)
+                {
+                    addCount += item.Value[mapID];
+                }
+            }
+        }
+
+        return addCount;
+    }
+
+    //鍓湰鍏嶈垂鐨勮喘涔版鏁�
+    public bool GetFBIsFree(int _mapID)
+    {
+        foreach (var item in m_InvestFreeFBID)
+        {
+            if (!IsInvested(item.Key))
+            {
+                continue;
+            }
+            foreach (var mapID in item.Value)
+            {
+                if (mapID == _mapID)
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+
+    public int GetPrivilegeLins(int type)
+    {
+        if (m_PrivilegeLins.ContainsKey(type))
+        {
+            return m_PrivilegeLins[type];
+        }
+        return 0;
+    }
+
+    public OrderInfoConfig GetOrderInfo(int type)
     {
         var ids = m_InvestRechargeIds[type];
         for (int i = 0; i < ids.Length; i++)
@@ -137,241 +292,100 @@
         return null;
     }
 
-
-    public bool hasInvestType(int type)
+    public int GetCTGID(int type)
     {
-        return investTypes.Contains(type);
+        return m_InvestRechargeIds[type][0];
     }
 
-
-    public int GetInvestPassDays(int type)
+    public int[][] GetDayAwards(int type)
     {
-        return m_InvestInfos.ContainsKey(type) ? m_InvestInfos[type].days : 0;
+        return m_InvestItems[type];
     }
 
-    //鑾峰緱鍗曟姇璧勭殑鎬绘敹鐩�
-    public long GetTotalIncome(int type)
+    //婕旀鍦哄嚟璇佷笂闄�
+    public int GetArenaAddMaxCount()
     {
-        long income = 0;
-        if (m_InvestItems.ContainsKey(type))
+        int addCount = 0;
+        foreach (var item in m_InvestArenaMaxCnt)
         {
-            var keyList = m_InvestItems[type].Keys.ToList();
-            for (int i = 0; i < keyList.Count; i++)
+            if (!IsInvested(item.Key))
             {
-                var items = m_InvestItems[type][keyList[i]];
-                for (var j = 0; j < items.Count; j++)
-                {
-                    var item = items[j];
-                    if (item.id == 20 || item.id == 30)
-                        income += item.countEx;
-                }
+                continue;
             }
+            addCount += item.Value;
         }
-        return income;
+
+        return addCount;
     }
 
-
-    //id 涓鸿〃閲岀殑ID
-    //0-鏈姇璧� 1-鏈揪鎴� 2-鍙鍙� 3-宸查鍙�
-    public int GetSingleInvestState(int type, int id)
+    //璐拱澶╂暟鏄惁杈句笂闄�
+    public bool IsBuyMaxDay(int type)
     {
-        if (IsInvested(type))
+        if (m_InvestMaxDays.ContainsKey(type) && m_InvestInfos.ContainsKey(type))
         {
-            var day = GetInvestPassDays(type);
-            if (m_InvestItems.ContainsKey(type)
-                && m_InvestItems[type].ContainsKey(id))
+            if (m_InvestInfos[type].InvestEndTime > 0)
             {
-                if (IsRewardGot(type, id))
-                {
-                    return 3;
-                }
-                var config = InvestConfig.Get(id);
-
-                if (!m_InvestSingleInfos.ContainsKey(type))
-                {
-                    return 0;
-                }
-
-                var index = id % 100;
-                //姣忎釜鏁版寜浣嶅瓨31涓縺娲荤储寮�
-                var listIndex = index / 31;
-                var bitIndex = index % 31;
-
-
-                return day < config.needDay ? 1 : 2;
+                return (m_InvestInfos[type].InvestEndTime - TimeUtility.AllSeconds) / 60 / 60 / 24 + m_InvestDays[type] >= m_InvestMaxDays[type];
             }
-        }
-        return 0;
-    }
-
-
-
-    public bool TryGetItems(int type, int id, out List<Item> items)
-    {
-        items = null;
-        if (m_InvestItems.ContainsKey(type))
-        {
-            return m_InvestItems[type].TryGetValue(id, out items);
         }
         return false;
     }
 
-    public List<int> GetIdsByType(int type)
+    //绁濈鑳介噺涓婇檺
+    public int GetBlessAddEnergyMax()
     {
-        if (m_InvestItems.ContainsKey(type))
+        int addCount = 0;
+        foreach (var item in m_InvestAddBlessEnergyCount)
         {
-            return m_InvestItems[type].Keys.ToList();
+            if (!IsInvested(item.Key))
+            {
+                continue;
+            }
+            addCount += item.Value;
         }
-        return null;
+
+        return addCount;
     }
 
-    //鍒ゆ柇鏄惁璐拱浜嗘姇璧�
-    public bool IsInvested(int type)
+    //鏄惁婵�娲昏嫳闆勭Н鍒嗗彫鍞�
+    public bool IsActiveHeroScoreCall()
     {
-        return m_InvestInfos.ContainsKey(type) && m_InvestInfos[type].money > 0;
-    }
-
-    //濂栧姳鏄惁宸查鍙�
-    public bool IsRewardGot(int type, int id)
-    {
-        if (m_InvestSingleInfos.ContainsKey(type))
+        foreach (var type in heroScoreCallOpenType)
         {
-            var index = id % 100;
-            //姣忎釜鏁版寜浣嶅瓨31涓縺娲荤储寮�
-            var listIndex = index / 31;
-            var bitIndex = index % 31;
-            return ((int)Math.Pow(2, bitIndex) & m_InvestSingleInfos[type][1][listIndex]) != 0;
+            if (IsInvested(type))
+            {
+                return true;
+            }
         }
         return false;
     }
 
-
-    private void OnFuncStateChangeEvent(int id)
+    public bool IsActiveFightSpeed(int speed)
     {
-        if (id == FuncID)
+        foreach (var item in m_PrivilegeFightSpeed)
         {
-            // activity.StateUpdate(id);
-            UpdateRedpoint();
-        }
-
-    }
-
-    
-
-    public void SendGetReward(int type, int id)
-    {
-        var pak = new CA541_tagCMGetInvestReward();
-        pak.InvestType = (byte)type;
-        pak.RewardIndex = (byte)(id % 100);
-        GameNetSystem.Instance.SendInfo(pak);
-    }
-
-    //璐拱鎶曡祫
-    public void BuyInvest(int type)
-    {
-        RechargeManager.Instance.CTG(GetOrderInfoId(type));
-    }
-
-    public void UpdateInvestInfo(HA338_tagMCInvestInfo package)
-    {
-        if (!investTypes.Contains(package.InvestType))
-        {
-            return;
-        }
-
-        m_InvestInfos[package.InvestType] = new InvestInfo()
-        {
-            days = (int)package.CurDay,
-            money = package.CurDay >= 1 ? 1 : 0,
-        };
-
-        List<List<int>> singleInfos;
-        if (!m_InvestSingleInfos.TryGetValue(package.InvestType, out singleInfos))
-        {
-            singleInfos = new List<List<int>>();
-            m_InvestSingleInfos.Add(package.InvestType, singleInfos);
-        }
-        singleInfos.Clear();
-        singleInfos.Add(new List<int>());
-        singleInfos.Add(new List<int>());
-        singleInfos.Add(new List<int>());
-        singleInfos[0].Add((int)package.CurDay);
-        for (int i = 0; i < package.ValueCount; i++)
-        {
-            singleInfos[1].Add((int)package.RewardValue[i]);
-            singleInfos[2].Add((int)package.ProgressValue[i]);
-        }
-        UpdateRedpoint();
-
-        if (onInvestUpdate != null)
-        {
-            onInvestUpdate(package.InvestType);
-        }
-    }
-
-    void UpdateRedpoint()
-    {
-        List<int> redpointTypes = new List<int>();
-        if (IsOpen())
-        {
-            for (var i = 0; i < investTypes.Count; i++)
+            if (!IsInvested(item.Key))
             {
-                var type = investTypes[i];
-                if (!IsInvested(type))
-                {
-                    continue;
-                }
-                var keyList = m_InvestItems[type].Keys.ToList();
-                for (int j = 0; j < keyList.Count; j++)
-                {
-                    var id = keyList[j];
-                    if (GetSingleInvestState(type, id) == 2)
-                    {
-                        redpointTypes.Add(type);
-                        break;
-                    }
-                }
+                continue;
+            }
+            if (item.Value == speed)
+            {
+                return true;
             }
         }
-
-        var redList = m_Redpoints.Keys.ToList();
-        for (int j = 0; j < redList.Count; j++)
-        {
-            var type = redList[j];
-            m_Redpoints[type].state = redpointTypes.Contains(type) ? RedPointState.Simple : RedPointState.None;
-        }
+        return false;
     }
 
-    
+    #endregion
 
-    //宸茬粡璐拱骞堕鍙栨墍鏈夌墿鍝�
-    public bool IsFinish()
-    {
-        for (int i = 0; i < investTypes.Count; i++)
-        {
-            int type = investTypes[i];
-            //蹇界暐姘镐箙鍗�
-            if (type == foreverCardType)
-                continue;
-            var idsList = GetIdsByType(type);
-            if (idsList.IsNullOrEmpty())
-                continue;
-            for (int j = 0; j < idsList.Count; j++)
-            {
-                int id = idsList[j];
-                if (GetSingleInvestState(type, id) != 3)
-                {
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
+
+
 
     public struct InvestInfo
     {
-        public int money;
-        public int days;
+        public int InvestBuyTime;    // 鎶曡祫璐拱鏃堕棿鎴筹紝姘镐箙鐨勯�氳繃璇ユ椂闂村垽鏂槸鍚︽湁鏁堟垨宸茶繃澶╂暟锛屼换鎰忕被鍨嬪潎鏈夎鍊硷紝杩囨湡娌℃湁閲嶇疆锛屽墠绔嚜宸卞垽鏂�
+        public int InvestEndTime;    // 鎶曡祫鍒版湡鏃堕棿鎴筹紝闈炴案涔呯殑閫氳繃璇ユ椂闂村垽鏂埌鏈熸椂闂达紝鏈夊ぉ鏁伴檺鍒剁殑鎵嶆湁鍊�
+        public int AwardState;    // 浠婃棩鏄惁宸查鍙栧鍔�
     }
 }
 

--
Gitblit v1.8.0