From e442cd3352c3d1e43683cea5e0e3650eac76649e Mon Sep 17 00:00:00 2001 From: 王家文 Date: Thu, 18 Apr 2024 11:51:14 +0800 Subject: [PATCH] feat✨:房间排行活动配置 --- configs/conf-cardholder.go | 16 ++++++++-------- configs/conf-roomrank-decode.go | 16 ++++++++++++++-- configs/conf-roomrank.go | 19 ++++++++++++++++++- configs/registry.go | 1 + controllers/demo.go | 21 +++++++++++++++++++++ 5 files changed, 62 insertions(+), 11 deletions(-) diff --git a/configs/conf-cardholder.go b/configs/conf-cardholder.go index 783b487..a586abd 100644 --- a/configs/conf-cardholder.go +++ b/configs/conf-cardholder.go @@ -47,14 +47,14 @@ type CardActivityConfigRaw struct { EndTime int64 // 结束时间 Round int // 轮数 - Awards string `json:"-"` // 奖励配置 - AlbumConfig string `json:"-"` // 卡组配置 - CardConfig string `json:"-"` // 卡牌配置 - CardHolderConfig string `json:"-"` // 卡包开卡规则 - NormalCardStarSequence string `json:"-"` // 卡片星级配置 - CardSequenceConfig string `json:"-"` // 卡片星级对应卡牌配置 - StarShopConfig string `json:"-"` // 星星商店配置 - + Awards string // 奖励配置 + AlbumConfig string // 卡组配置 + CardConfig string // 卡牌配置 + CardHolderConfig string // 卡包开卡规则 + NormalCardStarSequence string // 卡片星级配置 + CardSequenceConfig string // 卡片星级对应卡牌配置 + StarShopConfig string // 星星商店配置 + Ver string // 版本号 Status int // 状态 0=关闭 1=开启 UpdateTime int64 // 修改时间戳 diff --git a/configs/conf-roomrank-decode.go b/configs/conf-roomrank-decode.go index a96bb7a..38fb0fd 100644 --- a/configs/conf-roomrank-decode.go +++ b/configs/conf-roomrank-decode.go @@ -17,8 +17,9 @@ func (c *RoomRankConfig) Decode(gameId string, configRaw *RoomRankConfigRaw) { c.EndTime = configRaw.EndTime c.Robot = make(map[int]RoomRankRobotConfig) + c.Room = make(map[int]RoomRankRoomConfig) - // 解析机器人 + // 解析 机器人 { configs := make([]RoomRankRobotConfig, 0) err := json.Unmarshal([]byte(configRaw.Robot), &configs) @@ -30,7 +31,18 @@ func (c *RoomRankConfig) Decode(gameId string, configRaw *RoomRankConfigRaw) { c.Robot[i2.Id] = i2 } } - + // 解析 房间 + { + configs := make([]RoomRankRoomConfig, 0) + err := json.Unmarshal([]byte(configRaw.Room), &configs) + if err != nil { + lxalilog.Errors(err, configRaw.Room, gameId, configRaw.Id) + return + } + for _, i2 := range configs { + c.Room[i2.Id] = i2 + } + } c.GenerateConfigClient() } diff --git a/configs/conf-roomrank.go b/configs/conf-roomrank.go index 08bd587..5acdbf2 100644 --- a/configs/conf-roomrank.go +++ b/configs/conf-roomrank.go @@ -18,6 +18,7 @@ type RoomRankConfig struct { EndTime int64 // 结束时间 Robot map[int]RoomRankRobotConfig // 机器人配置 + Room map[int]RoomRankRoomConfig // 房间配置 Client *RoomRankConfigClient GameId string // 所属游戏ID @@ -39,7 +40,8 @@ type RoomRankConfigRaw struct { StartTime int64 // 开始时间 EndTime int64 // 结束时间 - Robot string `json:"-"` // 机器人配置 + Robot string // 机器人配置 + Room string // 房间配置 Ver string // 版本号 Status int // 状态 0=关闭 1=开启 @@ -66,3 +68,18 @@ type RoomRankRobotConfig struct { TotalScore int `json:"total_score"` // 总分数 TotalRate int `json:"total_rate"` // 总分浮动范围(%) } + +// RoomRankRoomConfig 房间配置 +type RoomRankRoomConfig struct { + Id int `json:"id"` // id + Levels []int `json:"levels"` // 等级范围 + UserClass int `json:"user_class"` // 评级 + UserScore []int `json:"user_score"` // 分数范围 + TotalPlayer int `json:"total_player"` // 房间总人数 + PlayerTypeCount [][]int `json:"player_type_count"` // 玩家类型数量 + AutoRobot []int `json:"auto_robot"` // 自动填充机器人 + InitRobot [][]int `json:"init_robot"` // 配置机器人 + Awards []string `json:"awards"` // 奖励 + SettleScores []int `json:"settle_scores"` // 结算分数调整 + SettleUserType []int `json:"settle_user_type"` // 结算用户类型 +} diff --git a/configs/registry.go b/configs/registry.go index 90149a7..80e6a62 100644 --- a/configs/registry.go +++ b/configs/registry.go @@ -80,6 +80,7 @@ func GetRoomRankConfig(gameId string) (conf *RoomRankConfig, has bool) { fmt.Println("dwjw GetRoomRankConfig save cache") fmt.Println("dwjw🐸", conf.Robot) + fmt.Println("dwjw🐸", conf.Room) svredis.SaveData(gameId, conf) return diff --git a/controllers/demo.go b/controllers/demo.go index ec8c978..d9ffd69 100644 --- a/controllers/demo.go +++ b/controllers/demo.go @@ -45,6 +45,27 @@ func (c *DemoController) Demo() { }) fmt.Println(zjson.Str(list)) } + { + list := make([]configs.RoomRankRoomConfig, 0) + { + room := configs.RoomRankRoomConfig{} + room.Id = 1 + room.Levels = []int{1, 9999} + room.UserClass = 0 + room.UserScore = []int{0, 0} + room.TotalPlayer = 50 + room.PlayerTypeCount = [][]int{{0, 5}} + room.AutoRobot = []int{1} + room.InitRobot = [][]int{{1, 5}, {2, 10}, {3, 30}} + for i := 0; i < 50; i++ { + room.Awards = append(room.Awards, "award") + room.SettleScores = append(room.SettleScores, 50-i) + room.SettleUserType = append(room.SettleUserType, 1) + } + list = append(list, room) + } + fmt.Println(zjson.Str(list)) + } c.RetRspCodeData(code_msg.RECODE_OK, rsp) } -- libgit2 0.21.0