conf-roomrank-decode.go
936 Bytes
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
package configs
import (
"apigame/util/util-lx/lxalilog"
"encoding/json"
)
// Decode 解析配置原始数据
func (c *RoomRankConfig) Decode(gameId string, configRaw *RoomRankConfigRaw) {
c.GameId = gameId
c.Raw = configRaw
c.Id = configRaw.Id
c.OpenLevel = configRaw.OpenLevel
c.PreviewTime = configRaw.PreviewTime
c.StartTime = configRaw.StartTime
c.EndTime = configRaw.EndTime
c.Robot = make(map[int]RoomRankRobotConfig)
// 解析机器人
{
configs := make([]RoomRankRobotConfig, 0)
err := json.Unmarshal([]byte(configRaw.Robot), &configs)
if err != nil {
lxalilog.Errors(err, configRaw.Robot, gameId, configRaw.Id)
return
}
for _, i2 := range configs {
c.Robot[i2.Id] = i2
}
}
c.GenerateConfigClient()
}
// GenerateConfigClient 生成给客户端的配置
func (c *RoomRankConfig) GenerateConfigClient() {
configClient := &RoomRankConfigClient{
Id: c.Id,
}
c.Client = configClient
}