Commit e442cd3352c3d1e43683cea5e0e3650eac76649e

Authored by 王家文
1 parent 271b3b29
Exists in master and in 1 other branch dev-wjw

feat✨:房间排行活动配置

configs/conf-cardholder.go
... ... @@ -47,14 +47,14 @@ type CardActivityConfigRaw struct {
47 47 EndTime int64 // 结束时间
48 48 Round int // 轮数
49 49  
50   - Awards string `json:"-"` // 奖励配置
51   - AlbumConfig string `json:"-"` // 卡组配置
52   - CardConfig string `json:"-"` // 卡牌配置
53   - CardHolderConfig string `json:"-"` // 卡包开卡规则
54   - NormalCardStarSequence string `json:"-"` // 卡片星级配置
55   - CardSequenceConfig string `json:"-"` // 卡片星级对应卡牌配置
56   - StarShopConfig string `json:"-"` // 星星商店配置
57   -
  50 + Awards string // 奖励配置
  51 + AlbumConfig string // 卡组配置
  52 + CardConfig string // 卡牌配置
  53 + CardHolderConfig string // 卡包开卡规则
  54 + NormalCardStarSequence string // 卡片星级配置
  55 + CardSequenceConfig string // 卡片星级对应卡牌配置
  56 + StarShopConfig string // 星星商店配置
  57 +
58 58 Ver string // 版本号
59 59 Status int // 状态 0=关闭 1=开启
60 60 UpdateTime int64 // 修改时间戳
... ...
configs/conf-roomrank-decode.go
... ... @@ -17,8 +17,9 @@ func (c *RoomRankConfig) Decode(gameId string, configRaw *RoomRankConfigRaw) {
17 17 c.EndTime = configRaw.EndTime
18 18  
19 19 c.Robot = make(map[int]RoomRankRobotConfig)
  20 + c.Room = make(map[int]RoomRankRoomConfig)
20 21  
21   - // 解析机器人
  22 + // 解析 机器人
22 23 {
23 24 configs := make([]RoomRankRobotConfig, 0)
24 25 err := json.Unmarshal([]byte(configRaw.Robot), &configs)
... ... @@ -30,7 +31,18 @@ func (c *RoomRankConfig) Decode(gameId string, configRaw *RoomRankConfigRaw) {
30 31 c.Robot[i2.Id] = i2
31 32 }
32 33 }
33   -
  34 + // 解析 房间
  35 + {
  36 + configs := make([]RoomRankRoomConfig, 0)
  37 + err := json.Unmarshal([]byte(configRaw.Room), &configs)
  38 + if err != nil {
  39 + lxalilog.Errors(err, configRaw.Room, gameId, configRaw.Id)
  40 + return
  41 + }
  42 + for _, i2 := range configs {
  43 + c.Room[i2.Id] = i2
  44 + }
  45 + }
34 46 c.GenerateConfigClient()
35 47 }
36 48  
... ...
configs/conf-roomrank.go
... ... @@ -18,6 +18,7 @@ type RoomRankConfig struct {
18 18 EndTime int64 // 结束时间
19 19  
20 20 Robot map[int]RoomRankRobotConfig // 机器人配置
  21 + Room map[int]RoomRankRoomConfig // 房间配置
21 22  
22 23 Client *RoomRankConfigClient
23 24 GameId string // 所属游戏ID
... ... @@ -39,7 +40,8 @@ type RoomRankConfigRaw struct {
39 40 StartTime int64 // 开始时间
40 41 EndTime int64 // 结束时间
41 42  
42   - Robot string `json:"-"` // 机器人配置
  43 + Robot string // 机器人配置
  44 + Room string // 房间配置
43 45  
44 46 Ver string // 版本号
45 47 Status int // 状态 0=关闭 1=开启
... ... @@ -66,3 +68,18 @@ type RoomRankRobotConfig struct {
66 68 TotalScore int `json:"total_score"` // 总分数
67 69 TotalRate int `json:"total_rate"` // 总分浮动范围(%)
68 70 }
  71 +
  72 +// RoomRankRoomConfig 房间配置
  73 +type RoomRankRoomConfig struct {
  74 + Id int `json:"id"` // id
  75 + Levels []int `json:"levels"` // 等级范围
  76 + UserClass int `json:"user_class"` // 评级
  77 + UserScore []int `json:"user_score"` // 分数范围
  78 + TotalPlayer int `json:"total_player"` // 房间总人数
  79 + PlayerTypeCount [][]int `json:"player_type_count"` // 玩家类型数量
  80 + AutoRobot []int `json:"auto_robot"` // 自动填充机器人
  81 + InitRobot [][]int `json:"init_robot"` // 配置机器人
  82 + Awards []string `json:"awards"` // 奖励
  83 + SettleScores []int `json:"settle_scores"` // 结算分数调整
  84 + SettleUserType []int `json:"settle_user_type"` // 结算用户类型
  85 +}
... ...
configs/registry.go
... ... @@ -80,6 +80,7 @@ func GetRoomRankConfig(gameId string) (conf *RoomRankConfig, has bool) {
80 80  
81 81 fmt.Println("dwjw GetRoomRankConfig save cache")
82 82 fmt.Println("dwjw🐸", conf.Robot)
  83 + fmt.Println("dwjw🐸", conf.Room)
83 84 svredis.SaveData(gameId, conf)
84 85  
85 86 return
... ...
controllers/demo.go
... ... @@ -45,6 +45,27 @@ func (c *DemoController) Demo() {
45 45 })
46 46 fmt.Println(zjson.Str(list))
47 47 }
  48 + {
  49 + list := make([]configs.RoomRankRoomConfig, 0)
  50 + {
  51 + room := configs.RoomRankRoomConfig{}
  52 + room.Id = 1
  53 + room.Levels = []int{1, 9999}
  54 + room.UserClass = 0
  55 + room.UserScore = []int{0, 0}
  56 + room.TotalPlayer = 50
  57 + room.PlayerTypeCount = [][]int{{0, 5}}
  58 + room.AutoRobot = []int{1}
  59 + room.InitRobot = [][]int{{1, 5}, {2, 10}, {3, 30}}
  60 + for i := 0; i < 50; i++ {
  61 + room.Awards = append(room.Awards, "award")
  62 + room.SettleScores = append(room.SettleScores, 50-i)
  63 + room.SettleUserType = append(room.SettleUserType, 1)
  64 + }
  65 + list = append(list, room)
  66 + }
  67 + fmt.Println(zjson.Str(list))
  68 + }
48 69  
49 70 c.RetRspCodeData(code_msg.RECODE_OK, rsp)
50 71 }
... ...