少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Text.RegularExpressions;
using vnxbqy.UI;
 
using LitJson;
 
public class DailyQuestData
{
    public int id { get; private set; }
    public Redpoint redpoint { get; private set; }
 
    public DailyQuestData(int _id)
    {
        this.id = _id;
    }
 
    public DailyQuestData(int _id, int _redpointId, int _parentRedpoint)
    {
        this.id = _id;
        this.redpoint = new Redpoint(_parentRedpoint, _redpointId);
    }
 
    public void UpdateRedpointState(RedPointState _redpointState)
    {
        if (this.redpoint != null)
        {
            this.redpoint.state = _redpointState;
        }
    }
 
}
 
public class DailyQuestActiveValueReward
{
    public int id { get; private set; }
 
    bool m_Got = false;
    public bool got {
        get { return this.m_Got; }
        set { this.m_Got = value; }
    }
 
    public DailyQuestActiveValueReward(int _id)
    {
        this.id = _id;
    }
}
 
public struct DailyQuestTimes
{
    public int completeTimes;
    public int dayBuyTimes;
    public int dayUseItemTimes;
}
 
public class DailyQuestOpenTime
{
    public int id;
    public bool always;
 
    //常规的活动时间,key是星期x
    Dictionary<int, List<HourMinute>> openTimes = new Dictionary<int, List<HourMinute>>();
    public Dictionary<int, List<HourMinute>> NormalOpenTimes { get { return openTimes; } }
    //开服前2周的活动时间,key1是开服日的星期,key2是开服第几天
    Dictionary<int, Dictionary<int, List<HourMinute>>> specialOpenTimes = new Dictionary<int, Dictionary<int, List<HourMinute>>>();
    //合服之后的活动时间,key是第几天
    Dictionary<int, List<HourMinute>> mixServerOpenTimes = new Dictionary<int, List<HourMinute>>();
 
    public DailyQuestOpenTime(int _id)
    {
        this.id = _id;
    }
 
    public void ParseQuestNormalOpenTime(DailyQuestOpenTimeConfig activityOpenTime)
    {
        string timeString = activityOpenTime.OpenTime;
        int duration = activityOpenTime.Duration;
        var matches = Regex.Matches(timeString, "\\\"[0-9]\\\":\\[[0-9|,|\\[|\\]]+");
        always = matches.Count == 0;
 
        for (int i = 0; i < matches.Count; i++)
        {
            var match = matches[i];
            var stringArray = match.Value.Split(':');
 
            var week = 0;
            var weekMatch = Regex.Match(stringArray[0], "[0-9]");
            int.TryParse(weekMatch.Value, out week);
 
            if (week == 0)
            {
                var subMatches = Regex.Matches(stringArray[1], "[0-9]{1,2},[0-9]{1,2}");
                var tempHourMinutes = new List<HourMinute>();
 
                for (int j = 0; j < subMatches.Count; j++)
                {
                    tempHourMinutes.Add(new HourMinute(subMatches[j].Value, duration));
                }
 
                tempHourMinutes.Sort((HourMinute a, HourMinute b) => { return HourMinute.Compare(a, b); });
 
                for (int j = 0; j < 7; j++)
                {
                    var hourMinutes = openTimes[j] = new List<HourMinute>(tempHourMinutes);
                }
            }
            else
            {
                var hourMinutes = openTimes[week % 7] = new List<HourMinute>();
                var subMatches = Regex.Matches(stringArray[1], "[0-9]{1,2},[0-9]{1,2}");
 
                for (int j = 0; j < subMatches.Count; j++)
                {
                    hourMinutes.Add(new HourMinute(subMatches[j].Value, duration));
                }
 
                hourMinutes.Sort((HourMinute a, HourMinute b) => { return HourMinute.Compare(a, b); });
            }
        }
    }
 
    public void ParseQuestSpecialOpenTimes(List<DailyQuestSpecialOpenTimeConfig> configs)
    {
        if (configs == null)
        {
            return;
        }
 
        foreach (var config in configs)
        {
            var openDayWeek = config.OpenServerWeek % 7;
            if (!specialOpenTimes.ContainsKey(openDayWeek))
            {
                specialOpenTimes[openDayWeek] = new Dictionary<int, List<HourMinute>>();
            }
 
            var dayIndexOpenTimes = specialOpenTimes[openDayWeek];
            var dayIndex = config.OpenServerDay;
            if (!dayIndexOpenTimes.ContainsKey(dayIndex))
            {
                dayIndexOpenTimes[dayIndex] = new List<HourMinute>();
            }
 
            var matches = Regex.Matches(config.TimeList, "\\[[0-9]{1,2},[0-9]{1,2}\\]");
            var hourMinutes = dayIndexOpenTimes[dayIndex];
 
            for (int i = 0; i < matches.Count; i++)
            {
                var temp = matches[i].Value;
                hourMinutes.Add(new HourMinute(temp, config.Duration));
            }
        }
    }
 
    public void ParseQuestMixServerOpenTime(List<DailyQuestMixServerStateTimeConfig> configs)
    {
        if (configs == null)
        {
            return;
        }
 
        foreach (var config in configs)
        {
            var timeString = config.TimeList;
            var duration = config.Duration;
 
            List<HourMinute> hourMinutes = null;
            if (mixServerOpenTimes.ContainsKey(config.MixServerDay))
            {
                hourMinutes = mixServerOpenTimes[config.MixServerDay];
            }
            else
            {
                hourMinutes = mixServerOpenTimes[config.MixServerDay] = new List<HourMinute>();
            }
 
            var matches = Regex.Matches(timeString, "[0-9]{1,2},[0-9]{1,2}");
            for (var i = 0; i < matches.Count; i++)
            {
                hourMinutes.Add(new HourMinute(matches[i].Value, duration));
            }
 
        }
    }
 
    public void ParseDungeonNormalOpenTimes(List<DungeonStateTimeConfig> configs)
    {
        always = configs == null || configs.Count == 0;
 
        if (!always)
        {
            for (int i = 0; i < configs.Count; i++)
            {
                var config = configs[i];
                if (config.CanEnter == 0)
                {
                    continue;
                }
 
                if (config.StartWeekday == 0 && config.EndWeekday == 0)
                {
                    for (int j = 0; j < 7; j++)
                    {
                        if (!openTimes.ContainsKey(j))
                        {
                            openTimes[j] = new List<HourMinute>();
                        }
                        var hourMinutes = openTimes[j];
                        hourMinutes.Add(new HourMinute(config.StartHour, config.StartMinute, config.EndHour, config.EndMinute));
                    }
                }
                else
                {
                    var dayOfWeek = config.StartWeekday % 7;
                    if (!openTimes.ContainsKey(dayOfWeek))
                    {
                        openTimes[dayOfWeek] = new List<HourMinute>();
                    }
 
                    var hourMinutes = openTimes[dayOfWeek];
                    hourMinutes.Add(new HourMinute(config.StartHour, config.StartMinute, config.EndHour, config.EndMinute));
                }
            }
        }
    }
 
    public void ParseDungeonSpecialOpenTimes(List<DungeonSpecialStateTimeConfig> configs)
    {
        if (configs == null)
        {
            return;
        }
 
        foreach (var config in configs)
        {
            if (config.CanEnter == 0)
            {
                continue;
            }
 
            var openDayWeek = config.OpenServerWeek % 7;
            if (!specialOpenTimes.ContainsKey(openDayWeek))
            {
                specialOpenTimes[openDayWeek] = new Dictionary<int, List<HourMinute>>();
            }
 
            var dayIndexOpenTimes = specialOpenTimes[openDayWeek];
            var dayIndex = config.OpenServerDay;
            if (!dayIndexOpenTimes.ContainsKey(dayIndex))
            {
                dayIndexOpenTimes[dayIndex] = new List<HourMinute>();
            }
 
            var hourMinutes = dayIndexOpenTimes[dayIndex];
            hourMinutes.Add(new HourMinute(config.StartHour, config.StartMinute, config.EndHour, config.EndMinute));
 
        }
    }
 
    public void ParseDungeonMixServerOpenTimes(List<DungeonMixServerStateTimeConfig> configs)
    {
        if (configs == null)
        {
            return;
        }
 
        foreach (var config in configs)
        {
            if (config.CanEnter == 0)
            {
                continue;
            }
 
            List<HourMinute> hourMinutes = null;
            if (mixServerOpenTimes.ContainsKey(config.MixServerDay))
            {
                hourMinutes = mixServerOpenTimes[config.MixServerDay];
            }
            else
            {
                hourMinutes = mixServerOpenTimes[config.MixServerDay] = new List<HourMinute>();
            }
 
            hourMinutes.Add(new HourMinute(config.StartHour, config.StartMinute, config.EndHour, config.EndMinute));
        }
 
    }
 
    public bool IsValidServerOpenTime()
    {
        return true;
    }
 
 
 
    // 改成判断日常活动ID不在定制中配置则定制期间正常开启
    public bool InOpenTime()
    {
        if (always)
        {
            return true;
        }
 
        var isMixServer = TimeUtility.IsMixServer && TimeUtility.MixOpenDay < GeneralDefine.mixServerCustomDays;
        if (isMixServer && mixServerOpenTimes.Count > 0)
        {
            var dayIndex = TimeUtility.MixOpenDay + 1;
            if (!mixServerOpenTimes.ContainsKey(dayIndex))
            {
                return false;
            }
            else
            {
                var hourMinutes = mixServerOpenTimes[dayIndex];
                foreach (var item in hourMinutes)
                {
                    if (item.InOpenTime())
                    {
                        return true;
                    }
                }
 
                return false;
            }
        }
        else
        {
            var isSpecialDay = TimeUtility.OpenDay < 7 && (DailyQuestType)id != DailyQuestType.CrossServerPk 
                && (DailyQuestType)id != DailyQuestType.default4;
            var openDayWeek = (int)TimeUtility.openServerDayOfWeek;
            var dayIndex = TimeUtility.OpenDay + 1;
            if (isSpecialDay && specialOpenTimes.Count > 0)
            {
                if (specialOpenTimes.ContainsKey(openDayWeek) && specialOpenTimes[openDayWeek].ContainsKey(dayIndex))
                {
                    var hourMinutes = specialOpenTimes[openDayWeek][dayIndex];
                    for (int i = 0; i < hourMinutes.Count; i++)
                    {
                        if (hourMinutes[i].InOpenTime())
                        {
                            return true;
                        }
                    }
 
                    return false;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return IsNormalOpenTime();
            }
        }
 
    }
 
    //日常活动开启判断
    private bool IsNormalOpenTime()
    {
        var dayOfWeek = (int)TimeUtility.ServerNow.DayOfWeek;
        if (!openTimes.ContainsKey(dayOfWeek))
        {
            return false;
        }
        else
        {
            var hourMinutes = openTimes[dayOfWeek];
            for (int i = 0; i < hourMinutes.Count; i++)
            {
                if (hourMinutes[i].InOpenTime())
                {
                    return true;
                }
            }
 
            return false;
        }
    }
 
 
    public bool TryGetTodayNearestOpenTime(out HourMinute _hourMinute)
    {
        var isMixServer = TimeUtility.IsMixServer && TimeUtility.MixOpenDay < GeneralDefine.mixServerCustomDays;
        if (isMixServer && mixServerOpenTimes.Count > 0)
        {
            var dayIndex = TimeUtility.MixOpenDay + 1;
            if (!mixServerOpenTimes.ContainsKey(dayIndex))
            {
                _hourMinute = default(HourMinute);
                return false;
            }
            else
            {
                var hour = TimeUtility.ServerNow.Hour;
                var minute = TimeUtility.ServerNow.Minute;
                var hourMinutes = mixServerOpenTimes[dayIndex];
                _hourMinute = hourMinutes[hourMinutes.Count - 1];
                foreach (var hourMinute in hourMinutes)
                {
                    if (hour < hourMinute.hourEnd || (hour == hourMinute.hourEnd && minute <= hourMinute.minuteEnd))
                    {
                        _hourMinute = hourMinute;
                        break;
                    }
                }
 
                return true;
            }
        }
        else
        {
            var isSpecialDay = TimeUtility.OpenDay < 7 && (DailyQuestType)id != DailyQuestType.CrossServerPk
                && (DailyQuestType)id != DailyQuestType.default4;
            var openDayWeek = (int)TimeUtility.openServerDayOfWeek;
            var dayIndex = TimeUtility.OpenDay + 1;
            if (isSpecialDay && specialOpenTimes.Count > 0)
            {
                if (specialOpenTimes.ContainsKey(openDayWeek) && specialOpenTimes[openDayWeek].ContainsKey(dayIndex))
                {
                    var hour = TimeUtility.ServerNow.Hour;
                    var minute = TimeUtility.ServerNow.Minute;
                    var hourMinutes = specialOpenTimes[openDayWeek][dayIndex];
                    _hourMinute = hourMinutes[hourMinutes.Count - 1];
                    for (int i = 0; i < hourMinutes.Count; i++)
                    {
                        var hourMinute = hourMinutes[i];
                        if (hour < hourMinute.hourEnd || (hour == hourMinute.hourEnd && minute <= hourMinute.minuteEnd))
                        {
                            _hourMinute = hourMinute;
                            break;
                        }
                    }
 
                    return true;
                }
                else
                {
                    _hourMinute = default(HourMinute);
                    return false;
                }
            }
            else
            {
                var dayOfWeek = (int)TimeUtility.ServerNow.DayOfWeek;
                if (!openTimes.ContainsKey(dayOfWeek))
                {
                    _hourMinute = default(HourMinute);
                    return false;
                }
 
                var hour = TimeUtility.ServerNow.Hour;
                var minute = TimeUtility.ServerNow.Minute;
                var hourMinutes = openTimes[dayOfWeek];
                _hourMinute = hourMinutes[hourMinutes.Count - 1];
                for (int i = 0; i < hourMinutes.Count; i++)
                {
                    var hourMinute = hourMinutes[i];
                    if (hour < hourMinute.hourEnd || (hour == hourMinute.hourEnd && minute <= hourMinute.minuteEnd))
                    {
                        _hourMinute = hourMinute;
                        break;
                    }
                }
 
                return true;
            }
        }
 
    }
 
    public bool TryGetNextOpenTime(out HourMinute _hourMinute)
    {
        _hourMinute = default(HourMinute);
 
        var openDayWeek = (int)TimeUtility.openServerDayOfWeek;
        var dayIndex = TimeUtility.OpenDay + 1;
        var maxSpecialDays = GeneralDefine.mixServerCustomDays + 1 - (openDayWeek == 0 ? 7 : openDayWeek);
        var hour = TimeUtility.ServerNow.Hour;
        var minute = TimeUtility.ServerNow.Minute;
        var mixDayIndex = 0;
        for (int i = 0; i <= 7; i++)//一周内必须有活动
        {
            List<HourMinute> hourminutes = null;
            var days = dayIndex + i;
            if (mixServerOpenTimes.Count > 0 && IsInMixServerCustomDay(days, out mixDayIndex))
            {
                if (!mixServerOpenTimes.ContainsKey(mixDayIndex))
                {
                    continue;
                }
                hourminutes = mixServerOpenTimes[mixDayIndex];
            }
            else if (specialOpenTimes.Count > 0 && days <= maxSpecialDays)
            {
                if (!specialOpenTimes.ContainsKey(openDayWeek)
                || !specialOpenTimes[openDayWeek].ContainsKey(days))
                {
                    continue;
                }
                hourminutes = specialOpenTimes[openDayWeek][days];
            }
            else
            {
                var dayOfWeek = (int)TimeUtility.ServerNow.AddTicks(i * TimeSpan.TicksPerDay).DayOfWeek;
                if (!openTimes.ContainsKey(dayOfWeek))
                {
                    continue;
                }
                hourminutes = openTimes[dayOfWeek];
            }
            if (hourminutes != null)
            {
                foreach (var hourMinute in hourminutes)
                {
                    if (days == dayIndex && hourMinute.AfterOpenTime(hour, minute))
                    {
                        continue;
                    }
                    _hourMinute = hourMinute;
                    return true;
                }
            }
        }
        return false;
    }
 
    bool IsInMixServerCustomDay(int day, out int index)
    {
        index = -1;
 
        if (!TimeUtility.IsMixServer)
        {
            return false;
        }
 
        var openServerDate = TimeUtility.ServerNow.AddTicks(-TimeUtility.OpenDay * TimeSpan.TicksPerDay);
        openServerDate = new DateTime(openServerDate.Year, openServerDate.Month, openServerDate.Day);
 
        var mixServerOpenDate = TimeUtility.ServerNow.AddTicks(-TimeUtility.MixOpenDay * TimeSpan.TicksPerDay);
        mixServerOpenDate = new DateTime(mixServerOpenDate.Year, mixServerOpenDate.Month, mixServerOpenDate.Day);
 
        var offset = (int)(mixServerOpenDate - openServerDate).TotalDays;
        index = day - offset;
        return index <= GeneralDefine.mixServerCustomDays;
    }
 
    public int GetNextSessionSurplusTime()
    {
        if (InOpenTime())
        {
            return 0;
        }
        var openDayWeek = (int)TimeUtility.openServerDayOfWeek;
        var dayIndex = TimeUtility.OpenDay + 1;
        var maxSpecialDays = GeneralDefine.mixServerCustomDays + 1 - (openDayWeek == 0 ? 7 : openDayWeek);
        var hour = TimeUtility.ServerNow.Hour;
        var minute = TimeUtility.ServerNow.Minute;
        var mixDayIndex = 0;
        for (int i = 0; i <= 7; i++)//一周内必须有活动
        {
            List<HourMinute> hourminutes = null;
            var days = dayIndex + i;
            if (mixServerOpenTimes.Count > 0 && IsInMixServerCustomDay(days, out mixDayIndex))
            {
                if (!mixServerOpenTimes.ContainsKey(mixDayIndex))
                {
                    continue;
                }
                hourminutes = mixServerOpenTimes[mixDayIndex];
            }
            else if (specialOpenTimes.Count > 0 && days <= maxSpecialDays)
            {
                if (!specialOpenTimes.ContainsKey(openDayWeek)
                || !specialOpenTimes[openDayWeek].ContainsKey(days))
                {
                    continue;
                }
                hourminutes = specialOpenTimes[openDayWeek][days];
            }
            else
            {
                var dayOfWeek = (int)TimeUtility.ServerNow.AddTicks(i * TimeSpan.TicksPerDay).DayOfWeek;
                if (!openTimes.ContainsKey(dayOfWeek))
                {
                    continue;
                }
                hourminutes = openTimes[dayOfWeek];
            }
            if (hourminutes != null)
            {
                foreach (var hourMinute in hourminutes)
                {
                    if (days == dayIndex && hourMinute.AfterOpenTime(hour, minute))
                    {
                        continue;
                    }
                    var time = TimeUtility.ServerNow.AddTicks(i * TimeSpan.TicksPerDay);
                    time = new DateTime(time.Year, time.Month, time.Day, hourMinute.hourBegin, hourMinute.minuteBegin, 0);
                    var seconds = (int)(time - TimeUtility.ServerNow).TotalSeconds;
                    return Mathf.Max(0, seconds);
                }
            }
        }
        return 0;
    }
 
    public int PassSessionCount(DateTime beginTime)
    {
        var openDayWeek = (int)TimeUtility.openServerDayOfWeek;
        var dayIndex = TimeUtility.OpenDay + 1;
        var maxSpecialDays = GeneralDefine.mixServerCustomDays + 1 - (openDayWeek == 0 ? 7 : openDayWeek);
        var beginHour = beginTime.Hour;
        var beginMinute = beginTime.Minute;
        var session = 0;
        var mixDayIndex = 0;
 
        var openServerDay = TimeUtility.ServerNow.AddTicks(-TimeUtility.OpenDay * TimeSpan.TicksPerDay);
        openServerDay = new DateTime(openServerDay.Year, openServerDay.Month, openServerDay.Day);
        var beginDay = (int)(beginTime - openServerDay).TotalDays + 1;
        List<HourMinute> hourMinutes = null;
 
        if (mixServerOpenTimes.Count > 0 && IsInMixServerCustomDay(beginDay, out mixDayIndex))
        {
            if (mixServerOpenTimes.ContainsKey(mixDayIndex))
            {
                hourMinutes = mixServerOpenTimes[mixDayIndex];
            }
        }
        else if (specialOpenTimes.Count > 0 && beginDay <= maxSpecialDays)
        {
            if (specialOpenTimes.ContainsKey(openDayWeek) && specialOpenTimes[openDayWeek].ContainsKey(beginDay))
            {
                hourMinutes = specialOpenTimes[openDayWeek][beginDay];
            }
        }
        else
        {
            var dayOfWeek = (int)beginTime.DayOfWeek;
            if (openTimes.ContainsKey(dayOfWeek))
            {
                hourMinutes = openTimes[dayOfWeek];
            }
        }
        if (hourMinutes != null)
        {
            var hourMinute = hourMinutes[hourMinutes.Count - 1];
            if (hourMinute.AfterOpenTime(beginHour, beginMinute))
            {
                beginDay++;
            }
        }
 
        var nowHour = TimeUtility.ServerNow.Hour;
        var nowMinute = TimeUtility.ServerNow.Minute;
        for (int i = beginDay; i <= dayIndex; i++)
        {
            hourMinutes = null;
            if (mixServerOpenTimes.Count > 0 && IsInMixServerCustomDay(i, out mixDayIndex))
            {
                if (mixServerOpenTimes.ContainsKey(mixDayIndex))
                {
                    hourMinutes = mixServerOpenTimes[mixDayIndex];
                }
            }
            else if (specialOpenTimes.Count > 0 && i <= maxSpecialDays)
            {
                if (specialOpenTimes.ContainsKey(openDayWeek) && specialOpenTimes[openDayWeek].ContainsKey(i))
                {
                    hourMinutes = specialOpenTimes[openDayWeek][i];
                }
            }
            else
            {
                var dayOfWeek = (int)openServerDay.AddTicks((i - 1) * TimeSpan.TicksPerDay).DayOfWeek;
                if (openTimes.ContainsKey(dayOfWeek))
                {
                    hourMinutes = openTimes[dayOfWeek];
                }
            }
            if (hourMinutes != null)
            {
                if (i < dayIndex)
                {
                    session += hourMinutes.Count;
                }
                else if (i == dayIndex)
                {
                    foreach (var hourMinute in hourMinutes)
                    {
                        if (hourMinute.AfterOpenTime(nowHour, nowMinute))
                        {
                            session++;
                        }
                    }
                }
            }
        }
        return session;
    }
 
    public bool ContainTimeNode(int week, int timeNode)
    {
        if ((DailyQuestType)id == DailyQuestType.CrossServerPk)
        {
            return false;
        }
 
        List<HourMinute> hourMinutes = null;
 
        var isMixServer = TimeUtility.IsMixServer && TimeUtility.MixOpenDay < GeneralDefine.mixServerCustomDays;
        if (isMixServer && mixServerOpenTimes.Count > 0)
        {
            week = week == 0 ? 7 : week;
            var todayWeek = (int)TimeUtility.ServerNow.DayOfWeek;
            todayWeek = todayWeek == 0 ? 7 : todayWeek;
            var targetMixOpenDay = week - todayWeek + TimeUtility.MixOpenDay;
            if (mixServerOpenTimes.Count > 0 && targetMixOpenDay >= 0 && targetMixOpenDay < GeneralDefine.mixServerCustomDays)
            {
                mixServerOpenTimes.TryGetValue(targetMixOpenDay + 1, out hourMinutes);
            }
            else
            {
                openTimes.TryGetValue(week, out hourMinutes);
            }
        }
        else
        {
            var openDayWeek = (int)TimeUtility.openServerDayOfWeek;
            var dayDelta = (week == 0 ? 7 : week) - (openDayWeek == 0 ? 7 : openDayWeek);
            if (TimeUtility.OpenWeekCnt < 1 && dayDelta < 0)
            {
                //openTimes.TryGetValue(week, out hourMinutes);
 
                if (specialOpenTimes.Count == 0)
                    openTimes.TryGetValue(week, out hourMinutes);
            }
            else
            {
                hourMinutes = GetHourMinuteByWeek(week);
            }
        }
 
        if (hourMinutes != null)
        {
            foreach (var item in hourMinutes)
            {
                if (item.hourBegin * 60 + item.minuteBegin == timeNode)
                {
                    return true;
                }
            }
        }
 
        return false;
    }
 
    private bool ContainWeek(int week)
    {
        week = week == 0 ? 7 : week;
        var todayWeek = (int)TimeUtility.ServerNow.DayOfWeek;
        todayWeek = todayWeek == 0 ? 7 : todayWeek;
        var isMixServer = TimeUtility.IsMixServer && TimeUtility.MixOpenDay < GeneralDefine.mixServerCustomDays;
        if (isMixServer && mixServerOpenTimes.Count > 0)
        {
            var targetMixOpenDay = week - todayWeek + TimeUtility.MixOpenDay;
            return mixServerOpenTimes.ContainsKey(targetMixOpenDay + 1);
        }
        else
        {
            var openDayWeek = (int)TimeUtility.openServerDayOfWeek;
            var dayDelta = (week == 0 ? 7 : week) - (openDayWeek == 0 ? 7 : openDayWeek);
            if (TimeUtility.OpenWeekCnt < 1 && dayDelta < 0)
            {
                if (specialOpenTimes.Count > 0)
                    return false;
                else
                    return openTimes.ContainsKey(week);
            }
            else
            {
                return GetHourMinuteByWeek(week) != null;
            }
        }
    }
 
    public string ToOpenTimeString()
    {
        if (always || openTimes.Count >= 7)
        {
            return Language.Get("DailyQuest_NoTimeLimit");
        }
        else
        {
            var timeStringList = new List<string>();
            for (var i = 1; i <= 7; i++)
            {
                var week = i % 7;
                if (ContainWeek(week))
                {
                    switch (week)
                    {
                        case 0:
                            timeStringList.Add(Language.Get("Weekday7"));
                            break;
                        case 1:
                            timeStringList.Add(Language.Get("Weekday1"));
                            break;
                        case 2:
                            timeStringList.Add(Language.Get("Weekday2"));
                            break;
                        case 3:
                            timeStringList.Add(Language.Get("Weekday3"));
                            break;
                        case 4:
                            timeStringList.Add(Language.Get("Weekday4"));
                            break;
                        case 5:
                            timeStringList.Add(Language.Get("Weekday5"));
                            break;
                        case 6:
                            timeStringList.Add(Language.Get("Weekday6"));
                            break;
                    }
                }
            }
 
            return string.Join(",", timeStringList.ToArray());
        }
 
    }
 
    public List<HourMinute> GetHourMinuteByWeek(int week)
    {
        var isMixServer = TimeUtility.IsMixServer && TimeUtility.MixOpenDay < GeneralDefine.mixServerCustomDays;
        if (isMixServer && mixServerOpenTimes.Count > 0)
        {
            week = week == 0 ? 7 : week;
            var todayWeek = (int)TimeUtility.ServerNow.DayOfWeek;
            todayWeek = todayWeek == 0 ? 7 : todayWeek;
            var targetMixOpenDay = week - todayWeek + TimeUtility.MixOpenDay;
            if (mixServerOpenTimes.ContainsKey(targetMixOpenDay + 1))
            {
                return mixServerOpenTimes[targetMixOpenDay + 1];
            }
            else
            {
                return null;
            }
        }
        else
        {
            var isSpecificDay = TimeUtility.OpenDay < 7;
            if (isSpecificDay && specialOpenTimes.Count > 0)
            {
                var openDayWeek = (int)TimeUtility.openServerDayOfWeek;
                var todayWeek = (int)TimeUtility.ServerNow.DayOfWeek;
                var dayDelta = ((week == 0 ? 7 : week) - (todayWeek == 0 ? 7 : todayWeek));
                var dayIndex = TimeUtility.OpenDay + 1 + dayDelta;
                if (specialOpenTimes.ContainsKey(openDayWeek) && specialOpenTimes[openDayWeek].ContainsKey(dayIndex))
                {
                    return specialOpenTimes[openDayWeek][dayIndex];
                }
            }
            else if (openTimes.ContainsKey(week % 7))
            {
                return openTimes[week % 7];
            }
        }
 
        return null;
    }
 
    public List<HourMinute> GetNormalHourMinutes()
    {
        foreach (var hourMinutes in openTimes.Values)
        {
            if (hourMinutes != null)
            {
                return hourMinutes;
            }
        }
        return null;
    }
}
 
public struct HourMinute
{
    public int hourBegin;
    public int minuteBegin;
    public int hourEnd;
    public int minuteEnd;
    public bool wholeDay;
 
    public HourMinute(string _input, int _duration)
    {
        var matches = Regex.Matches(_input, "[0-9]{1,2}");
        if (matches.Count >= 2)
        {
            hourBegin = int.Parse(matches[0].Value);
            minuteBegin = int.Parse(matches[1].Value);
 
            hourEnd = hourBegin + _duration / 60;
            minuteEnd = minuteBegin + _duration % 60;
            if (minuteEnd >= 60)
            {
                minuteEnd = minuteEnd % 60;
                hourEnd += 1;
            }
 
            wholeDay = false;
        }
        else
        {
            hourBegin = 0;
            minuteBegin = 0;
            hourEnd = 0;
            minuteEnd = 0;
 
            wholeDay = true;
        }
    }
 
    public HourMinute(int _hourBegin, int _minuteBegin, int _hourEnd, int _minuteEnd)
    {
        hourBegin = _hourBegin;
        minuteBegin = _minuteBegin;
        hourEnd = _hourEnd;
        minuteEnd = _minuteEnd;
 
        wholeDay = hourBegin == 0 && minuteBegin == 0 && hourEnd == 0 && minuteEnd == 0;
 
    }
 
    public bool InOpenTime()
    {
        if (wholeDay)
        {
            return true;
        }
        else
        {
            var minutes = TimeUtility.ServerNow.Hour * 60 + TimeUtility.ServerNow.Minute;
            if ((hourBegin * 60 + minuteBegin) <= minutes && (hourEnd * 60 + minuteEnd) > minutes)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
 
    public bool AfterOpenTime(int hour, int minute)
    {
        if (wholeDay)
        {
            return false;
        }
        else
        {
            var minutes = hour * 60 + minute;
            return (hourEnd * 60 + minuteEnd) <= minutes;
        }
    }
 
    public override string ToString()
    {
        var minuteBeginStr = minuteBegin > 9 ? minuteBegin.ToString() : StringUtility.Contact("0", minuteBegin);
        var minuteEndStr = minuteEnd > 9 ? minuteEnd.ToString() : StringUtility.Contact("0", minuteEnd);
        return StringUtility.Contact(hourBegin, ":", minuteBeginStr, "--", hourEnd, ":", minuteEndStr);
    }
 
    public string ToOpenTime()
    {
        if (minuteBegin < 10)
        {
            return StringUtility.Contact(hourBegin, ":0", minuteBegin);
        }
        else
        {
            return StringUtility.Contact(hourBegin, ":", minuteBegin);
        }
    }
 
    public static int Compare(HourMinute _lhs, HourMinute _rhs)
    {
        return (_lhs.hourBegin * 60 + _lhs.minuteBegin) < (_rhs.hourBegin * 60 + _rhs.minuteBegin) ? -1 : 1;
    }
 
}