Browse Source

合适多余物品数量是否进入分解栏问题

huangxiaoyue 2 years ago
parent
commit
e7dcf632e9

+ 37 - 0
GameClient/Assets/Editor/Excel/Scanner/ItemApproachScanner.cs

@@ -21,11 +21,13 @@ namespace GFGEditor
             ItemCfg[] dataArray = ItemCfgArray.Instance.dataArray;
             GetApproachCall[] actions = new GetApproachCall[] { GetClothingShopApproach, GetLeaguePrayApproach, GetLeagueAnswerApproach, CheckStoreApproach, GetClothingSyntheticApproach, GetSuitGuideApproach, GetSuitSyntheticApproach, GetClothingDecomposeApproach, CheckClothingFosterApproach, CheckDailyTaskApproach, GetZhaiXingApproach, GetStoryLevelApproach };
             Dictionary<SuitCfg, List<int>> suitDic = new Dictionary<SuitCfg, List<int>>();
+            Dictionary<ItemCfg, List<int>> syntheticSuitDic = new Dictionary<ItemCfg, List<int>>();
             int suitPartTotalCount = 0;
             foreach (ItemCfg cfg in dataArray)
             {
                 HandleItemAndSuitTable(cfg, suitDic);
                 HandleItemApproch(cfg, actions);
+                HandleItemSyntheticSuit(cfg, syntheticSuitDic);
             }
             var globalCfg = GlobalCfgArray.globalCfg;
             SQLiteHelper.Instance.OpenConnection();
@@ -51,6 +53,14 @@ namespace GFGEditor
                 }
                 globalCfg.suitPartTotalCount = suitPartTotalCount;
                 UpdateGlobalCfg(globalCfg);
+
+                //材料对应的套装id
+                foreach (var a in syntheticSuitDic)
+                {
+                    var names = new string[] { nameof(a.Key.syntheticSuitArr).Replace("Arr", "") };
+                    var values = new string[] { string.Join(";", a.Value) };
+                    SQLiteHelper.Instance.UpdateValues(nameof(ItemCfgArray), names, values, nameof(a.Key.id), a.Key.id.ToString());
+                }
             }
             catch (Exception e)
             {
@@ -69,6 +79,33 @@ namespace GFGEditor
             SQLiteHelper.Instance.UpdateValues(nameof(GlobalCfgArray), names, values, nameof(globalCfg.id), globalCfg.id.ToString());
         }
 
+        private static void HandleItemSyntheticSuit(ItemCfg itemCfg, Dictionary<ItemCfg, List<int>> syntheticSuitDic)
+        {
+            if (itemCfg.syntheticMateriarsArr.Length <= 0)
+            {
+                return;
+            }
+            if (itemCfg.itemType == ConstItemType.DRESS_UP)
+            {
+                ItemCfg materialItemCfg;
+                foreach (int[] materiars in itemCfg.syntheticMateriarsArr)
+                {
+                    int materialId = materiars[0];
+                    materialItemCfg = ItemCfgArray.Instance.GetCfg(materialId);
+                    if (materialItemCfg != null)
+                    {
+                        syntheticSuitDic.TryGetValue(materialItemCfg, out var syntheticSuitList);
+                        if (syntheticSuitList == null)
+                        {
+                            syntheticSuitList = new List<int>();
+                            syntheticSuitDic[materialItemCfg] = syntheticSuitList;
+                        }
+                        syntheticSuitList.Add(itemCfg.id);
+                    }
+                }
+            }
+        }
+
         private static void HandleItemAndSuitTable(ItemCfg itemCfg, Dictionary<SuitCfg, List<int>> suitDic)
         {
             if (itemCfg.suitId <= 0)

+ 26 - 1
GameClient/Assets/Game/HotUpdate/Data/DecomposeDataManager.cs

@@ -29,6 +29,7 @@ namespace GFGGame
                 _decomposeData[rarity].Add(itemId);
             }
         }
+
         public void Remove(int itemId)
         {
             int rarity = ItemCfgArray.Instance.GetCfg(itemId).rarity;
@@ -40,6 +41,28 @@ namespace GFGGame
             }
         }
 
+        //分解需要扣去合成需要的数量
+        public int DeductSynthesisNeedNum(int itemId)
+        {
+            ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
+            if (itemCfg == null)
+                return 0;
+
+            int sum = 0;
+            foreach (int syntheticId in itemCfg.syntheticSuitArr)
+            {
+                if (ItemDataManager.GetItemNum(syntheticId) <= 0) { 
+                    ItemCfg syntheticItemCfg = ItemCfgArray.Instance.GetCfg(syntheticId);
+                    foreach (int[] MateriarsInfo in syntheticItemCfg.syntheticMateriarsArr)
+                    {
+                        if(MateriarsInfo[0] == itemId)
+                            sum += MateriarsInfo[1];
+                    }
+                }
+            }
+            return sum;
+        }
+
         public List<int> GetDecomposeDataByRarity(int rarity)
         {
             if (!_decomposeData.ContainsKey(rarity)) return null;
@@ -67,7 +90,9 @@ namespace GFGGame
         //物品可分解的数量
         public long ItemCanDecomposeCount(int itemId)
         {
-            return ItemDataManager.GetItemNum(itemId) - 1;
+            //合成需要的数量
+            int synthesisNum = DeductSynthesisNeedNum(itemId);   
+            return ItemDataManager.GetItemNum(itemId) - 1 - synthesisNum;
         }
         public void InitSuitSyntheticMaterias()
         {