package confroomrank import ( "apigame/util/util-lx/lxalilog" "encoding/json" ) // Decode 解析配置原始数据 func (c *ActivityConfig) Decode(gameId string, rawData any) { raw := rawData.(*ActivityConfigRaw) c.GameId = gameId c.Raw = raw c.Id = raw.Id c.Typ = raw.Typ c.OpenLevel = raw.OpenLevel c.OpenScore = raw.OpenScore c.PreviewTime = raw.PreviewTime c.StartTime = raw.StartTime c.EndTime = raw.EndTime c.ReleaseTime = raw.ReleaseTime c.Robot = make(map[int]RobotConfig) c.Room = make(map[int]RoomConfig) // 解析 机器人 { configs := make([]RobotConfig, 0) err := json.Unmarshal([]byte(raw.BootConfig), &configs) if err != nil { lxalilog.Errors(err, raw.BootConfig, gameId, raw.Id) return } for _, i2 := range configs { c.Robot[i2.Id] = i2 } } // 解析 房间 { configs := make([]RoomConfig, 0) err := json.Unmarshal([]byte(raw.RoomConfig), &configs) if err != nil { lxalilog.Errors(err, raw.RoomConfig, gameId, raw.Id) return } for _, i2 := range configs { c.Room[i2.Id] = i2 } } }