少年修仙传客户端代码仓库
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
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using System.Linq;
 
public class ZhanLingHBuyModel : Model
{
    public int zhanLingType;        //高级战令类型
    public int showGiftType;        //1 普通战令礼包 2 高级战令礼包
    public string bgIconkey;        //背景在Icon表中的KEY
 
    public Dictionary<int, List<int>> ctgIdDictH = new Dictionary<int, List<int>>();
    public Dictionary<int, List<int>> ctgIdDict = new Dictionary<int, List<int>>();
    VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
    GatheringSoulZhanLingModel model { get { return ModelCenter.Instance.GetModel<GatheringSoulZhanLingModel>(); } }
 
    public override void Init()
    {
        ctgIdDict = GeneralDefine.ZhanLingCtgIdDict;
        ctgIdDictH = GeneralDefine.ZhanLingCtgIdHDict;
    }
 
    public override void UnInit()
    {
 
    }
 
    public void ShowZhanLingHBuy(int zhanLingType, int showGiftType, string bgIconkey = null)
    {
        this.zhanLingType = zhanLingType;
        this.showGiftType = showGiftType;
        this.bgIconkey = bgIconkey;
        if (!WindowCenter.Instance.IsOpen<ZhanLingHBuyWin>())
            WindowCenter.Instance.Open<ZhanLingHBuyWin>();
    }
 
    public int GetCtgID()
    {
        int ctgid = 0;
        if (showGiftType == 1)
        {
            ctgid = ctgIdDict[zhanLingType][0];
        }
        else if (showGiftType == 2)
        {
            ctgid = ctgIdDictH[zhanLingType][0];
        }
        return ctgid;
    }
 
    public List<Item> GetGiftAllItem()
    {
        List<Item> result = new List<Item>();
        //itemID,count
        Dictionary<int, int> resultDict = new Dictionary<int, int>();
        var dict = ILZhanlingConfig.GetTypeToIDDict(zhanLingType);
        var list = dict.Keys.ToList();
        for (int i = 0; i < list.Count; i++)
        {
            int needValue = list[i];
            int zhanLingID = dict[needValue];
            int[][] itemArr;
            if (showGiftType == 1)
            {
                itemArr = ILZhanlingConfig.Get(zhanLingID).ZLRewardItemList;
            }
            else if (showGiftType == 2)
            {
                itemArr = ILZhanlingConfig.Get(zhanLingID).ZLRewardItemListH;
            }
            else
            {
                itemArr = new int[][] { };
            }
 
            if (itemArr.IsNullOrEmpty())
                continue;
            for (int j = 0; j < itemArr.Length; j++)
            {
                int itemID = itemArr[j][0];
                int count = itemArr[j][1];
                if (resultDict.ContainsKey(itemID))
                {
                    resultDict[itemID] += count;
                }
                else
                {
                    resultDict[itemID] = count;
                }
            }
        }
        list = resultDict.Keys.ToList();
        list.Sort((a, b) =>
        {
            int count1 = resultDict[a];
            int count2 = resultDict[b];
            int quality1 = ItemConfig.Get(a).ItemColor;
            int quality2 = ItemConfig.Get(b).ItemColor;
 
            //品质高的排在前面
            if (quality1 != quality2)
            {
                return quality2.CompareTo(quality1);
            }
 
            // 品质相同时,数量多的排在前面
            if (count1 != count2)
            {
                return count2.CompareTo(count1);
            }
 
            // 如果品质和数量都相同,保持原有顺序
            return 0;
        });
 
        for (int i = 0; i < list.Count; i++)
        {
            int itemID = list[i];
            int count = resultDict[itemID];
            result.Add(new Item(itemID, count));
        }
        return result;
    }
 
 
}