少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using LitJson;
 
public class TreasurePavilionModel : ILModel<TreasurePavilionModel>
{
    //古宝ID:[星级,等级]
    Dictionary<int, List<int>> gubaoDict = new Dictionary<int, List<int>>();
    List<int> gubaoShowList = new List<int>();  //排序显示 可激活-已激活-品质
 
    public Dictionary<int, int> gubaoAwardDict = new Dictionary<int, int>();
    public Dictionary<int, int> gubaoEffectDict = new Dictionary<int, int>(); //古宝特效
    public Dictionary<int, string> gubaoDiIconDict = new Dictionary<int, string>();
    public int[] xbIDArr;
    public Dictionary<int, int> luckyDrawFuncIDDict = new Dictionary<int, int>();
    public event Action UpdateGubaoEvent;
    public Dictionary<int, Dictionary<int, int[]>> probabilityDisplayDict = new Dictionary<int, Dictionary<int, int[]>>();
    public int selectGubao; //从藏宝阁选中
    public int waitActiveGubao; //激活等待显示的古宝
    public int upgradeGubao;    //当前升级升星的古宝
    public int upgradeFuncOrder = 0;//0升星1升级
    string scoreFormula;
    public bool isEffectPlaying = false;//古宝抽奖动画正在播放
    public List<int> gubaoTypeList = new List<int>();
    public Dictionary<int, int> gubaoItemCountDict = new Dictionary<int, int>();    //古宝碎片背包物品改为数值记录
    public event Action UpdateGubaoItemCountEvent;
 
    public bool isSkipOneTip = false;                                       //本次登录是否跳过一次购买二次确认窗口
    public bool isSkipManyTip = false;                                       //本次登录是否跳过多次购买二次确认窗口
    public bool isWinOpen = false;
    int getA3CBCount;          //古宝收到了几次包
    int m_SelectIndex;  //古宝总类型
    public event Action OnSelectUpdate;
    public int selectIndex
    {
        get { return m_SelectIndex; }
        set
        {
            if (m_SelectIndex != value)
            {
                m_SelectIndex = value;
                OnSelectUpdate?.Invoke();
            }
        }
    }
 
    int m_SelectTagIndex = 0;  //古宝Tag类型 0 全部 1 共鸣 2 可升星
    public int selectTagIndex
    {
        get { return m_SelectTagIndex; }
        set
        {
            if (m_SelectTagIndex != value)
            {
                m_SelectTagIndex = value;
                OnSelectUpdate?.Invoke();
            }
        }
    }
 
    int m_SelectResonanceID = 0;
    public int selectResonanceID
    {
        get { return m_SelectResonanceID; }
        set
        {
            if (m_SelectResonanceID != value)
            {
                m_SelectResonanceID = value;
            }
        }
    }
 
    bool m_showLuckyDraw = false;
    public bool isShowLuckyDraw
    {
        get { return m_showLuckyDraw; }
        set
        {
            if (m_showLuckyDraw != value)
            {
                m_showLuckyDraw = value;
                OnSelectUpdate?.Invoke();
            }
        }
    }
    int m_XBIndex = 0;
    public int xbIndex
    {
        get { return m_XBIndex; }
        set
        {
            if (m_XBIndex != value)
            {
                m_XBIndex = value;
                OnSelectUpdate?.Invoke();
            }
        }
    }
 
    PackModel packModel { get { return ModelCenter.Instance.GetModelEx<PackModel>(); } }
 
    Dictionary<int, Redpoint> activeRedPointDict = new Dictionary<int, Redpoint>();
    Dictionary<int, Redpoint> starRedPointDict = new Dictionary<int, Redpoint>();
    Dictionary<int, Redpoint> lvRedPointDict = new Dictionary<int, Redpoint>();
    Dictionary<int, Redpoint> awardRedPointDict = new Dictionary<int, Redpoint>();
    Redpoint tmpRP = new Redpoint(MainRedDot.RedPoint_key, MainRedPoint.cbgRedpoint);
    Redpoint treasureLuckyDrawRedpoint = new Redpoint(MainRedPoint.cbgRedpoint, MainRedDot.TreasureLuckyDrawRedpoint);    //古宝抽奖入口红点
    List<Redpoint> treasureLuckyDrawTabRedpointList = new List<Redpoint>(); //古宝抽奖Tab红点
    Redpoint treasureLuckDrawFreeRedpoint = new Redpoint(MainRedDot.TreasureLuckyDrawRedpoint, MainRedDot.TreasureLuckyDrawRedpoint * 10 + 9);//免费抽奖红点
    TreasurePavilionUpgradeChooseModel treasurePavilionUpgradeChooseModel { get { return ModelCenter.Instance.GetModelEx<TreasurePavilionUpgradeChooseModel>(); } }
    protected override void Init()
    {
        GameEvent.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
        packModel.refreshItemCountEvent += RefreshItemCount;
        FuncOpen.Instance.OnFuncStateChangeEvent += OnFunctionStateChange;
        ParseConfig();
 
        for (int i = 0; i < gubaoTypeList.Count; i++)
        {
            new Redpoint(MainRedPoint.cbgRedpoint, MainRedPoint.cbgRedpoint * 10 + gubaoTypeList[i]);
        }
        for (int i = 0; i < 4; i++)
        {
            treasureLuckyDrawTabRedpointList.Add(new Redpoint(MainRedDot.TreasureLuckyDrawRedpoint, MainRedDot.TreasureLuckyDrawRedpoint * 10 + i));
        }
        var gubaoKeys = ILGubaoConfig.GetKeys();
        for (int i = 0; i < gubaoKeys.Count; i++)
        {
            var gubaoID = int.Parse(gubaoKeys[i]);
            var gubaoRPID = MainRedPoint.cbgRedpoint * 10000 + gubaoID;
            var config = ILGubaoConfig.Get(gubaoID);
            new Redpoint(MainRedPoint.cbgRedpoint * 10 + config.GubaoType, gubaoRPID);
            activeRedPointDict[gubaoID] = new Redpoint(gubaoRPID, gubaoRPID * 10);
            starRedPointDict[gubaoID] = new Redpoint(gubaoRPID, gubaoRPID * 10 + 1);
            lvRedPointDict[gubaoID] = new Redpoint(gubaoRPID, gubaoRPID * 10 + 2);
            var starConfig = ILGubaoStarConfig.Get(ILGubaoStarConfig.GetGubaoStarIndex(gubaoID, 1));
            if (starConfig.StarEffIDList[0] != 0 && ILGubaoEffAttrConfig.Get(starConfig.StarEffIDList[0]).EffItemAwardList.Length > 2)
            {
                awardRedPointDict[gubaoID] = new Redpoint(gubaoRPID, gubaoRPID * 10 + 3);
            }
            //if (!unLockItems.Contains(config.UnlockItemID))
            //{
            //    unLockItems.Add(config.UnlockItemID);
            //}
        }
    }
 
    protected override void UnInit()
    {
        GameEvent.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
        packModel.refreshItemCountEvent -= RefreshItemCount;
        FuncOpen.Instance.OnFuncStateChangeEvent -= OnFunctionStateChange;
    }
    private void OnFunctionStateChange(int id)
    {
        if (id == 234)
        {
            UpdateLuckyDrawRedpoint();
        }
    }
    void ParseConfig()
    {
        gubaoTypeList = ILGubaoConfig.gubaoTypeDict.Keys.ToList();
        //gubaoShowList.Clear();
        //var tmpList = ILGubaoConfig.GetKeys();
        //for (int i = 0; i < tmpList.Count; i++)
        //{
        //    gubaoShowList.Add(int.Parse(tmpList[i]));
        //}
        var config = FuncConfigConfig.Get("gubao");
        var json = JsonMapper.ToObject(config.Numerical1);
        var keys = json.Keys.ToList();
        for (int i = 0; i < keys.Count; i++)
        {
            gubaoEffectDict[int.Parse(keys[i])] = int.Parse(json[keys[i]].ToString());
        }
 
        json = JsonMapper.ToObject(config.Numerical2);
        keys = json.Keys.ToList();
        for (int i = 0; i < keys.Count; i++)
        {
            gubaoDiIconDict[int.Parse(keys[i])] = json[keys[i]].ToString();
        }
 
        scoreFormula = config.Numerical3;
 
        config = FuncConfigConfig.Get("TreasureLuckyDraw");
        xbIDArr = JsonMapper.ToObject<int[]>(config.Numerical1);
        json = JsonMapper.ToObject(config.Numerical2);
        keys = json.Keys.ToList();
        for (int i = 0; i < keys.Count; i++)
        {
            luckyDrawFuncIDDict[int.Parse(keys[i])] = int.Parse(json[keys[i]].ToString());
        }
 
        for (int i = 0; i < xbIDArr.Length; i++)
        {
            int xbID = xbIDArr[i];
            int type = XBGetItemConfig.Get(xbID).TreasureType;
            Dictionary<int, int[]> result = new Dictionary<int, int[]>();
            string str = TreasureSetConfig.Get(type).ProbabilityDisplay;
            var jsonData = JsonMapper.ToObject(str);
            var keyList = jsonData.Keys.ToList();
            for (int j = 0; j < keyList.Count; j++)
            {
                string key = keyList[j];
                int[] value = JsonMapper.ToObject<int[]>(jsonData[key].ToJson());
                result[int.Parse(key)] = value;
            }
            probabilityDisplayDict[type] = result;
        }
 
 
    }
 
 
    void OnBeforePlayerDataInitialize()
    {
        gubaoDict.Clear();
        waitActiveGubao = 0;
        gubaoAwardDict.Clear();
        gubaoItemCountDict.Clear();
        getA3CBCount = 0;
    }
 
 
    void RefreshItemCount(PackType packType, int index, int itemID)
    {
        if (packType == PackType.Item)
        {
            if (CanRefreshRepoint(itemID))
            {
                UpdateRedpoint();
            }
        }
    }
 
    public void UpdateLuckyDrawRedpoint()
    {
        var keyList = luckyDrawFuncIDDict.Keys.ToList();
        for (int i = 0; i < treasureLuckyDrawTabRedpointList.Count; i++)
        {
            treasureLuckyDrawTabRedpointList[i].state = RedPointState.None;
        }
        treasureLuckDrawFreeRedpoint.state = RedPointState.None;
        for (int i = 0; i < 4; i++)
        {
            if (i < xbIDArr.Length)
            {
                if (!luckyDrawFuncIDDict.ContainsKey(xbIDArr[i]))
                    return;
                if (!FuncOpen.Instance.IsFuncOpen(luckyDrawFuncIDDict[xbIDArr[i]]))
                    return;
                int type = XBGetItemConfig.Get(xbIDArr[i]).TreasureType;
                var funcSet = ModelCenter.Instance.GetModel<HappyXBModel>().GetXBFuncSet(type);
                bool isHaveFree = ModelCenter.Instance.GetModel<HappyXBModel>().IsHaveFreeXB(type);
                if (isHaveFree)
                {
                    treasureLuckyDrawTabRedpointList[i].state = RedPointState.Simple;
                    if (xbIndex == i)
                    {
                        treasureLuckDrawFreeRedpoint.state = RedPointState.Simple;
                    }
                }
            }
        }
    }
 
    // 428 -4281(类型) - 4280000 - 42800001
    // 主界面红点-古宝(ID)红点- 0激活1升星2升级红点 
    // 物品数量
    public void UpdateRedpoint()
    {
        treasurePavilionUpgradeChooseModel.UpdateGubaoPieceInfo();
        var keys = activeRedPointDict.Keys.ToList();
        for (int i = 0; i < keys.Count; i++)
        {
            var gubaoID = keys[i];
            activeRedPointDict[gubaoID].state = RedPointState.None;
            starRedPointDict[gubaoID].state = RedPointState.None;
            lvRedPointDict[gubaoID].state = RedPointState.None;
 
            var config = ILGubaoConfig.Get(gubaoID);
 
            if (!gubaoDict.ContainsKey(gubaoID))
            {
                var hasCnt = GetGubaoItemCount(gubaoID);// packModel.GetItemCountByID(PackType.Item, config.UnlockItemID);
                if (hasCnt >= config.UnlockItemCnt)
                {
                    activeRedPointDict[gubaoID].state = RedPointState.Simple;
                }
 
            }
            else
            {
                var gubaoInfo = TryGetGubaoInfo(gubaoID);
                //升级红点
                var needItems = ILGubaoLVConfig.GetGubaoQualityLVItems(config.GubaoType, config.GubaoQuality, gubaoInfo[1]);
                bool enough = true;
                for (int j = 0; j < needItems.Count; j++)
                {
                    var hasCnt = packModel.GetItemCountByID(PackType.Item, needItems[j].x);
                    if (hasCnt < needItems[j].y)
                    {
                        enough = false;
                        break;
                    }
                }
                if (enough && needItems.Count > 0)
                    lvRedPointDict[gubaoID].state = RedPointState.Simple;
 
                //升星红点
                var maxStar = ILGubaoStarConfig.GetMaxStar(gubaoID);
                if (maxStar == 1)
                {
                    continue;
                }
                var qualityItems = ILGubaoStarConfig.GetGubaQualityPieceInfoList(gubaoID, gubaoInfo[0]);
                needItems = ILGubaoStarConfig.GetGubaoStarItems(gubaoID, gubaoInfo[0]);
                enough = true;
                for (int j = 0; j < needItems.Count; j++)
                {
                    var itemConfig = ItemConfig.Get(needItems[j].x);
                    int hasCnt;
                    if (itemConfig.Effect1 == 270)
                        hasCnt = GetGubaoItemCount(itemConfig.EffectValueA1);
                    else
                        hasCnt = packModel.GetItemCountByID(PackType.Item, needItems[j].x);
                    if (hasCnt < needItems[j].y)
                    {
                        enough = false;
                        break;
                    }
                }
 
                // 检查古宝碎片
                if (enough)
                {
                    for (int j = 0; j < qualityItems.Count; j++)
                    {
                        int quality = qualityItems[j].x;
                        int cnt = qualityItems[j].y;
                        int hasCnt = treasurePavilionUpgradeChooseModel.GetHaveGuBaoPieceCountByQuality(quality);
                        if (hasCnt < cnt)
                        {
                            enough = false;
                            break;
                        }
                    }
                }
 
                if (enough && (needItems.Count > 0 || qualityItems.Count > 0))
                    starRedPointDict[gubaoID].state = RedPointState.Simple;
 
            }
        }
    }
 
    void UpdateRedpointAward()
    {
        var keys = awardRedPointDict.Keys.ToList();
        for (int i = 0; i < keys.Count; i++)
        {
            var gubaoID = keys[i];
            awardRedPointDict[gubaoID].state = RedPointState.None;
 
            //领取红点
            if (gubaoAwardDict.ContainsKey(gubaoID) && gubaoAwardDict[gubaoID] > 0)
            {
                var starConfig = ILGubaoStarConfig.Get(ILGubaoStarConfig.GetGubaoStarIndex(gubaoID, gubaoDict[gubaoID][0]));
                if (gubaoAwardDict[gubaoID] / ILGubaoEffAttrConfig.Get(starConfig.StarEffIDList[0]).EffCond > 0)
                {
                    awardRedPointDict[gubaoID].state = RedPointState.Simple;
                }
            }
        }
    }
 
 
 
    bool CanRefreshRepoint(int itemID)
    {
        //if (unLockItems.Contains(itemID))
        //    return true;
 
        if (ILGubaoLVConfig.needItemIDs.Contains(itemID))
            return true;
 
        if (ILGubaoStarConfig.needItemIDs.Contains(itemID))
            return true;
        return false;
    }
 
    public void UpdateGubaoNetPack(IL_HA3C7_tagMCGubaoInfo netPack)
    {
        for (int i = 0; i < netPack.Count; i++)
        {
            gubaoDict[netPack.GubaoInfoList[i].GubaoID] = new List<int>() {
            netPack.GubaoInfoList[i].GubaoStar,
            netPack.GubaoInfoList[i].GubaoLV
            };
        }
 
        UpdateGubaoEvent?.Invoke();
        if (waitActiveGubao != 0 && gubaoDict.ContainsKey(waitActiveGubao))
        {
            WindowCenter.Instance.OpenIL<TreasurePavilionActiveWin>();
        }
        UpdateRedpoint();
    }
 
    public void SortGubaoList()
    {
        gubaoShowList = ILGubaoConfig.gubaoTypeDict[gubaoTypeList[selectIndex]];
        gubaoShowList.Sort(CmpGubao);
    }
 
    public List<int> GetGubaoList()
    {
        return gubaoShowList;
    }
 
 
 
    public List<int> TryGetGubaoInfo(int gubaoID)
    {
        if (!gubaoDict.ContainsKey(gubaoID))
            return new List<int>();
 
        return gubaoDict[gubaoID];
    }
 
 
    //排序显示 可激活-已激活-品质
    int CmpGubao(int gubaoA, int gubaoB)
    {
        var isActiveA = gubaoDict.ContainsKey(gubaoA);
        var isActiveB = gubaoDict.ContainsKey(gubaoB);
 
        var configA = ILGubaoConfig.Get(gubaoA);
        var configB = ILGubaoConfig.Get(gubaoB);
        var canActiveA = false;
        var canActiveB = false;
        if (!isActiveA)
        {
            canActiveA = GetGubaoItemCount(gubaoA) >= configA.UnlockItemCnt;
            if (canActiveA) isActiveA = true;
        }
 
        if (!isActiveB)
        {
            canActiveB = GetGubaoItemCount(gubaoB) >= configB.UnlockItemCnt;
            if (canActiveB) isActiveB = true;
        }
 
        if (canActiveA != canActiveB)
        {
            return canActiveB.CompareTo(canActiveA);
        }
 
        if (isActiveA != isActiveB)
        {
            return isActiveB.CompareTo(isActiveA);
        }
 
        int gubaoQualityA = configA.GubaoQuality;
        int gubaoQualityB = configB.GubaoQuality;
        if (gubaoQualityA != gubaoQualityB)
        {
            return gubaoQualityB.CompareTo(gubaoQualityA);
        }
 
        return gubaoA.CompareTo(gubaoB);
    }
 
    public int GetGubaoScore(int gubaoID)
    {
        Equation.Instance.Clear();
        //baseScore+lvFightPower*0.2+starScore
        var config = ILGubaoConfig.Get(gubaoID);
        Equation.Instance.AddKeyValue("baseScore", config.BaseScore);
 
        var gubaoInfo = TryGetGubaoInfo(gubaoID);
        var lvFightPower = 0;
 
        ILGubaoStarConfig starConfig = null;
        if (gubaoDict.ContainsKey(gubaoID))
        {
            starConfig = ILGubaoStarConfig.Get(ILGubaoStarConfig.GetGubaoStarIndex(gubaoID, gubaoDict[gubaoID][0]));
        }
 
        if (gubaoInfo.Count > 0)
        {
            var lvConfig = ILGubaoLVConfig.Get(ILGubaoLVConfig.GetGubaoQualityLVIndex(config.GubaoType, config.GubaoQuality, gubaoInfo[1]));
            Dictionary<int, int> attrDict = new Dictionary<int, int>();
            for (int i = 0; i < lvConfig.LVAttrTypeList.Length; i++)
            {
                attrDict[lvConfig.LVAttrTypeList[i]] = lvConfig.LVAttrValueList[i];
            }
 
            if (starConfig.StarAttrIDList.Length != 0)
            {
                for (int i = 0; i < starConfig.StarAttrIDList.Length; i++)
                {
                    if (!attrDict.ContainsKey(starConfig.StarAttrIDList[i]))
                    {
                        attrDict[starConfig.StarAttrIDList[i]] = 0;
                    }
                    attrDict[starConfig.StarAttrIDList[i]] += starConfig.StarAttrValueList[i];
                }
            }
 
            lvFightPower = UIHelper.GetFightPower(attrDict);
        }
        Equation.Instance.AddKeyValue("lvFightPower", lvFightPower);
        var starScore = 0;
        if (starConfig != null)
        {
            for (int i = 0; i < starConfig.StarEffIDList.Length; i++)
            {
                if (!ILGubaoEffAttrConfig.Has(starConfig.StarEffIDList[i]))
                {
                    starScore += 0;
                }
                else
                {
                    starScore += ILGubaoEffAttrConfig.Get(starConfig.StarEffIDList[i]).StarScore;
                }
            }
        }
        Equation.Instance.AddKeyValue("starScore", starScore);
        return Equation.Instance.Eval<int>(scoreFormula);
    }
 
    public void ActiveGubao(int gubaoID)
    {
        var pak = new IL_CB216_tagCMGubaoActivate();
        pak.GubaoID = (ushort)gubaoID;
        GameNetSystem.Instance.SendInfo(pak);
        waitActiveGubao = gubaoID;
    }
 
    public void UpgradeGubaoStar(int gubaoID, IL_CB217_tagCMGubaoStarUp.tagCMGubaoPieceUse[] info = null)
    {
        var pak = new IL_CB217_tagCMGubaoStarUp();
        pak.GubaoID = (ushort)gubaoID;
        pak.CommPieceUseList = info;
        pak.PieceSelectCount = info == null ? (byte)0 : (byte)info.Length;
        GameNetSystem.Instance.SendInfo(pak);
    }
 
    public void UpgradeGubaoLV(int gubaoID)
    {
        var pak = new IL_CB218_tagCMGubaoLVUp();
        pak.GubaoID = (ushort)gubaoID;
        GameNetSystem.Instance.SendInfo(pak);
    }
 
    public event Action UpdateGubaoAwardEvent;
    public void UpdateGubaoAward(IL_HA3CA_tagMCGubaoItemEffInfo netPack)
    {
        for (int i = 0; i < netPack.ItemEffInfoList.Length; i++)
        {
            gubaoAwardDict[netPack.ItemEffInfoList[i].GubaoID] = (int)netPack.ItemEffInfoList[i].EffValue;
        }
 
        UpdateRedpointAward();
        UpdateGubaoAwardEvent?.Invoke();
    }
 
 
    public void UpdateGubaoItemCount(IL_HA3CB_tagMCGubaoPieceInfo netPack)
    {
 
        ShowRewardWin(netPack);
        for (int i = 0; i < netPack.PieceInfoList.Length; i++)
        {
            gubaoItemCountDict[netPack.PieceInfoList[i].GubaoID] = (int)netPack.PieceInfoList[i].PieceCount;
        }
        UpdateGubaoItemCountEvent?.Invoke();
        UpdateRedpoint();
    }
 
    private List<Item> accumulatedItems = new List<Item>();
    private Clock rewardClock;
 
    public void ShowRewardWin(IL_HA3CB_tagMCGubaoPieceInfo vNetData)
    {
        getA3CBCount += 1;
        if (WindowCenter.Instance.IsOpen<BoxGetItemWin>())
            return;
        if (getA3CBCount <= 1) // 同步古宝数据,避免触发奖励弹窗
            return;
        if (isShowLuckyDraw && isWinOpen)    //避免和古宝抽奖奖励弹窗冲突
            return;
 
 
        for (int i = 0; i < vNetData.PieceInfoList.Length; i++)
        {
            int gubaoID = vNetData.PieceInfoList[i].GubaoID;
            int pieceCount = (int)vNetData.PieceInfoList[i].PieceCount;
            int hasCnt = 0;
            if (gubaoItemCountDict.ContainsKey(gubaoID))
            {
                hasCnt = gubaoItemCountDict[gubaoID];
            }
            if (hasCnt > pieceCount)
                return;
            int itemId = ILGubaoConfig.Get(gubaoID).UnlockItemID;
            ItemLogicUtility.Instance.RefreshPickItem(PackType.Item, itemId.ToString());
            
        }
    }
 
    public int GetGubaoItemCount(int gubaoID)
    {
        if (!gubaoItemCountDict.ContainsKey(gubaoID))
            return 0;
 
        return gubaoItemCountDict[gubaoID];
    }
 
    //当前类型的古宝一个共鸣套装也没有
    public bool IsTypeNoReverberation()
    {
        var dict = GubaoResonanceConfig.GetGubaoIDToResonanceIDDict();
        var list = GetGubaoList();
        for (int i = 0; i < list.Count; i++)
        {
            int gubaoID = list[i];
            if (dict.ContainsKey(gubaoID))
            {
                return false;
            }
        }
        return true;
    }
 
 
 
    //返回当前所在标签类型的可升星的古宝列表
    public bool TryGetUpgradeStarList(out List<int> upgradeStarList)
    {
        upgradeStarList = new List<int>();
        var list = GetGubaoList();
        for (int i = 0; i < list.Count; i++)
        {
            int gubaoID = list[i];
            //古宝表里没有
            if (!ILGubaoConfig.Has(gubaoID)) continue;
            var config = ILGubaoConfig.Get(gubaoID);
            //古宝未激活
            if (!gubaoDict.ContainsKey(gubaoID)) continue;
            var gubaoInfo = TryGetGubaoInfo(gubaoID);
            var maxStar = ILGubaoStarConfig.GetMaxStar(gubaoID);
            //古宝最大等级只有1级
            if (maxStar == 1) continue;
            var qualityItems = ILGubaoStarConfig.GetGubaQualityPieceInfoList(gubaoID, gubaoInfo[0]);
            var needItems = ILGubaoStarConfig.GetGubaoStarItems(gubaoID, gubaoInfo[0]);
            var enough = true;
            for (int j = 0; j < needItems.Count; j++)
            {
                var itemConfig = ItemConfig.Get(needItems[j].x);
                int hasCnt;
                if (itemConfig.Effect1 == 270)
                    hasCnt = GetGubaoItemCount(itemConfig.EffectValueA1);
                else
                    hasCnt = packModel.GetItemCountByID(PackType.Item, needItems[j].x);
                if (hasCnt < needItems[j].y)
                {
                    enough = false;
                    break;
                }
            }
            // 检查古宝碎片
            if (enough)
            {
                for (int j = 0; j < qualityItems.Count; j++)
                {
                    int quality = qualityItems[j].x;
                    int cnt = qualityItems[j].y;
                    int hasCnt = treasurePavilionUpgradeChooseModel.GetHaveGuBaoPieceCountByQuality(quality);
                    if (hasCnt < cnt)
                    {
                        enough = false;
                        break;
                    }
                }
            }
 
            if (enough && (needItems.Count > 0 || qualityItems.Count > 0))
                upgradeStarList.Add(gubaoID);
        }
        return upgradeStarList.Count > 0;
    }
 
    //获取当前类型的所有共鸣ID
    public List<int> GetReverberationList()
    {
        List<int> tempList = new List<int>();
        var dict = GubaoResonanceConfig.GetGubaoIDToResonanceIDDict();
        var list = GetGubaoList();
        for (int i = 0; i < list.Count; i++)
        {
            int gubaoID = list[i];
            if (dict.ContainsKey(gubaoID))
            {
                int resonanceID = dict[gubaoID];
                if (!tempList.Contains(resonanceID))
                {
                    tempList.Add(resonanceID);
                }
            }
        }
        tempList.Sort();
        return tempList;
    }
 
    //显示内容(直接显示总的)
    public string GetInfo(int nowID)
    {
        if (!GubaoResonanceAttrConfig.Has(nowID))
            return string.Empty;
        var config = GubaoResonanceAttrConfig.Get(nowID);
        int resonanceStar = config.ResonanceStar;
        int[] attrIDArr = config.ResonanceAttrIDList;
        int[] attrValueArr = config.ResonanceAttrValueList;
        List<string> result = new List<string>();
        if (resonanceStar == 1)
        {
            result.Add(Language.Get("TreasurePavilion02"));
        }
        else
        {
            result.Add(Language.Get("TreasurePavilion03", resonanceStar));
        }
 
        for (int i = 0; i < attrIDArr.Length; i++)
        {
            result.Add(GetShowAttribute(attrIDArr[i], attrValueArr[i]));
        }
 
        string str = StringUtility.Contact(result.ToArray());
        result.Clear();
        result = null;
        return str;
    }
 
    //获得当前共鸣星级上一共鸣星级的共鸣属性ID 没有返回0
    public int GetLastResonanceStarID(int resonanceID, int resonanceStar)
    {
        var dict = GubaoResonanceAttrConfig.GetDict();
        var starDict = dict[resonanceID];
        var keyList = starDict.Keys.ToList();
        int minResonanceStar = resonanceStar;
 
        //传入星级是1 已经是最小星级的
        if (resonanceStar == 1)
            return 0;
        keyList.Sort();
        int index = keyList.IndexOf(resonanceStar);
        if (index - 1 < 0)
            return 0;
        return starDict[keyList[index - 1]];
    }
 
    //获得当前共鸣星级上一共鸣星级的属性值 没有返回0
    public long GetLastAttributeValue(int lastID, int nowAttrID)
    {
        if (lastID == 0)
            return 0;
        var config = GubaoResonanceAttrConfig.Get(lastID);
        int[] lastAttrIDArr = config.ResonanceAttrIDList;
        int[] lastAttrValueArr = config.ResonanceAttrValueList;
        if (!IsLastHaveAttributeID(lastID, nowAttrID))
            return 0;
        int index = GetLastHaveAttributeIDIndex(lastID, nowAttrID);
        return lastAttrValueArr[index];
    }
 
    //上一档是否存在这个属性
    public bool IsLastHaveAttributeID(int lastID, int AttrID)
    {
        if (lastID == 0)
            return false;
        var config = GubaoResonanceAttrConfig.Get(lastID);
        int[] lastAttrIDArr = config.ResonanceAttrIDList;
        for (int i = 0; i < lastAttrIDArr.Length; i++)
        {
            if (lastAttrIDArr[i] == AttrID)
            {
                return true;
            }
        }
        return false;
    }
 
    public int GetLastHaveAttributeIDIndex(int lastID, int AttrID)
    {
        var config = GubaoResonanceAttrConfig.Get(lastID);
        int[] lastAttrIDArr = config.ResonanceAttrIDList;
        for (int i = 0; i < lastAttrIDArr.Length; i++)
        {
            if (lastAttrIDArr[i] == AttrID)
            {
                return i;
            }
        }
        return 0;
    }
 
    //传入属性id 自动根据属性类型决定后面加不加%
    public string GetShowAttribute(int id, long value)
    {
        if (id == 0 || !PlayerPropertyConfig.GetKeys().Contains(id.ToString()))
            return "";
        return StringUtility.Contact(" ", PlayerPropertyConfig.Get(id).Name, " +", PlayerPropertyConfig.GetValueDescription(id, value) + " ");
    }
 
    //获得这组古宝的最小星数
    public int GetNowStar(int id)
    {
        int resonanceID = GubaoResonanceAttrConfig.Get(id).ResonanceID;
        var gubaoIDList = GubaoResonanceConfig.Get(resonanceID).GubaoIDList;
        List<int> starCountList = new List<int>();
        for (int i = 0; i < gubaoIDList.Length; i++)
        {
            int gubaoID = gubaoIDList[i];
            var list = TryGetGubaoInfo(gubaoID);
            if (list.Count == 0)
                return 0;
            starCountList.Add(list[0]);
        }
        starCountList.Sort();
        return starCountList[0];
    }
 
    //获取共鸣中有几件古宝激活了
    public int GetResonanceGuBaoActiveCount(int resonanceID)
    {
        int count = 0;
        var gubaoIDList = GubaoResonanceConfig.Get(resonanceID).GubaoIDList;
        for (int i = 0; i < gubaoIDList.Length; i++)
        {
            int gubaoID = gubaoIDList[i];
            var list = TryGetGubaoInfo(gubaoID);
            var hasCnt = GetGubaoItemCount(gubaoID);
            var config = ILGubaoConfig.Get(gubaoID);
            //满足激活条件的古宝 视为已激活
            if (list.Count == 0)
            {
                if (hasCnt >= config.UnlockItemCnt)
                {
                    count += 1;
                }
                else
                {
                    continue;
                }
            }
            else
            {
                count += 1;
            }
        }
        return count;
    }
 
 
    //获得这组古宝的最小星数
    public int GetNowStarByResonanceID(int resonanceID)
    {
        var gubaoIDList = GubaoResonanceConfig.Get(resonanceID).GubaoIDList;
        List<int> starCountList = new List<int>();
        for (int i = 0; i < gubaoIDList.Length; i++)
        {
            int gubaoID = gubaoIDList[i];
            var list = TryGetGubaoInfo(gubaoID);
            if (list.Count == 0)
                return 0;
            starCountList.Add(list[0]);
        }
        starCountList.Sort();
        return starCountList[0];
    }
 
    //获取共鸣中有几条属性激活了
    public int GetResonanceGuBaoAttrActiveCount(int resonanceID)
    {
        int minStar = GetNowStarByResonanceID(resonanceID);
        int count = 0;
        var starList = GubaoResonanceAttrConfig.GetResonanceStarDict()[resonanceID];
        for (int j = 0; j < starList.Count; j++)
        {
            int star = starList[j];
            if (star <= minStar)
            {
                count += 1;
            }
        }
        return count;
    }
 
    //对套装进行排序
    //套装激活属性数量未满 > 没有任何激活的古宝套装 > 套装所有属性激活
    public int CmpResonance(int resonanceA, int resonanceB)
    {
        // 套装中古宝数量
        int gubaoCountA = GubaoResonanceConfig.Get(resonanceA).GubaoIDList.Length;
        int gubaoCountB = GubaoResonanceConfig.Get(resonanceB).GubaoIDList.Length;
        // 套装中激活的古宝数量
        int activeCountA = GetResonanceGuBaoActiveCount(resonanceA);
        int activeCountB = GetResonanceGuBaoActiveCount(resonanceB);
        // 套装可激活属性数量
        int AttrCountA = GubaoResonanceAttrConfig.GetResonanceStarDict()[resonanceA].Count;
        int AttrCountB = GubaoResonanceAttrConfig.GetResonanceStarDict()[resonanceB].Count;
        // 套装激活属性数量
        int activeAttrCountA = GetResonanceGuBaoAttrActiveCount(resonanceA);
        int activeAttrCountB = GetResonanceGuBaoAttrActiveCount(resonanceB);
 
        // 判断是否有任一古宝激活但套装未满(包括未激活任何套装效果的情况)
        bool isPartiallyActiveA = activeCountA > 0 && activeCountA < gubaoCountA;
        bool isPartiallyActiveB = activeCountB > 0 && activeCountB < gubaoCountB;
 
        // 判断套装属性是否全部激活
        bool allActiveA = activeAttrCountA == AttrCountA && activeAttrCountA > 0;
        bool allActiveB = activeAttrCountB == AttrCountB && activeAttrCountB > 0;
 
        // 处理套装所有属性激活的情况,将其排在最后
        if (allActiveA != allActiveB)
        {
            return allActiveA ? 1 : -1; // 全部激活的套装排在后面
        }
 
        // 如果都是全部激活或都不是全部激活,继续比较其他条件
 
        // 比较激活属性数量
        if (activeAttrCountA != activeAttrCountB)
        {
            return activeAttrCountB.CompareTo(activeAttrCountA);
        }
 
        // 如果激活属性数量相同,处理有任一古宝激活但套装未满的情况
        if (isPartiallyActiveA != isPartiallyActiveB)
        {
            return isPartiallyActiveA ? -1 : 1; // 部分激活的套装优先
        }
 
        if (isPartiallyActiveA && isPartiallyActiveB)
        {
            // 两个套装都是部分激活,比较激活的古宝数量
            return activeCountB.CompareTo(activeCountA);
        }
 
        // 处理没有任何激活的古宝套装的情况
        if (activeCountA == 0 && activeCountB == 0)
        {
            // 两个套装都没有激活的古宝,比较总古宝数量
            return gubaoCountB.CompareTo(gubaoCountA);
        }
 
        // 如果都是全部激活的情况,比较总古宝数量
        if (allActiveA && allActiveB)
        {
            return gubaoCountB.CompareTo(gubaoCountA);
        }
 
        // 如果代码执行到这里,说明存在未考虑到的情况,返回0表示相等
        return 0;
 
    }
 
    public int GetJumpIndex()
    {
        if (selectResonanceID == 0)
        {
            return 0;
        }
        else
        {
            List<int> reverberationList = GetReverberationList();
            reverberationList.Sort(CmpResonance);
            int index = reverberationList.IndexOf(selectResonanceID);
            if (index < 0)
            {
                return 0;
            }
            return index;
        }
    }
 
    //获取品质对应的可展示的物品ID
    public List<int> GetItemIDByQuality(int quality, int treasureType)
    {
        List<int> result = new List<int>();
        var probabilityDict = probabilityDisplayDict[treasureType];
        int[] libs = probabilityDict[quality];
        for (int i = 0; i < libs.Length; i++)
        {
            int libID = libs[i];
            var list = TreasureItemLibConfig.GetItemIDList(libID);
            for (int j = 0; j < list.Count; j++)
            {
                if (!result.Contains(list[j]))
                {
                    result.Add(list[j]);
                }
            }
        }
        return result;
    }
 
    public Dictionary<int, int> GetRateDict(int treasureID)
    {
        Dictionary<int, int> result = new Dictionary<int, int>();
        Dictionary<int, int> gridLibInfo = new Dictionary<int, int>();
        var jsonData = JsonMapper.ToObject(XBGetItemConfig.Get(treasureID).GridLibInfo);
        var keyList = jsonData.Keys.ToList();
        for (int i = 0; i < keyList.Count; i++)
        {
            gridLibInfo[int.Parse(keyList[i])] = int.Parse(jsonData[keyList[i]].ToString());
        }
 
        int[][] GridItemRateList = XBGetItemConfig.Get(treasureID).GridItemRateList1;
        Dictionary<int, int> rateDict = ConfigParse.GetRateDict(GridItemRateList);
 
        var InfoKey = gridLibInfo.Keys.ToList();
        for (int i = 0; i < InfoKey.Count; i++)
        {
            int grid = InfoKey[i];
            int lib = gridLibInfo[grid];
            result[lib] = rateDict[grid];
        }
 
        return result;
    }
 
    public List<string> GetGubaoEffects(int gubaoID, bool includeShentong = true, int star = 0)
    {
        List<string> starInfo = new List<string>();
        if (includeShentong)
        {
            int shentongID = ShentongModel.Instance.GetShentongIDByGubaoID(gubaoID);
            if (shentongID != 0)
            {
                //激活神通Shentong8
                starInfo.Add(Language.Get("Shentong8", ILShentongConfig.Get(shentongID).Name));
            }
        }
 
        int showStar;
        if (star != 0)
        {
            showStar = star;
        }
        else
        {
            var gubaoInfo = TryGetGubaoInfo(gubaoID);
            showStar = gubaoInfo.Count == 0 ? 1 : gubaoInfo[0];
        }
 
        var starConfig = ILGubaoStarConfig.Get(ILGubaoStarConfig.GetGubaoStarIndex(gubaoID, showStar));
        if (starConfig.StarEffIDList[0] != 0)
        {
            starInfo.Add(ILGubaoEffAttrConfig.Get(starConfig.StarEffIDList[0]).Name);
        }
        for (int i = 0; i < starConfig.StarAttrIDList.Length; i++)
        {
            starInfo.Add(PlayerPropertyConfig.GetFullDescription(starConfig.StarAttrIDList[i], starConfig.StarAttrValueList[i]));
        }
 
        return starInfo;
    }
}