少年修仙传客户端代码仓库
client_Hale
2019-04-11 f54f6c7531c426a59efa900c880ee86d90d38c9d
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LitJson;
 
public class LegendPropertyUtility
{
    static PropertyColor propertyColor;
    static PropertyMap dogzPropertyMap;
    static PropertyCount dogzPropertyCount;
    static QualityPropertyValue dogzQualityPropertyValue;
    static WingPropertyCount wingPropertyCount;
    static WingPropertyValue wingPropertyValue;
 
    public static void Init()
    {
        propertyColor = new PropertyColor("LegendAttrColor");
        dogzPropertyMap = new PropertyMap(FuncConfigConfig.Get("DogzLegendAttrColor").Numerical1,
            FuncConfigConfig.Get("DogzLegendAttrRulePreview").Numerical1);
        dogzPropertyCount = new PropertyCount(FuncConfigConfig.Get("DogzLegendAttrCountPreview").Numerical1);
        dogzQualityPropertyValue = new QualityPropertyValue(FuncConfigConfig.Get("DogzLegendAttrValueByColorPreview").Numerical1);
 
        wingPropertyCount = new WingPropertyCount();
        wingPropertyValue = new WingPropertyValue();
    }
 
    public static List<Int2> GetEquipProperties(int itemId)
    {
        var config = ItemConfig.Get(itemId);
        if (config == null)
        {
            return null;
        }
 
        var legendPropertyConfig = LegendPropertyValueConfig.Get(config.Type, config.LV, config.ItemColor, config.SuiteiD != 0);
        if (legendPropertyConfig == null)
        {
            return null;
        }
 
        return new List<Int2>(legendPropertyConfig.previewValue);
    }
 
    public static int GetEquipPropertyCount(int itemId)
    {
        var config = ItemConfig.Get(itemId);
        if (config == null)
        {
            return 0;
        }
 
        var legendPropertyConfig = LegendPropertyValueConfig.Get(config.Type, config.LV, config.ItemColor, config.SuiteiD != 0);
        if (legendPropertyConfig == null)
        {
            return 0;
        }
 
        return legendPropertyConfig.propertyCount;
    }
 
    public static string GetWingPropertyColor(int propertyId, int value)
    {
        return propertyColor.GetWingPropertyColor(propertyId, value);
    }
 
    public static LegendAttrType GetDogzPropertyType(int propertyId)
    {
        return dogzPropertyMap.GetPropertyType(propertyId);
    }
 
    public static bool HasDogzPlace(int place)
    {
        return dogzPropertyMap.HasPlace(place);
    }
 
    public static List<int> GetDogzPlaceProperties(int place)
    {
        return dogzPropertyMap.GetProperties(place);
    }
 
    public static int GetDogzPropertyCount(int quality, int star, LegendAttrType type)
    {
        return dogzPropertyCount.GetCount(quality, star, type);
    }
 
    public static int GetDogzQualityPropertyValue(int property, int quality)
    {
        return dogzQualityPropertyValue.GetValue(property, quality);
    }
 
    public static int GetWingPropertyCount(int level)
    {
        return wingPropertyCount.GetValue(level);
    }
 
    public static int GetWingPropertyMinValue(int level, int property)
    {
        return wingPropertyValue.GetMin(level, property);
    }
 
    public static int GetWingPropertyMaxValue(int level, int property)
    {
        return wingPropertyValue.GetMax(level, property);
    }
 
    public static bool HasWingProperties(int level)
    {
        return wingPropertyValue.Has(level);
    }
 
    public static List<int> GetWingProperties(int level)
    {
        return wingPropertyValue.GetProperties(level);
    }
 
    public static List<int> GetWingPropertyValues(int level, int property)
    {
        return wingPropertyValue.GetValues(level, property);
    }
 
    public class PropertyColor
    {
        Dictionary<int, Dictionary<int, string>> wingLegendPropertyColors = new Dictionary<int, Dictionary<int, string>>();
 
        public PropertyColor(string configId)
        {
            var config = FuncConfigConfig.Get(configId);
 
            var wingColorJsonData = JsonMapper.ToObject(config.Numerical2);
            foreach (var key in wingColorJsonData.Keys)
            {
                var propertyId = int.Parse(key);
                if (!wingLegendPropertyColors.ContainsKey(propertyId))
                {
                    wingLegendPropertyColors[propertyId] = new Dictionary<int, string>();
                }
 
                var subJson = wingColorJsonData[key];
                var colors = wingLegendPropertyColors[propertyId];
                foreach (var key2 in subJson.Keys)
                {
                    var limit = int.Parse(key2);
                    colors[limit] = subJson[key2][0].ToString();
                }
            }
 
        }
 
        public string GetWingPropertyColor(int propertyId, int value)
        {
            if (!wingLegendPropertyColors.ContainsKey(propertyId))
            {
                return "ffffff";
            }
 
            var colors = wingLegendPropertyColors[propertyId];
            var ienumerator = colors.GetEnumerator();
            ienumerator.MoveNext();
            var color = ienumerator.Current.Value;
 
            while (ienumerator.MoveNext())
            {
                if (value < ienumerator.Current.Key)
                {
                    color = ienumerator.Current.Value;
                }
                else
                {
                    break;
                }
            }
 
            return color;
        }
    }
 
    public class PropertyMap
    {
        Dictionary<int, LegendAttrType> propertyTypes = new Dictionary<int, LegendAttrType>();
        // key 装备位 value 属性ID
        Dictionary<int, List<int>> placeToProperties = new Dictionary<int, List<int>>();
 
        public PropertyMap(string typeConfig, string placeConfig)
        {
            var json = JsonMapper.ToObject(typeConfig);
            foreach (var item in json.Keys)
            {
                var type = (LegendAttrType)(int.Parse(item) - 1);
                var propertyId = 0;
                int.TryParse(json[item].ToString(), out propertyId);
                propertyTypes[propertyId] = type;
            }
 
            json = JsonMapper.ToObject(placeConfig);
            foreach (var key in json.Keys)
            {
                var equipPlace = int.Parse(key);
                var properties = new List<int>();
                placeToProperties.Add(equipPlace, properties);
 
                if (json[key].IsArray)
                {
                    var subJson = json[key];
                    for (var i = 0; i < subJson.Count; i++)
                    {
                        if (subJson[i].IsArray)
                        {
                            for (var j = 0; j < subJson[i].Count; j++)
                            {
                                var propertyId = (int)subJson[i][j];
                                properties.Add(propertyId);
                            }
                        }
                    }
                }
            }
        }
 
        public bool HasProperty(int propertyId)
        {
            return propertyTypes.ContainsKey(propertyId);
        }
 
        public LegendAttrType GetPropertyType(int propertyId)
        {
            if (HasProperty(propertyId))
            {
                return propertyTypes[propertyId];
            }
            else
            {
                return LegendAttrType.Normal;
            }
        }
 
        public bool HasPlace(int place)
        {
            return placeToProperties.ContainsKey(place);
        }
 
        public List<int> GetProperties(int place)
        {
            if (HasPlace(place))
            {
                return placeToProperties[place];
            }
            else
            {
                return null;
            }
        }
 
        public List<int> GetProperties(int place, LegendAttrType type)
        {
            if (!HasPlace(place))
            {
                return null;
            }
 
            var allProperties = placeToProperties[place];
            var properties = new List<int>();
            for (var i = 0; i < allProperties.Count; i++)
            {
                var propertyId = allProperties[i];
                if (propertyTypes[propertyId] == type)
                {
                    properties.Add(propertyId);
                }
            }
 
            return properties;
        }
 
    }
 
    public class PropertyCount
    {
        Dictionary<int, StarPropertyCount> qualityToStarLegendPropertyCounts = new Dictionary<int, StarPropertyCount>();
 
        public PropertyCount(string config)
        {
            var json = JsonMapper.ToObject(config);
            foreach (var key in json.Keys)
            {
                var quality = int.Parse(key);
                qualityToStarLegendPropertyCounts[quality] = new StarPropertyCount(json[key]);
            }
        }
 
        public bool Has(int quality)
        {
            return qualityToStarLegendPropertyCounts.ContainsKey(quality);
        }
 
        public bool Has(int quality, int star)
        {
            if (!qualityToStarLegendPropertyCounts.ContainsKey(quality))
            {
                return false;
            }
 
            return qualityToStarLegendPropertyCounts[quality].Has(star);
        }
 
        public int GetCount(int quality, int star, LegendAttrType type)
        {
            if (!Has(quality, star))
            {
                return 0;
            }
 
            return qualityToStarLegendPropertyCounts[quality].GetCount(star, type);
        }
 
        class StarPropertyCount
        {
            Dictionary<int, Dictionary<LegendAttrType, int>> counts = new Dictionary<int, Dictionary<LegendAttrType, int>>();
 
            public StarPropertyCount(JsonData json)
            {
                foreach (var key in json.Keys)
                {
                    var star = int.Parse(key);
                    var typeCounts = counts[star] = new Dictionary<LegendAttrType, int>();
                    var subJson = json[key];
 
                    if (subJson.IsArray)
                    {
                        for (int i = 0; i < subJson.Count; i++)
                        {
                            var type = (LegendAttrType)(i);
                            typeCounts[type] = (int)subJson[i];
                        }
                    }
                }
            }
 
            public bool Has(int star)
            {
                return counts.ContainsKey(star);
            }
 
            public int GetCount(int star, LegendAttrType type)
            {
                if (!counts.ContainsKey(star))
                {
                    return 0;
                }
 
                if (!counts[star].ContainsKey(type))
                {
                    return 0;
                }
 
                return counts[star][type];
            }
 
        }
    }
 
    public class QualityPropertyValue
    {
        // key 属性ID value 装备品质,属性数值
        Dictionary<int, Dictionary<int, int>> qualityValues = new Dictionary<int, Dictionary<int, int>>();
 
        public QualityPropertyValue(string config)
        {
            var json = JsonMapper.ToObject(config);
            foreach (var key in json.Keys)
            {
                var propertyId = int.Parse(key);
                var qualityToValue = new Dictionary<int, int>();
                qualityValues.Add(propertyId, qualityToValue);
 
                var subJson = json[key];
                for (var i = 0; i < subJson.Count; i++)
                {
                    qualityToValue[(int)subJson[i][0]] = (int)subJson[i][1];
                }
            }
        }
 
        public bool Has(int property)
        {
            return qualityValues.ContainsKey(property);
        }
 
        public bool Has(int property, int quality)
        {
            if (!qualityValues.ContainsKey(property))
            {
                return false;
            }
 
            return qualityValues[property].ContainsKey(property);
        }
 
        public int GetValue(int property, int quality)
        {
            if (Has(property, quality))
            {
                return qualityValues[property][quality];
            }
            else
            {
                return 0;
            }
        }
    }
 
    public class WingPropertyCount
    {
        Dictionary<int, int> counts = new Dictionary<int, int>();
 
        public WingPropertyCount()
        {
            var json = JsonMapper.ToObject(FuncConfigConfig.Get("WingLegendAttrCountPreview").Numerical1);
            for (int i = 0; i < json.Count; i++)
            {
                counts[(int)json[i][0]] = (int)json[i][1];
            }
        }
 
        public bool Has(int level)
        {
            return counts.ContainsKey(level);
        }
 
        public int GetValue(int level)
        {
            if (Has(level))
            {
                return counts[level];
            }
            else
            {
                return 0;
            }
        }
 
    }
 
    public class WingPropertyValue
    {
        Dictionary<int, Dictionary<int, List<int>>> levelPropertyValues = new Dictionary<int, Dictionary<int, List<int>>>();
 
        public WingPropertyValue()
        {
            var json = JsonMapper.ToObject(FuncConfigConfig.Get("WingLegendAttrValuePreview").Numerical1);
            foreach (var key in json.Keys)
            {
                var levelValues = new Dictionary<int, List<int>>();
                levelPropertyValues.Add(int.Parse(key), levelValues);
 
                var subJson = json[key];
                foreach (var propertyId in subJson.Keys)
                {
                    var count = subJson[propertyId].Count;
                    var values = new List<int>();
                    levelValues[int.Parse(propertyId)] = values;
 
                    if (subJson[propertyId].IsArray)
                    {
                        for (var i = 0; i < subJson[propertyId].Count; i++)
                        {
                            values.Add((int)subJson[propertyId][i]);
                        }
                    }
 
                }
            }
        }
 
        public bool Has(int level)
        {
            return levelPropertyValues.ContainsKey(level);
        }
 
        public bool Has(int level, int propertyId)
        {
            if (!levelPropertyValues.ContainsKey(level))
            {
                return false;
            }
 
            return levelPropertyValues[level].ContainsKey(propertyId);
        }
 
        public int GetMin(int level, int propertyId)
        {
            if (Has(level, propertyId))
            {
                return levelPropertyValues[level][propertyId][0];
            }
            else
            {
                return 0;
            }
        }
 
        public int GetMax(int level, int propertyId)
        {
            if (Has(level, propertyId))
            {
                var count = levelPropertyValues[level][propertyId].Count;
                return levelPropertyValues[level][propertyId][count - 1];
            }
            else
            {
                return 0;
            }
        }
 
        public List<int> GetProperties(int level)
        {
            if (Has(level))
            {
                return new List<int>(levelPropertyValues[level].Keys);
            }
            else
            {
                return null;
            }
        }
 
        public List<int> GetValues(int level, int propertyId)
        {
            if (Has(level, propertyId))
            {
                return levelPropertyValues[level][propertyId];
            }
            else
            {
                return null;
            }
        }
 
    }
}