From a14173f2788287574561b279a7fe09c3d05ea7ea Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期一, 17 九月 2018 15:41:41 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts

---
 System/Welfare/OperationTimeHepler.cs | 1144 ++++++++------------------------------------------------
 1 files changed, 173 insertions(+), 971 deletions(-)

diff --git a/System/Welfare/OperationTimeHepler.cs b/System/Welfare/OperationTimeHepler.cs
index 0eaf6a6..867222c 100644
--- a/System/Welfare/OperationTimeHepler.cs
+++ b/System/Welfare/OperationTimeHepler.cs
@@ -15,11 +15,13 @@
         public event Action<Operation> operationServerCloseEvent;//鐗规畩鎯呭喌涓嬭Е鍙�
         public event Action<Operation, int> operationEndEvent;//娲诲姩缁撴潫鏃堕棿瑙﹀彂  绗簩涓弬鏁�0--杩囨椿鍔ㄦ椂闂磋Е鍙�  1--杩囨椿鍔ㄥぉ瑙﹀彂
         public event Action<Operation, int> operationStartEvent;//娲诲姩寮�濮嬫椂闂村苟涓旀弧瓒冲紑鍚潯浠惰Е鍙� 绗簩涓弬鏁�0--娲诲姩鏃堕棿瑙﹀彂  1--娲诲姩澶╄Е鍙�
-        public event Action<Operation> operationAdvanceEvent;//娲诲姩鎻愬墠寮�鏀句簨浠�
+        public event Action<int> dayResetEvent;//娲诲姩閲嶇疆浜嬩欢0-0鐐� 1-5鐐�
+        public event Action<Operation> operationAdvanceEvent;//娲诲姩鍦ㄦ彁鍓嶅紑鍚殑鏃堕棿鍐�
         public OperationTimeHepler()
         {
             DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += BeforePlayerDataInitializeEvent;
             GlobalTimeEvent.Instance.secondEvent += SecondEvent;
+            TimeMgr.Instance.OnHourEvent += HourEvent;
         }
 
         private void BeforePlayerDataInitializeEvent()
@@ -38,8 +40,8 @@
                 if (operationDict.ContainsKey((Operation)i))
                 {
                     var operation = operationDict[(Operation)i];
-                    if (operation.InDay(TimeUtility.ServerNow) && operation.SatisfyOpenCondition()
-                        && !operation.inDateNotify)
+                    if (!operation.inDateNotify && operation.SatisfyOpenCondition()
+                        && operation.InDay(TimeUtility.ServerNow))
                     {
                         operation.inDateNotify = true;
                         operation.stepDateNotify = false;
@@ -49,7 +51,7 @@
                             operationStartEvent((Operation)i, 1);
                         }
                     }
-                    else if (!operation.InDay(TimeUtility.ServerNow) && !operation.stepDateNotify)
+                    else if (!operation.stepDateNotify && !operation.InDay(TimeUtility.ServerNow))
                     {
                         operation.inDateNotify = false;
                         operation.stepDateNotify = true;
@@ -59,22 +61,22 @@
                             operationEndEvent((Operation)i, 1);
                         }
                     }
-                    if (operation.InTime(TimeUtility.ServerNow) && operation.SatisfyOpenCondition()
-                        && !operation.inTimeNotify)
+                    if (!operation.inTimeNotify && operation.SatisfyOpenCondition()
+                        && operation.InTime(TimeUtility.ServerNow))
                     {
                         operation.inTimeNotify = true;
                         operation.stepTimeNotify = false;
-                        operation.inAdvanceNotify = false;
                         DebugEx.LogFormat("{0}  娲诲姩鏃堕棿寮�濮�", (Operation)i);
                         if (operationStartEvent != null)
                         {
                             operationStartEvent((Operation)i, 0);
                         }
                     }
-                    else if (!operation.InTime(TimeUtility.ServerNow) && !operation.stepTimeNotify)
+                    else if (!operation.stepTimeNotify && !operation.InTime(TimeUtility.ServerNow))
                     {
                         operation.inTimeNotify = false;
                         operation.stepTimeNotify = true;
+                        operation.inAdvanceNotify = false;
                         DebugEx.LogFormat("{0}  娲诲姩鏃堕棿缁撴潫", (Operation)i);
                         if (operationEndEvent != null)
                         {
@@ -82,15 +84,33 @@
                         }
                     }
 
-                    if (!operation.inAdvanceNotify && operation.InAdvanceTime(TimeUtility.ServerNow))
+                    if (!operation.inAdvanceNotify && operation.SatisfyOpenCondition()
+                        && operation.InAdvanceTime(TimeUtility.ServerNow))
                     {
                         operation.inAdvanceNotify = true;
+                        DebugEx.LogFormat("{0}  娲诲姩鎻愬墠寮�鍚�", (Operation)i);
                         if (operationAdvanceEvent != null)
                         {
                             operationAdvanceEvent((Operation)i);
                         }
                     }
                 }
+            }
+        }
+
+        private void HourEvent()
+        {
+            if (!(StageManager.Instance.CurrentStage is DungeonStage))
+            {
+                return;
+            }
+            if (TimeUtility.Hour == 0 && dayResetEvent != null)
+            {
+                dayResetEvent(0);
+            }
+            if (TimeUtility.Hour == 5 && dayResetEvent != null)
+            {
+                dayResetEvent(1);
             }
         }
 
@@ -102,22 +122,9 @@
         {
             OperationBase operation = null;
             operationDict.TryGetValue(Operation.MultipleExp, out operation);
-            if (package.StartDate == null || package.StartDate.Equals(string.Empty)
-                || package.EndtDate == null || package.EndtDate.Equals(string.Empty))
+            if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
             {
-                if (operationDict.ContainsKey(Operation.MultipleExp))
-                {
-                    operationDict.Remove(Operation.MultipleExp);
-                }
-                if (operationServerCloseEvent != null)
-                {
-                    operationServerCloseEvent(Operation.MultipleExp);
-                }
-                if (operationEndEvent != null)
-                {
-                    operationEndEvent(Operation.MultipleExp, 0);
-                    operationEndEvent(Operation.MultipleExp, 1);
-                }
+                ForceStopOperation(Operation.MultipleExp);
             }
             else
             {
@@ -131,17 +138,10 @@
                 operation.endDate = ParseOperationDate(package.EndtDate);
                 operation.limitLv = package.LimitLV;
                 (operation as OperationMultiExp).multiple = (int)package.AddExpRate + 10000;
-                if (package.ActivityTimeCount == 0)
+                for (int i = 0; i < package.ActivityTimeCount; i++)
                 {
-                    operation.allDay = true;
-                }
-                else
-                {
-                    for (int i = 0; i < package.ActivityTimeCount; i++)
-                    {
-                        operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime,
-                            package.ActivityTime[i].EndtTime));
-                    }
+                    operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime,
+                        package.ActivityTime[i].EndtTime));
                 }
                 if (operationTimeUpdateEvent != null)
                 {
@@ -149,6 +149,7 @@
                 }
             }
         }
+
         /// <summary>
         /// 娑堣垂杩斿埄
         /// </summary>
@@ -157,22 +158,9 @@
         {
             OperationBase operationBase = null;
             operationDict.TryGetValue(Operation.ConsumeRebate, out operationBase);
-            if (package.StartDate == null || package.StartDate.Equals(string.Empty)
-                || package.EndtDate == null || package.EndtDate.Equals(string.Empty))
+            if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
             {
-                if (operationDict.ContainsKey(Operation.ConsumeRebate))
-                {
-                    operationDict.Remove(Operation.ConsumeRebate);
-                }
-                if (operationServerCloseEvent != null)
-                {
-                    operationServerCloseEvent(Operation.ConsumeRebate);
-                }
-                if (operationEndEvent != null)
-                {
-                    operationEndEvent(Operation.ConsumeRebate, 0);
-                    operationEndEvent(Operation.ConsumeRebate, 1);
-                }
+                ForceStopOperation(Operation.ConsumeRebate);
             }
             else
             {
@@ -186,37 +174,15 @@
                 operation.limitLv = package.LimitLV;
                 operation.startDate = ParseOperationDate(package.StartDate);
                 operation.endDate = ParseOperationDate(package.EndtDate);
-                operation.allDay = true;
                 operation.dayReset = package.IsDayReset == 1;
-                for (int i = 0; i < package.AwardDays; i++)
-                {
-                    var _rebate = package.AwardDayInfo[i];
-                    OperationConsumeRebate.Rebate rebate = new OperationConsumeRebate.Rebate();
-                    for (int k = 0; k < _rebate.AwardCount; k++)
-                    {
-                        OperationConsumeRebate.RebateGrade rebateGrade = new OperationConsumeRebate.RebateGrade();
-                        rebateGrade.needGold = (int)_rebate.AwardInfo[k].NeedGold;
-                        rebateGrade.index = _rebate.AwardInfo[k].AwardIndex;
-                        for (int q = 0; q < _rebate.AwardInfo[k].AwardItemCount; q++)
-                        {
-                            var _item = _rebate.AwardInfo[k].AwardItem[q];
-                            rebateGrade.items.Add(new OperationConsumeRebate.Item()
-                            {
-                                itemId = (int)_item.ItemID,
-                                count = _item.ItemCount,
-                                isBind = _item.IsBind,
-                            });
-                        }
-                        rebate.rebateGrades.Add(rebateGrade);
-                    }
-                    operation.rebates.Add(rebate);
-                }
+                operation.ParseRebate(package);
                 if (operationTimeUpdateEvent != null)
                 {
                     operationTimeUpdateEvent(Operation.ConsumeRebate);
                 }
             }
         }
+
         /// <summary>
         /// 闄愭椂鐗规儬
         /// </summary>
@@ -227,19 +193,7 @@
             operationDict.TryGetValue(Operation.FlashSale, out operationBase);
             if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
             {
-                if (operationDict.ContainsKey(Operation.FlashSale))
-                {
-                    operationDict.Remove(Operation.FlashSale);
-                }
-                if (operationServerCloseEvent != null)
-                {
-                    operationServerCloseEvent(Operation.FlashSale);
-                }
-                if (operationEndEvent != null)
-                {
-                    operationEndEvent(Operation.FlashSale, 0);
-                    operationEndEvent(Operation.FlashSale, 1);
-                }
+                ForceStopOperation(Operation.FlashSale);
             }
             else
             {
@@ -253,80 +207,32 @@
                 operation.limitLv = package.LimitLV;
                 operation.startDate = ParseOperationDate(package.StartDate);
                 operation.endDate = ParseOperationDate(package.EndtDate);
-                operation.dateEnumerator = new OperationDateEnumerator(operation.startDate, operation.endDate);
                 operation.dayReset = package.IsDayReset == 1;
-                if (package.ActivityTimeCount == 0)
+                operation.inAdvanceMinute = package.AdvanceMinutes;
+                for (int i = 0; i < package.ActivityTimeCount; i++)
                 {
-                    operation.allDay = true;
+                    operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime,
+                        package.ActivityTime[i].EndtTime));
                 }
-                else
-                {
-                    for (int i = 0; i < package.ActivityTimeCount; i++)
-                    {
-                        operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime,
-                            package.ActivityTime[i].EndtTime));
-                    }
-                }
-
-                for (int i = 0; i < package.ShopCount; i++)
-                {
-                    var flashShop = new OperationFlashSale.FlashSale();
-                    var shop = package.ShopInfo[i];
-                    flashShop.gifts = new OperationFlashSale.FlashSaleGift[shop.GiftbagCount];
-                    for (int k = 0; k < shop.GiftbagCount; k++)
-                    {
-                        var gift = new OperationFlashSale.FlashSaleGift();
-                        var pakGift = shop.GiftbagInfo[k];
-                        gift.id = (int)pakGift.GiftID;
-                        gift.limitNum = pakGift.BuyCountLimit;
-                        gift.moneyNumber = (int)pakGift.MoneyNumber;
-                        gift.moneyType = pakGift.MoneyType;
-                        gift.moneyOriginal = (int)pakGift.MoneyOriginal;
-                        gift.items = new OperationFlashSale.FlashSaleItem[pakGift.GiftItemCount];
-                        for (int q = 0; q < pakGift.GiftItemCount; q++)
-                        {
-                            var item = new OperationFlashSale.FlashSaleItem();
-                            item.itemId = (int)pakGift.ItemInfo[q].ItemID;
-                            item.isBind = pakGift.ItemInfo[q].IsBind;
-                            item.itemCount = pakGift.ItemInfo[q].ItemCount;
-                            item.isMainItem = pakGift.ItemInfo[q].IsMainItem == 1;
-                            gift.items[q] = item;
-                        }
-                        flashShop.gifts[k] = gift;
-                    }
-                    operation.flashShops.Add(flashShop);
-                }
+                operation.ParsePackage(package);
                 if (operationTimeUpdateEvent != null)
                 {
                     operationTimeUpdateEvent(Operation.FlashSale);
                 }
             }
         }
+
         /// <summary>
         /// 闄愭椂绀煎寘
         /// </summary>
         /// <param name="package"></param>
-        /// 
         public void UpdateGiftPackage(HAA12_tagMCFlashGiftbagInfo package)
         {
             OperationBase operationBase = null;
             operationDict.TryGetValue(Operation.GiftPackage, out operationBase);
             if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
             {
-                if (operationDict.ContainsKey(Operation.GiftPackage))
-                {
-                    operationDict.Remove(Operation.GiftPackage);
-                }
-                if (operationServerCloseEvent != null)
-                {
-                    operationServerCloseEvent(Operation.GiftPackage);
-                }
-                if (operationEndEvent != null)
-                {
-                    operationEndEvent(Operation.GiftPackage, 0);
-                    operationEndEvent(Operation.GiftPackage, 1);
-                }
-
+                ForceStopOperation(Operation.GiftPackage);
             }
             else
             {
@@ -341,48 +247,13 @@
                 operation.startDate = ParseOperationDate(package.StartDate);
                 operation.endDate = ParseOperationDate(package.EndtDate);
                 operation.dayReset = package.IsDayReset == 1;
-                if (package.ActivityTimeCount == 0)
+                operation.inAdvanceMinute = package.AdvanceMinutes;
+                for (int i = 0; i < package.ActivityTimeCount; i++)
                 {
-                    operation.allDay = true;
+                    operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime,
+                        package.ActivityTime[i].EndtTime));
                 }
-                else
-                {
-                    for (int i = 0; i < package.ActivityTimeCount; i++)
-                    {
-                        operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime,
-                            package.ActivityTime[i].EndtTime));
-                    }
-                }
-                for (int i = 0; i < package.GiftbagTypeCount; i++)
-                {
-                    var GiftbagType = new GiftPackageClass.Gift_Package();
-                    var Giftbag = package.GiftbagTypeInfo[i];
-                    GiftbagType.gifts = new GiftPackageClass.GiftPackageGift[Giftbag.GiftbagCount];
-                    for (int k = 0; k < Giftbag.GiftbagCount; k++)
-                    {
-                        var gift = new GiftPackageClass.GiftPackageGift();
-                        var pakGift = Giftbag.GiftbagInfo[k];
-                        gift.id = (int)pakGift.GiftID;
-                        gift.limitNum = pakGift.BuyCountLimit;
-                        gift.rmb = (int)pakGift.RMB;
-                        gift.rmbOriginal = (int)pakGift.RMBOriginal;
-                        gift.OrderInfo = pakGift.OrderInfo;
-                        gift.OrderInfoLength = pakGift.OrderInfoLen;
-                        gift.items = new GiftPackageClass.GiftPackageItem[pakGift.GiftItemCount];
-
-                        for (int q = 0; q < pakGift.GiftItemCount; q++)
-                        {
-                            var item = new GiftPackageClass.GiftPackageItem();
-                            item.itemId = (int)pakGift.ItemInfo[q].ItemID;
-                            item.isBind = pakGift.ItemInfo[q].IsBind;
-                            item.itemCount = pakGift.ItemInfo[q].ItemCount;
-                            item.isMainItem = pakGift.ItemInfo[q].IsMainItem == 1;
-                            gift.items[q] = item;
-                        }
-                        GiftbagType.gifts[k] = gift;
-                    }
-                    operation.giftpackage1.Add(GiftbagType);
-                }
+                operation.ParsePackage(package);
                 if (operationTimeUpdateEvent != null)
                 {
                     operationTimeUpdateEvent(Operation.GiftPackage);
@@ -395,21 +266,7 @@
         {
             if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
             {
-                if (operationDict.ContainsKey(Operation.BossReborn))
-                {
-                    operationDict.Remove(Operation.BossReborn);
-                }
-
-                if (operationServerCloseEvent != null)
-                {
-                    operationServerCloseEvent(Operation.BossReborn);
-                }
-
-                if (operationEndEvent != null)
-                {
-                    operationEndEvent(Operation.BossReborn, 0);
-                    operationEndEvent(Operation.BossReborn, 1);
-                }
+                ForceStopOperation(Operation.BossReborn);
             }
             else
             {
@@ -423,10 +280,9 @@
 
                 operationBase.Reset();
                 operationBase.limitLv = package.LimitLV;
-                operationBase.allDay = true;
                 operationBase.startDate = ParseOperationDate(package.StartDate);
                 operationBase.endDate = ParseOperationDate(package.EndtDate);
-
+                operationBase.resetType = package.ResetType;
                 ModelCenter.Instance.GetModel<BossRebornModel>().UpdateTaskBaseInfos(package.TaskInfo); 
             }
         }
@@ -439,22 +295,9 @@
         {
             OperationBase operation = null;
             operationDict.TryGetValue(Operation.FairyCeremony, out operation);
-            if (package.StartDate == null || package.StartDate.Equals(string.Empty)
-                || package.EndtDate == null || package.EndtDate.Equals(string.Empty))
+            if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
             {
-                if (operationDict.ContainsKey(Operation.FairyCeremony))
-                {
-                    operationDict.Remove(Operation.FairyCeremony);
-                }
-                if (operationServerCloseEvent != null)
-                {
-                    operationServerCloseEvent(Operation.FairyCeremony);
-                }
-                if (operationEndEvent != null)
-                {
-                    operationEndEvent(Operation.FairyCeremony, 0);
-                    operationEndEvent(Operation.FairyCeremony, 1);
-                }
+                ForceStopOperation(Operation.FairyCeremony);
             }
             else
             {
@@ -467,7 +310,6 @@
                 operation.startDate = ParseOperationDate(package.StartDate);
                 operation.endDate = ParseOperationDate(package.EndtDate);
                 operation.limitLv = package.LimitLV;
-                operation.allDay = true;
                 if (operationTimeUpdateEvent != null)
                 {
                     operationTimeUpdateEvent(Operation.FairyCeremony);
@@ -483,22 +325,9 @@
         {
             OperationBase operation = null;
             operationDict.TryGetValue(Operation.MultipRealmPoint, out operation);
-            if (package.StartDate == null || package.StartDate.Equals(string.Empty)
-                || package.EndtDate == null || package.EndtDate.Equals(string.Empty))
+            if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
             {
-                if (operationDict.ContainsKey(Operation.MultipRealmPoint))
-                {
-                    operationDict.Remove(Operation.MultipRealmPoint);
-                }
-                if (operationServerCloseEvent != null)
-                {
-                    operationServerCloseEvent(Operation.MultipRealmPoint);
-                }
-                if (operationEndEvent != null)
-                {
-                    operationEndEvent(Operation.MultipRealmPoint, 0);
-                    operationEndEvent(Operation.MultipRealmPoint, 1);
-                }
+                ForceStopOperation(Operation.MultipRealmPoint);
             }
             else
             {
@@ -511,12 +340,28 @@
                 operation.startDate = ParseOperationDate(package.StartDate);
                 operation.endDate = ParseOperationDate(package.EndtDate);
                 operation.limitLv = package.LimitLV;
-                operation.allDay = true;
                 (operation as OperationMultipleRealmPoint).multiplePractice = package.Multiple;
                 if (operationTimeUpdateEvent != null)
                 {
                     operationTimeUpdateEvent(Operation.MultipRealmPoint);
                 }
+            }
+        }
+
+        void ForceStopOperation(Operation operationType)
+        {
+            if (operationDict.ContainsKey(operationType))
+            {
+                operationDict.Remove(operationType);
+            }
+            if (operationServerCloseEvent != null)
+            {
+                operationServerCloseEvent(operationType);
+            }
+            if (operationEndEvent != null)
+            {
+                operationEndEvent(operationType, 0);
+                operationEndEvent(operationType, 1);
             }
         }
 
@@ -545,17 +390,6 @@
             return false;
         }
 
-        public bool SideOfTime(Operation type, out int side)
-        {
-            side = 0;
-            OperationBase operation;
-            if (TryGetOperationTime(type, out operation))
-            {
-                return operation.SideOfTime(TimeUtility.ServerNow, out side);
-            }
-            return false;
-        }
-
         public int GetOperationSurplusTime(Operation type)
         {
             OperationBase operation;
@@ -566,12 +400,42 @@
             return 0;
         }
 
+        public bool InOperationAdvance(Operation type)
+        {
+            OperationBase operation;
+            if (TryGetOperationTime(type, out operation))
+            {
+                return operation.InAdvanceTime(TimeUtility.ServerNow);
+            }
+            return false;
+        }
+
+        public int GetOperationSecondsBeforeStart(Operation type)
+        {
+            OperationBase operation;
+            if (TryGetOperationTime(type, out operation))
+            {
+                return operation.GetSecondsBeforeStart(TimeUtility.ServerNow);
+            }
+            return 0;
+        }
+
         public bool SatisfyOpenCondition(Operation type)
         {
             OperationBase operation;
             if (TryGetOperationTime(type, out operation))
             {
                 return operation.SatisfyOpenCondition() && InOperationTime(type);
+            }
+            return false;
+        }
+
+        public bool SatisfyAdvanceCondition(Operation type)
+        {
+            OperationBase operation;
+            if (TryGetOperationTime(type, out operation))
+            {
+                return operation.SatisfyOpenCondition() && InOperationAdvance(type);
             }
             return false;
         }
@@ -600,16 +464,6 @@
             }
         }
 
-        public int IndexOfOperationDays(Operation type)
-        {
-            OperationBase operation;
-            if (TryGetOperationTime(type, out operation))
-            {
-                return operation.IndexOfOpenDay(TimeUtility.ServerNow);
-            }
-            return -1;
-        }
-
         OperationDate ParseOperationDate(string date)
         {
             string[] dateArray = date.Split('-');
@@ -620,6 +474,24 @@
                     year = int.Parse(dateArray[0].Trim()),
                     month = int.Parse(dateArray[1].Trim()),
                     day = int.Parse(dateArray[2].Trim())
+                };
+            }
+            else if (dateArray != null && dateArray.Length == 1)
+            {
+                var time = TimeUtility.openServerTime;
+                if (time.Equals(default(DateTime)))
+                {
+                    DebugEx.Log("鏈嶅姟鏈熷紑鏈嶆椂闂翠笅鍙戦『搴忔湁闂");
+                }
+                var days = 0;
+                int.TryParse(date, out days);
+                days = Mathf.Max(1, days);
+                time = time.AddDays(days - 1);
+                return new OperationDate()
+                {
+                    year = time.Year,
+                    month = time.Month,
+                    day = time.Day,
                 };
             }
             return default(OperationDate);
@@ -644,51 +516,6 @@
         }
     }
 
-    public class OperationDateEnumerator : IEnumerable, IEnumerator
-    {
-        OperationDate start;
-        OperationDate end;
-
-        public int index = -1;
-
-        public OperationDateEnumerator(OperationDate _start,OperationDate _end)
-        {
-            this.start = _start;
-            this.end = _end;
-        }
-
-        public object Current
-        {
-            get
-            {
-                var date = start;
-                date.day += index;
-                return date;
-            }
-        }
-
-        public IEnumerator GetEnumerator()
-        {
-            return (IEnumerator)this;
-        }
-
-        public bool MoveNext()
-        {
-            index++;
-            bool isIn = index <= (start - end);
-            if (!isIn)
-            {
-                GetEnumerator().Reset();
-            }
-            return isIn;
-        }
-
-        public void Reset()
-        {
-            index = -1;
-        }
-    }
-
     public struct OperationDate
     {
         public int year;
@@ -705,10 +532,57 @@
             return !(x == y);
         }
 
+        public static bool operator >(OperationDate x, OperationDate y)
+        {
+            if (x.year > y.year)
+            {
+                return true;
+            }
+            if (x.year == y.year)
+            {
+                if (x.month > y.month)
+                {
+                    return true;
+                }
+                if (x.month == y.month)
+                {
+                    return x.day > y.day;
+                }
+            }
+            return false;
+        }
+
+        public static bool operator <(OperationDate x, OperationDate y)
+        {
+            return !(x > y) && x != y;
+        }
+
+        public static bool operator >=(OperationDate x, OperationDate y)
+        {
+            return x > y || x == y;
+        }
+
+        public static bool operator <=(OperationDate x, OperationDate y)
+        {
+            return x < y || x == y;
+        }
+
         public DateTime AddSeconds(int _seconds)
         {
             DateTime d = new DateTime(year, month, day);
             return d.AddTicks(_seconds * TimeSpan.TicksPerSecond);
+        }
+
+        public OperationDate AddDays(int _days)
+        {
+            DateTime d = new DateTime(year, month, day);
+            d = d.AddDays(_days);
+            return new OperationDate()
+            {
+                year = d.Year,
+                month = d.Month,
+                day = d.Day,
+            };
         }
 
         public string ToDisplay(bool showYear = true)
@@ -721,7 +595,7 @@
         {
             DateTime _x = new DateTime(x.year, x.month, x.day);
             DateTime _y = new DateTime(y.year, y.month, y.day);
-            return (int)(_y - _x).TotalDays;
+            return (int)(_x - _y).TotalDays;
         }
     }
 
@@ -735,18 +609,10 @@
 
         public bool InTime(DateTime time)
         {
-            if (time.Hour < startHour || (time.Hour == startHour && time.Minute < startMinute))
-            {
-                return false;
-            }
-            if (time.Hour > endHour || (time.Hour == endHour && time.Minute >= endMinute))
-            {
-                return false;
-            }
-            return true;
+            return CompareTime(time) == 0;
         }
 
-        public int SideOfTime(DateTime time)
+        public int CompareTime(DateTime time)
         {
             if (time.Hour < startHour || (time.Hour == startHour && time.Minute < startMinute))
             {
@@ -769,670 +635,6 @@
         {
             DateTime d = new DateTime(y.Year, y.Month, y.Day, x.endHour, x.endMinute, 0);
             return Mathf.Max(0, (int)(d - y).TotalSeconds);
-        }
-    }
-
-    public class OperationBase
-    {
-        public OperationDate startDate;
-        public OperationDate endDate;
-        public List<OperationTime> times = new List<OperationTime>();
-        public OperationDateEnumerator dateEnumerator;
-
-        public bool allDay = false;
-
-        public bool stepTimeNotify = false;
-        public bool stepDateNotify = false;
-
-        public bool inTimeNotify = false;
-        public bool inDateNotify = false;
-
-        public bool inAdvanceNotify = false;
-
-        public int inAdvanceSeconds = 0;
-
-        public int limitLv;
-
-        public bool InTime(DateTime time)
-        {
-            if (!InDay(time))
-            {
-                return false;
-            }
-            if (allDay)
-            {
-                return true;
-            }
-            for (int i = 0; i < times.Count; i++)
-            {
-                if (times[i].InTime(time))
-                {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-        public bool SideOfTime(DateTime time, out int side)
-        {
-            side = 0;
-            if (!InDay(time))
-            {
-                return false;
-            }
-            if (allDay)
-            {
-                side = 0;
-                return true;
-            }
-            for (int i = 0; i < times.Count; i++)
-            {
-                side = times[i].SideOfTime(time);
-            }
-            return true;
-        }
-
-        public bool InDay(DateTime time)
-        {
-            if (time.Year != startDate.year && time.Year != endDate.year)
-            {
-                return false;
-            }
-            if (startDate.year != endDate.year)
-            {
-                if (time.Year == startDate.year)
-                {
-                    if (time.Month < startDate.month)
-                    {
-                        return false;
-                    }
-                    else if (time.Month == startDate.month && time.Day < startDate.day)
-                    {
-                        return false;
-                    }
-                }
-                else if (time.Year == endDate.year)
-                {
-                    if (time.Month > endDate.month)
-                    {
-                        return false;
-                    }
-                    else if (time.Month == endDate.month && time.Day > endDate.day)
-                    {
-                        return false;
-                    }
-                }
-            }
-            else
-            {
-                if (time.Month < startDate.month || (time.Month == startDate.month && time.Day < startDate.day))
-                {
-                    return false;
-                }
-                if (time.Month > endDate.month || (time.Month == endDate.month && time.Day > endDate.day))
-                {
-                    return false;
-                }
-            }
-            return true;
-        }
-
-        public int IndexOfOpenDay(DateTime time)
-        {
-            if (!InDay(time))
-            {
-                return -1;
-            }
-            DateTime s = new DateTime(startDate.year, startDate.month, startDate.day);
-            return (time - s).Days;
-        }
-
-        public int IndexOfOpenTime(DateTime time)
-        {
-            if (!InTime(time))
-            {
-                return -1;
-            }
-            if (allDay)
-            {
-                return 0;
-            }
-            for (int i = 0; i < times.Count; i++)
-            {
-                if (times[i].InTime(time))
-                {
-                    return i;
-                }
-            }
-            return -1;
-        }
-
-        public bool InAdvanceTime(DateTime time)
-        {
-            if (InTime(time) || inAdvanceSeconds <= 0)
-            {
-                return false;
-            }
-            var seconds = 0;
-            if (TryGetInAdvanceSurplusSecond(time, out seconds))
-            {
-                return seconds < inAdvanceSeconds;
-            }
-            return false;
-        }
-
-        public bool TryGetInAdvanceSurplusSecond(DateTime time, out int seconds)
-        {
-            seconds = 0;
-            if (InTime(time))
-            {
-                return false;
-            }
-            if (allDay)
-            {
-                var startTime = new DateTime(startDate.year, startDate.month, startDate.day);
-                seconds = (int)(startTime - time).TotalSeconds;
-            }
-            else
-            {
-                if (dateEnumerator != null)
-                {
-                    foreach (OperationDate date in dateEnumerator)
-                    {
-                        for (int i = 0; i < times.Count; i++)
-                        {
-                            var startTime = new DateTime(date.year, date.month, date.day, times[i].startHour, times[i].startMinute, 0);
-                            seconds = (int)(startTime - time).TotalSeconds;
-                            if (seconds > 0)
-                            {
-                                break;
-                            }
-                        }
-                        if (seconds > 0)
-                        {
-                            dateEnumerator.Reset();
-                            break;
-                        }
-                    }
-                }
-            }
-            return seconds > 0;
-        }
-
-        public int GetSurplusTime(DateTime time)
-        {
-            var seconds = 0;
-            if (InTime(time))
-            {
-                if (allDay)
-                {
-                    seconds += (int)(endDate.AddSeconds(24 * 60 * 60) - time).TotalSeconds;
-                }
-                else
-                {
-                    for (int i = 0; i < times.Count; i++)
-                    {
-                        if (times[i].InTime(time))
-                        {
-                            seconds += times[i] - time;
-                            break;
-                        }
-                    }
-                }
-            }
-            return seconds;
-        }
-        public virtual string ToDisplayTime()
-        {
-            return string.Empty;
-        }
-
-        public virtual void Reset()
-        {
-            stepTimeNotify = false;
-            stepDateNotify = false;
-            inTimeNotify = false;
-            inDateNotify = false;
-            inAdvanceNotify = false;
-            allDay = false;
-            inAdvanceSeconds = 0;
-            limitLv = 0;
-            times.Clear();
-        }
-
-        public virtual bool SatisfyOpenCondition()
-        {
-            return PlayerDatas.Instance.baseData.LV >= limitLv;
-        }
-    }
-
-    public class OperationMultiExp : OperationBase
-    {
-        public int multiple;
-
-        public override string ToDisplayTime()
-        {
-            var textBuilder = OperationTimeHepler.textBuilder;
-            textBuilder.Length = 0;
-            if (allDay)
-            {
-                textBuilder.Append(Language.Get("OpenAllDay"));
-            }
-            else
-            {
-                if (startDate != endDate)
-                {
-                    textBuilder.Append(Language.Get("EveryDay"));
-                }
-                for (int i = 0, n = times.Count; i < n; i++)
-                {
-                    textBuilder.Append(times[i].ToString());
-                    if (i < n - 1)
-                    {
-                        textBuilder.Append("銆�");
-                    }
-                }
-            }
-            return textBuilder.ToString();
-        }
-
-        public override bool SatisfyOpenCondition()
-        {
-            return PlayerDatas.Instance.baseData.LV >= limitLv;
-        }
-
-        public string GetMultipleCHS()
-        {
-            if (multiple / 10000 == 2)
-            {
-                return Language.Get("Num_CHS_Double");
-            }
-            else
-            {
-                return Language.Get(StringUtility.Contact("Num_CHS_", multiple / 10000));
-            }
-        }
-    }
-
-    public class OperationFlashSale : OperationBase
-    {
-        public bool dayReset = false;
-
-        public List<FlashSale> flashShops = new List<FlashSale>();
-
-        public int IndexOfFlashShop()
-        {
-            if (flashShops.Count == 1)
-            {
-                return 0;
-            }
-            var _timeIndex = IndexOfOpenTime(TimeUtility.ServerNow);
-            if (_timeIndex == -1)
-            {
-                return -1;
-            }
-            return Mathf.Min(flashShops.Count - 1, allDay ? 0 : _timeIndex);
-        }
-
-        public FlashSaleGift GetFlashSaleGift(int _index, int _id)
-        {
-            if (_index < flashShops.Count)
-            {
-                for (int i = 0; i < flashShops[_index].gifts.Length; i++)
-                {
-                    if (flashShops[_index].gifts[i].id == _id)
-                    {
-                        return flashShops[_index].gifts[i];
-                    }
-                }
-            }
-            return default(FlashSaleGift);
-        }
-
-        public override bool SatisfyOpenCondition()
-        {
-            return PlayerDatas.Instance.baseData.LV >= limitLv;
-        }
-
-        public override void Reset()
-        {
-            base.Reset();
-            flashShops.Clear();
-        }
-
-        public override string ToDisplayTime()
-        {
-            var textBuilder = OperationTimeHepler.textBuilder;
-            textBuilder.Length = 0;
-            textBuilder.Append(startDate.ToDisplay());
-            if (startDate != endDate)
-            {
-                textBuilder.Append("鈥�");
-                textBuilder.Append(endDate.ToDisplay());
-            }
-            return textBuilder.ToString();
-        }
-
-        public int GetSurplusTime(int index)
-        {
-            if (!InTime(TimeUtility.ServerNow))
-            {
-                return 0;
-            }
-            var seconds = 0;
-            if (times.Count == 0)
-            {
-                DateTime endOperationTime = new DateTime(TimeUtility.Year, TimeUtility.Month,
-                        TimeUtility.Day, 0, 0, 0);
-                endOperationTime = endOperationTime.AddDays(1);
-                seconds = (int)(endOperationTime - TimeUtility.ServerNow).TotalSeconds;
-            }
-            if (index >= 0 && index < times.Count)
-            {
-                var _endTime = times[index];
-                DateTime endOperationTime = new DateTime(TimeUtility.Year, TimeUtility.Month,
-                        TimeUtility.Day, _endTime.endHour, _endTime.endMinute, 0);
-                seconds = (int)(endOperationTime - TimeUtility.ServerNow).TotalSeconds;
-            }
-            return seconds;
-        }
-
-        public struct FlashSale
-        {
-            public FlashSaleGift[] gifts;
-        }
-
-        public struct FlashSaleGift
-        {
-            public int id;
-            public int limitNum;
-            public int moneyType;
-            public int moneyNumber;
-            public int moneyOriginal;
-            public FlashSaleItem[] items;
-        }
-
-        public struct FlashSaleItem
-        {
-            public int itemId;
-            public int itemCount;
-            public int isBind;
-            public bool isMainItem;
-        }
-    }
-
-
-    public class GiftPackageClass : OperationBase
-    {
-        public bool dayReset = false;
-
-        public List<Gift_Package> giftpackage1 = new List<Gift_Package>();
-
-        public int IndexOfFlashShop()
-        {
-            if (giftpackage1.Count == 1)
-            {
-                return 0;
-            }
-            var _timeIndex = IndexOfOpenTime(TimeUtility.ServerNow);
-            if (_timeIndex == -1)
-            {
-                return -1;
-            }
-            return Mathf.Min(giftpackage1.Count - 1, allDay ? 0 : _timeIndex);
-        }
-
-        public GiftPackageGift GetFlashSaleGift(int _index, int _id)
-        {
-            if (_index < giftpackage1.Count)
-            {
-                for (int i = 0; i < giftpackage1[_index].gifts.Length; i++)
-                {
-                    if (giftpackage1[_index].gifts[i].id == _id)
-                    {
-                        return giftpackage1[_index].gifts[i];
-                    }
-                }
-            }
-            return default(GiftPackageGift);
-        }
-
-        public override bool SatisfyOpenCondition()
-        {
-            return PlayerDatas.Instance.baseData.LV >= limitLv;
-        }
-
-        public override void Reset()
-        {
-            base.Reset();
-            giftpackage1.Clear();
-        }
-
-        public override string ToDisplayTime()
-        {
-            var textBuilder = OperationTimeHepler.textBuilder;
-            textBuilder.Length = 0;
-            textBuilder.Append(startDate.ToDisplay());
-            if (startDate != endDate)
-            {
-                textBuilder.Append("鈥�");
-                textBuilder.Append(endDate.ToDisplay());
-            }
-            return textBuilder.ToString();
-        }
-
-        public struct Gift_Package
-        {
-            public GiftPackageGift[] gifts;
-        }
-
-        public struct GiftPackageGift
-        {
-            public int id;
-            public int limitNum;//闄愯喘鏁�
-            public int rmb;//浜烘皯甯�
-            public int rmbOriginal;//鍘熶环
-            public string OrderInfo;//鍟嗗搧缂栧彿
-            public int OrderInfoLength;//闀垮害
-            public GiftPackageItem[] items;
-        }
-
-        public struct GiftPackageItem
-        {
-            public int itemId;
-            public int itemCount;
-            public int isBind;
-            public bool isMainItem;
-        }
-    }
-
-    public class OperationConsumeRebate : OperationBase
-    {
-        public bool dayReset = false;
-
-        public List<Rebate> rebates = new List<Rebate>();
-        public override bool SatisfyOpenCondition()
-        {
-            return PlayerDatas.Instance.baseData.LV >= limitLv;
-        }
-
-        public override string ToDisplayTime()
-        {
-            var textBuilder = OperationTimeHepler.textBuilder;
-            textBuilder.Length = 0;
-            textBuilder.Append(startDate.ToDisplay());
-            if (startDate != endDate)
-            {
-                textBuilder.Append("鈥�");
-                textBuilder.Append(endDate.ToDisplay());
-            }
-            return textBuilder.ToString();
-        }
-
-        public override void Reset()
-        {
-            base.Reset();
-            rebates.Clear();
-        }
-
-        public Rebate GetRebate(DateTime time)
-        {
-            if (rebates.Count == 0)
-            {
-                return null;
-            }
-            var index = IndexOfOpenDay(time);
-            if (index != -1 && index < rebates.Count)
-            {
-                return rebates[index];
-            }
-            return rebates[rebates.Count - 1];
-        }
-
-        public class Rebate
-        {
-            public List<RebateGrade> rebateGrades = new List<RebateGrade>();
-        }
-
-        public class RebateGrade
-        {
-            public int needGold;
-            public int index;//濂栧姳绱㈠紩
-            public List<Item> items = new List<Item>();
-        }
-
-        public struct Item
-        {
-            public int itemId;
-            public int count;
-            public int isBind;
-        }
-    }
-
-    public class OperationBossReborn : OperationBase
-    {
-        public override bool SatisfyOpenCondition()
-        {
-            return PlayerDatas.Instance.baseData.LV >= limitLv;
-        }
-    }
-
-    public class OperationMultipleRealmPoint : OperationBase
-    {
-        public int multiplePractice; //鍊嶆暟
-        public int startHour = 5;
-        public int startMinute = 0;
-        public int startSecond = 0;
-        public override bool SatisfyOpenCondition()
-        {
-            return PlayerDatas.Instance.baseData.LV >= limitLv;
-        }
-
-        public  bool InActiveTime(DateTime time)
-        {
-            if (time.Year != startDate.year && time.Year != endDate.year)
-            {
-                return false;
-            }
-
-            if (startDate.year != endDate.year)
-            {
-                if (time.Year == startDate.year)
-                {
-                    if (time.Month < startDate.month)
-                    {
-                        return false;
-                    }
-                    else if (time.Month == startDate.month && time.Day < startDate.day)
-                    {
-                        return false;
-                    }
-                    else if(time.Month == startDate.month
-                        && time.Day == startDate.day
-                        && time.Hour < startHour)
-                    {
-                        return false;
-                    }
-                    else if (time.Month == startDate.month
-                       && time.Day == startDate.day
-                       && time.Hour == startHour
-                       && time.Minute < startMinute)
-                    {
-                        return false;
-                    }
-                    else if (time.Month == startDate.month
-                      && time.Day == startDate.day
-                      && time.Hour == startHour
-                      && time.Minute == startMinute
-                        && time.Second < startSecond)
-                    {
-                        return false;
-                    }
-                }
-                else if (time.Year == endDate.year)
-                {
-                    if (time.Month > endDate.month)
-                    {
-                        return false;
-                    }
-                    else if (time.Month == endDate.month && time.Day > endDate.day)
-                    {
-                        return false;
-                    }
-                    else if(time.Month == endDate.month 
-                        && time.Day == endDate.day
-                        && time.Hour > startHour)
-                    {
-                        return false;
-                    }
-                    else if (time.Month == endDate.month
-                       && time.Day == endDate.day
-                       && time.Hour == startHour
-                       && time.Minute > startMinute)
-                    {
-                        return false;
-                    }
-                    else if (time.Month == endDate.month
-                      && time.Day == endDate.day
-                      && time.Hour == startHour
-                      && time.Minute == startMinute
-                        && time.Second > startSecond)
-                    {
-                        return false;
-                    }
-                }
-            }
-            else
-            {
-                if (time.Month < startDate.month 
-                    || (time.Month == startDate.month && time.Day < startDate.day)
-                    || (time.Month == startDate.month && time.Day == startDate.day && time.Hour < startHour)
-                    || (time.Month == startDate.month && time.Day == startDate.day && time.Hour == startHour && time.Minute < startMinute)
-                    || (time.Month == startDate.month && time.Day == startDate.day && time.Hour == startHour && time.Minute == startMinute) && time.Second < startSecond)
-                {
-                    return false;
-                }
-                if (time.Month > endDate.month 
-                    || (time.Month == endDate.month && time.Day > endDate.day)
-                    || (time.Month == endDate.month && time.Day == endDate.day && time.Hour > startHour)
-                     || (time.Month == endDate.month && time.Day == endDate.day && time.Hour == startHour && time.Minute > startMinute)
-                    || (time.Month == endDate.month && time.Day == endDate.day && time.Hour == startHour && time.Minute == startMinute) && time.Second > startSecond)
-                {
-                    return false;
-                }
-            }
-            return true;
-        }
-
-        public int GetRemainTime(DateTime time)
-        {
-            var seconds = 0;
-            if (InActiveTime(time))
-            {
-                DateTime endTime = new DateTime(endDate.year, endDate.month, endDate.day, startHour, 0, 0);
-                seconds = (int)(endTime - time).TotalSeconds;
-            }
-            return seconds;
         }
     }
 

--
Gitblit v1.8.0