diff --git a/configs/confroomrank/config.go b/configs/confroomrank/config.go index 54d718d..b639e9a 100644 --- a/configs/confroomrank/config.go +++ b/configs/confroomrank/config.go @@ -17,6 +17,7 @@ type ActivityConfig struct { PreviewTime int64 // 预告时间 StartTime int64 // 开始时间 EndTime int64 // 结束时间 + ReleaseTime int64 // 结算发奖时间 Robot map[int]RobotConfig // 机器人配置 Room map[int]RoomConfig // 房间配置 @@ -57,9 +58,10 @@ type ActivityConfigRaw struct { PreviewTime int64 // 预告时间 StartTime int64 // 开始时间 EndTime int64 // 结束时间 + ReleaseTime int64 // 结算发奖时间 - Robot string // 机器人配置 - Room string // 房间配置 + BootConfig string // 机器人配置 + RoomConfig string // 房间配置 Ver string // 版本号 Status int // 状态 0=关闭 1=开启 @@ -76,20 +78,20 @@ type RobotConfig struct { Id int `json:"id"` // id MinScore int `json:"min_score"` // 最低分数 TotalScore int `json:"total_score"` // 总分数 - TotalRate int `json:"total_rate"` // 总分浮动范围(%) + Range int `json:"range"` // 总分浮动范围(%) } // RoomConfig 房间配置 type RoomConfig 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"` // 结算用户类型 + Id int `json:"id"` // id + Levels []int `json:"level_range"` // 等级范围 + UserClass int `json:"rating"` // 评级 + UserScore []int `json:"score_range"` // 分数范围 + TotalPlayer int `json:"room_user_number"` // 房间总人数 + PlayerTypeCount [][]int `json:"user_type_number"` // 玩家类型数量 + AutoRobot []int `json:"auto_room"` // 自动填充机器人 + InitRobot [][]int `json:"disposition_robots"` // 配置机器人 + Awards map[string]string `json:"rewards"` // 奖励 + SettleScores []int `json:"score_adjest"` // 结算分数调整 + SettleUserType []int `json:"user_type"` // 结算用户类型 } diff --git a/configs/confroomrank/decode.go b/configs/confroomrank/decode.go index d004655..9ad5cb5 100644 --- a/configs/confroomrank/decode.go +++ b/configs/confroomrank/decode.go @@ -16,6 +16,7 @@ func (c *ActivityConfig) Decode(gameId string, rawData any) { 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) @@ -23,9 +24,9 @@ func (c *ActivityConfig) Decode(gameId string, rawData any) { // 解析 机器人 { configs := make([]RobotConfig, 0) - err := json.Unmarshal([]byte(raw.Robot), &configs) + err := json.Unmarshal([]byte(raw.BootConfig), &configs) if err != nil { - lxalilog.Errors(err, raw.Robot, gameId, raw.Id) + lxalilog.Errors(err, raw.BootConfig, gameId, raw.Id) return } for _, i2 := range configs { @@ -35,9 +36,9 @@ func (c *ActivityConfig) Decode(gameId string, rawData any) { // 解析 房间 { configs := make([]RoomConfig, 0) - err := json.Unmarshal([]byte(raw.Room), &configs) + err := json.Unmarshal([]byte(raw.RoomConfig), &configs) if err != nil { - lxalilog.Errors(err, raw.Room, gameId, raw.Id) + lxalilog.Errors(err, raw.RoomConfig, gameId, raw.Id) return } for _, i2 := range configs { diff --git a/controllers/demo.go b/controllers/demo.go index ea8b8ec..cb602f2 100644 --- a/controllers/demo.go +++ b/controllers/demo.go @@ -1,11 +1,9 @@ package controllers import ( - "apigame/configs/confroomrank" "apigame/models" "apigame/service/code-msg" "apigame/util/util-lx/lxalilog" - "apigame/util/zjson" "fmt" ) @@ -26,50 +24,6 @@ func (c *DemoController) Demo() { lxalilog.Errors("DemoController.demo") - { - list := make([]confroomrank.RobotConfig, 0) - list = append(list, confroomrank.RobotConfig{ - Id: 1, - MinScore: 10, - TotalScore: 30, - TotalRate: 10, - }) - list = append(list, confroomrank.RobotConfig{ - Id: 2, - MinScore: 20, - TotalScore: 50, - TotalRate: 6, - }) - list = append(list, confroomrank.RobotConfig{ - Id: 3, - MinScore: 50, - TotalScore: 200, - TotalRate: 5, - }) - fmt.Println(zjson.Str(list)) - } - { - list := make([]confroomrank.RoomConfig, 0) - { - room := confroomrank.RoomConfig{} - 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)) - } - //{ // gameId := "10149" // { diff --git a/service-common/svconst/mysql.go b/service-common/svconst/mysql.go index 4fb4769..ffaf4bc 100644 --- a/service-common/svconst/mysql.go +++ b/service-common/svconst/mysql.go @@ -17,7 +17,7 @@ const ( MYSQL_TABLE_S_CARDHOLDER_RECORD_REWARDALBUM = "s_cardholder_record_rewardalbum" // 开卡包活动日志领取卡组奖励 MYSQL_TABLE_S_CARDHOLDER_RECORD_REWARDROUND = "s_cardholder_record_rewardround" // 开卡包活动日志领取轮次奖励 - MYSQL_TABLE_S_ROOMRANK_CONFIG = "s_roomrank_activity" // 房间排行活动配置 - MYSQL_TABLE_S_ROOMRANK_PLAYER = "s_roomrank_player" // 房间排行玩家数据 - MYSQL_TABLE_S_ROOMRANK_ROOM = "s_roomrank_room" // 房间排行房间数据 + MYSQL_TABLE_S_ROOMRANK_CONFIG = "s_beach_rank_activity" // 房间排行活动配置 + MYSQL_TABLE_S_ROOMRANK_PLAYER = "s_roomrank_player" // 房间排行玩家数据 + MYSQL_TABLE_S_ROOMRANK_ROOM = "s_roomrank_room" // 房间排行房间数据 ) diff --git a/service/roomrank/logic.go b/service/roomrank/logic.go index cd51470..2ce5534 100644 --- a/service/roomrank/logic.go +++ b/service/roomrank/logic.go @@ -2,6 +2,9 @@ package roomrank import ( "apigame/configs/confroomrank" + "apigame/util/utstring" + "apigame/util/zjson" + "fmt" ) // TrySettle 尝试判断结算 @@ -16,6 +19,7 @@ func TrySettle(gameId string, player *Player, config *confroomrank.ActivityConfi if player.ActivityId == config.Id { return } + fmt.Println(zjson.Str(player)) // 查找玩家所在的房间 room, hasRoom := LoadRoom(gameId, player.ActivityId, player.RoomUid) if !hasRoom { @@ -38,8 +42,8 @@ func TrySettle(gameId string, player *Player, config *confroomrank.ActivityConfi if !hasConfRoom { return } - if len(confRoom.Awards) > rankIndex { - player.SettleAward = confRoom.Awards[rankIndex] + if confAward, hasConfAward := confRoom.Awards[utstring.IntToString(rankIndex)]; hasConfAward { + player.SettleAward = confAward } if len(confRoom.SettleScores) > rankIndex { player.AddUserScore(confRoom.SettleScores[rankIndex]) diff --git a/service/roomrank/room.go b/service/roomrank/room.go index 2e1ac39..ee5451b 100644 --- a/service/roomrank/room.go +++ b/service/roomrank/room.go @@ -270,7 +270,7 @@ func GetRobotScoreCurrent(config *confroomrank.ActivityConfig, confRobot *confro } score := (float64(confRobot.TotalScore-confRobot.MinScore) * - float64(100-confRobot.TotalRate+rand.Intn(confRobot.TotalRate*2)) / 100) * percent / 100 + float64(100-confRobot.Range+rand.Intn(confRobot.Range*2)) / 100) * percent / 100 result := int64(confRobot.MinScore) + int64(math.Ceil(score)) if result < int64(confRobot.MinScore) { result = int64(confRobot.MinScore) @@ -281,7 +281,7 @@ func GetRobotScoreCurrent(config *confroomrank.ActivityConfig, confRobot *confro // GetRobotScoreMax 从机器人配置里得到最高分 func GetRobotScoreMax(confRobot *confroomrank.RobotConfig) int64 { score := float64(confRobot.TotalScore-confRobot.MinScore) * - float64(100-confRobot.TotalRate+rand.Intn(confRobot.TotalRate*2)) / float64(100) + float64(100-confRobot.Range+rand.Intn(confRobot.Range*2)) / float64(100) result := int64(confRobot.MinScore) + int64(math.Ceil(score)) if result < int64(confRobot.MinScore) { result = int64(confRobot.MinScore) -- libgit2 0.21.0