From 417cfe9fa764490bc3710e89030cc2c90de5f727 Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期一, 03 六月 2019 19:32:20 +0800
Subject: [PATCH] 7065 【2.0】【开发】丹炉新增批量炼丹

---
 System/Alchemy/AlchemyModel.cs |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/System/Alchemy/AlchemyModel.cs b/System/Alchemy/AlchemyModel.cs
index 7d2cee0..8447b59 100644
--- a/System/Alchemy/AlchemyModel.cs
+++ b/System/Alchemy/AlchemyModel.cs
@@ -8,7 +8,7 @@
     [XLua.LuaCallCSharp]
     public class AlchemyModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
     {
-        Dictionary<int, uint> m_AlchemyTimes = new Dictionary<int, uint>();
+        Dictionary<int, AlchemyTime> m_AlchemyTimes = new Dictionary<int, AlchemyTime>();
         Dictionary<int, Dictionary<int, AlchemyCount>> m_AlchemyCounts = new Dictionary<int, Dictionary<int, AlchemyCount>>();
         Dictionary<int, int> m_AlchemyQualityLucks = new Dictionary<int, int>();
         Dictionary<int, List<Item>> m_AlchemyMaterials = new Dictionary<int, List<Item>>();
@@ -53,6 +53,8 @@
 
         public bool alchemyNormalNotifySymbol { get; set; }
         public bool alchemyFairyNotifySymbol { get; set; }
+
+        public int maxBatchAlchemyCount { get; private set; }
 
         public bool isServerPrepare { get; private set; }
 
@@ -203,6 +205,7 @@
             {
                 var funcConfig = FuncConfigConfig.Get("AlchemyOverLimit");
                 var itemId = int.Parse(funcConfig.Numerical1);
+                maxBatchAlchemyCount = int.Parse(funcConfig.Numerical2);
 
                 var configs = AttrFruitConfig.GetValues();
                 foreach (var config in configs)
@@ -235,9 +238,9 @@
             }
         }
 
-        public bool TryGetAlchemyStartTime(int alchemyId, out uint tick)
+        public bool TryGetAlchemyStartTime(int alchemyId, out AlchemyTime alchemyTime)
         {
-            return m_AlchemyTimes.TryGetValue(alchemyId, out tick);
+            return m_AlchemyTimes.TryGetValue(alchemyId, out alchemyTime);
         }
 
         public bool TryGetAlchemyCount(int alchemyId, int luckValue, out AlchemyCount alchemyCount)
@@ -346,13 +349,14 @@
 
         public int GetStoveState(int alchemyId)
         {
-            uint tick = 0;
-            if (TryGetAlchemyStartTime(alchemyId, out tick)
-                && tick > 0)
+            AlchemyTime alchemyTime;
+            if (TryGetAlchemyStartTime(alchemyId, out alchemyTime)
+                && alchemyTime.startTick > 0)
             {
                 var config = AlchemyConfig.Get(alchemyId);
-                var startTime = TimeUtility.GetTime(tick);
-                var seconds = config.NeedTime - (float)(TimeUtility.ServerNow - startTime).TotalSeconds;
+                var startTime = TimeUtility.GetTime(alchemyTime.startTick);
+                var seconds = config.NeedTime * alchemyTime.count
+                    - (float)(TimeUtility.ServerNow - startTime).TotalSeconds;
                 return seconds > 0 ? 1 : 2;
             }
             return 0;
@@ -394,6 +398,34 @@
                 return drugUseLimit.GetUseLimit();
             }
             return 0;
+        }
+
+        public int GetCanAlchemyCount(int alchemyId)
+        {
+            Item item;
+            var count = 0;
+            if (IsAlchemyEnoughMaterial(alchemyId, out item))
+            {
+                List<Item> materials;
+                if (TryGetAlchemyMaterials(alchemyId, out materials))
+                {
+                    for (int i = 0; i < materials.Count; i++)
+                    {
+                        var mat = materials[i];
+                        var itemCount = packModel.GetItemCountByID(PackType.Item, mat.id);
+                        var _count = itemCount / mat.count;
+                        if (count == 0)
+                        {
+                            count = _count;
+                        }
+                        else
+                        {
+                            count = Mathf.Min(count, _count);
+                        }
+                    }
+                }
+            }
+            return count;
         }
 
         public bool IsGraspRecipe(int alchemyId)
@@ -442,7 +474,11 @@
             for (int i = 0; i < package.StoveCnt; i++)
             {
                 var data = package.InfoList[i];
-                m_AlchemyTimes[(int)data.AlchemyID] = data.StartTime;
+                m_AlchemyTimes[(int)data.AlchemyID] = new AlchemyTime()
+                {
+                    startTick = data.StartTime,
+                    count = data.AlchemyTimes,
+                };
 
                 if (isServerPrepare)
                 {
@@ -842,6 +878,12 @@
         }
     }
 
+    public struct AlchemyTime
+    {
+        public uint startTick;
+        public int count;
+    }
+
     public class AlchemyRedpoint
     {
         public readonly Redpoint redpoint;

--
Gitblit v1.8.0