Commit 0fc53fc003ec141725fe7bb57cfda5ac5e1167ee

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

feat✨:房间排行榜改为支持多个排行榜

configs/confroomrank/config.go
... ... @@ -108,15 +108,15 @@ type RobotConfig struct {
108 108  
109 109 // RoomConfig 房间配置
110 110 type RoomConfig struct {
111   - Id int `json:"id"` // id
112   - Levels []int `json:"level_range"` // 等级范围
113   - UserClass int `json:"rating"` // 评级
114   - UserScore []int `json:"score_range"` // 分数范围
115   - TotalPlayer int `json:"room_user_number"` // 房间总人数
116   - PlayerTypeCount [][]int `json:"user_type_number"` // 玩家类型数量
117   - AutoRobot []int `json:"auto_room"` // 自动填充机器人
118   - InitRobot [][]int `json:"disposition_robots"` // 配置机器人
119   - Awards map[string]string `json:"rewards"` // 奖励
120   - SettleScores []int `json:"score_adjest"` // 结算分数调整
121   - SettleUserType []int `json:"user_type"` // 结算用户类型
  111 + Id int `json:"id"` // id
  112 + Levels []int `json:"level_range"` // 等级范围
  113 + UserClass int `json:"rating"` // 评级
  114 + UserScore []int `json:"score_range"` // 分数范围
  115 + TotalPlayer int `json:"room_user_number"` // 房间总人数
  116 + PlayerTypeCount [][]int `json:"user_type_number"` // 玩家类型数量
  117 + AutoRobot []int `json:"auto_room"` // 自动填充机器人
  118 + InitRobot [][]int `json:"disposition_robots"` // 配置机器人
  119 + Awards []string `json:"rewards"` // 奖励
  120 + SettleScores []int `json:"score_adjest"` // 结算分数调整
  121 + SettleUserType []int `json:"user_type"` // 结算用户类型
122 122 }
... ...
service/roomrank/logic.go
... ... @@ -3,7 +3,6 @@ package roomrank
3 3 import (
4 4 "apigame/configs/confroomrank"
5 5 "apigame/service-common/svconst"
6   - "apigame/util/utstring"
7 6 "apigame/util/zjson"
8 7 "fmt"
9 8 )
... ... @@ -51,8 +50,8 @@ func TrySettle(gameId string, topType int, player *Player, config *confroomrank.
51 50 if !hasConfRoom {
52 51 return
53 52 }
54   - if confAward, hasConfAward := confRoom.Awards[utstring.IntToString(player.SettleRank)]; hasConfAward {
55   - player.SettleAward = confAward
  53 + if len(confRoom.Awards) > rankIndex {
  54 + player.SettleAward = confRoom.Awards[rankIndex]
56 55 }
57 56 if len(confRoom.SettleScores) > rankIndex {
58 57 player.AddUserScore(confRoom.SettleScores[rankIndex])
... ...
service/roomrank/player.go
... ... @@ -7,7 +7,6 @@ import (
7 7 "apigame/service-common/svmysql"
8 8 "apigame/util/util-lx/lxalilog"
9 9 "apigame/util/util-lx/lxtime"
10   - "apigame/util/utstring"
11 10 "math/rand"
12 11 )
13 12  
... ... @@ -101,8 +100,8 @@ func GetInfoFromRoom(player *Player, room *Room, config *confroomrank.ActivityCo
101 100 Icon: p.Icon,
102 101 }
103 102 if confRoom, hasConfRoom := config.Room[room.ConfigId]; hasConfRoom {
104   - if confAward, hasConfAward := confRoom.Awards[utstring.IntToString(rank)]; hasConfAward {
105   - node.Award = confAward
  103 + if len(confRoom.Awards) > i {
  104 + node.Award = confRoom.Awards[i]
106 105 }
107 106 }
108 107 if player.Uid == p.Uid {
... ...