config-registry.go
3.49 KB
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
package ht_cardholder
import (
"apigame/lx-util/lxalilog"
"apigame/service/constd"
"encoding/json"
"errors"
)
var (
Registry RegistryConfigs // 卡牌活动配置
)
// RegistryConfigs 卡牌活动配置
type RegistryConfigs struct {
ConfigRaws CardActivityConfigRaw // 活动配置 原始数据
Config CardActivityConfig // 活动配置 分析后数据
}
func NewRegistryConfigs() {
Registry = RegistryConfigs{}
}
// Decode 解析配置原始数据
func (r *RegistryConfigs) Decode(confRaw CardActivityConfigRaw) {
conf := CardActivityConfig{
Raw: confRaw,
Id: confRaw.Id,
Awards: make(map[string]string),
AlbumConfig: make(map[string]AlbumConfig),
CardConfig: make(map[int]CardConfig),
CardholderConfig: make(map[string]CardholderConfig),
NormalCardStarSequence: make([]NormalCardStarSequence, 0),
CardSequenceConfig: make([]CardSequenceConfig, 0),
}
// 解析奖励
{
err := json.Unmarshal([]byte(confRaw.Awards), &conf.Awards)
if err != nil {
lxalilog.Errors(err, confRaw.Awards, constd.GAME_ID_HT, confRaw.Id)
return
}
}
// 卡组配置
{
configs := make([]AlbumConfig, 0)
err := json.Unmarshal([]byte(confRaw.AlbumConfig), &configs)
if err != nil {
lxalilog.Errors(err, confRaw.AlbumConfig, constd.GAME_ID_HT, confRaw.Id)
return
}
for _, i2 := range configs {
conf.AlbumConfig[i2.SetId] = i2
}
}
// 卡牌配置
{
configs := make([]CardConfig, 0)
err := json.Unmarshal([]byte(confRaw.CardConfig), &configs)
if err != nil {
lxalilog.Errors(err, confRaw.CardConfig, constd.GAME_ID_HT, confRaw.Id)
return
}
for _, i2 := range configs {
conf.CardConfig[i2.Id] = i2
}
}
// 卡包开卡规则
{
configs := make([]CardholderConfig, 0)
err := json.Unmarshal([]byte(confRaw.CardHolderConfig), &configs)
if err != nil {
lxalilog.Errors(err, confRaw.CardHolderConfig, constd.GAME_ID_HT, confRaw.Id)
return
}
for _, i2 := range configs {
conf.CardholderConfig[i2.Id] = i2
}
}
// 卡片星级配置
{
configs := make([]NormalCardStarSequence, 0)
err := json.Unmarshal([]byte(confRaw.NormalCardStarSequence), &configs)
if err != nil {
lxalilog.Errors(err, confRaw.NormalCardStarSequence, constd.GAME_ID_HT, confRaw.Id)
return
}
for _, i2 := range configs {
conf.NormalCardStarSequence = append(conf.NormalCardStarSequence, i2)
}
}
// 卡片星级对应卡牌配置
{
configs := make([]CardSequenceConfig, 0)
err := json.Unmarshal([]byte(confRaw.CardSequenceConfig), &configs)
if err != nil {
lxalilog.Errors(err, confRaw.CardSequenceConfig, constd.GAME_ID_HT, confRaw.Id)
return
}
for _, i2 := range configs {
conf.CardSequenceConfig = append(conf.CardSequenceConfig, i2)
}
}
r.Config = conf
//logs.Debug(conf.Awards)
//logs.Debug(conf.AlbumConfig)
//logs.Debug(conf.CardConfig)
//logs.Debug(conf.CardholderConfig)
//logs.Debug("🐸", conf.NormalCardStarSequence)
//logs.Debug("🐸", conf.CardSequenceConfig)
}
// FindCardSequenceConfig 查找配置 星级ID对应的卡片
func FindCardSequenceConfig(id, sequenceId, cohort string) (conf CardSequenceConfig, has bool) {
conf = CardSequenceConfig{}
has = false
for _, c := range Registry.Config.CardSequenceConfig {
if c.Id == id &&
c.SequenceId == sequenceId &&
c.Cohort == cohort {
has = true
return
}
}
if !has {
lxalilog.Errors(errors.New("ht_cardholder CardSequenceConfig error"), " LoadData Error", id, sequenceId, cohort)
}
return
}