Commit 965e00db4a6136e99067608a9a52ec34b37cdd08
1 parent
a7c3578e
Exists in
master
and in
1 other branch
fix🐛:一些配置ID从string改为int类型
Showing
4 changed files
with
42 additions
and
48 deletions
Show diff stats
configs/confcardholder/config.go
| ... | ... | @@ -115,31 +115,29 @@ type CardConfig struct { |
| 115 | 115 | |
| 116 | 116 | // OpenCardholderConfig 卡包开卡规则表 |
| 117 | 117 | type OpenCardholderConfig struct { |
| 118 | - Id int `json:"id"` // ID | |
| 119 | - IsGoldCardholder int `json:"is_gold_card_holder"` // 是否是金卡包 | |
| 120 | - IsNew int `json:"is_new"` // 是否是新卡包 | |
| 121 | - GuaranteedStarCardId string `json:"guaranteed_star_card_id"` // 保底卡星级序列ID | |
| 122 | - NormalCardNumber int `json:"normal_card_number"` // 非保底卡数量 | |
| 123 | - MinimumGuaranteeCardId string `json:"minimum_guarantee_card_id"` // 非保底卡牌序列ID | |
| 124 | - ActivityId int `json:"activity_id"` // 对应活动ID | |
| 118 | + Id int `json:"id"` // ID | |
| 119 | + IsGoldCardholder int `json:"is_gold_card_holder"` // 是否是金卡包 | |
| 120 | + IsNew int `json:"is_new"` // 是否是新卡包 | |
| 121 | + GuaranteedStarCardId int `json:"guaranteed_star_card_id"` // 保底卡星级序列ID | |
| 122 | + NormalCardNumber int `json:"normal_card_number"` // 非保底卡数量 | |
| 123 | + MinimumGuaranteeCardId int `json:"minimum_guarantee_card_id"` // 非保底卡牌序列ID | |
| 124 | + ActivityId int `json:"activity_id"` // 对应活动ID | |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // NormalCardStarConfig 非保底卡星级ID |
| 128 | 128 | type NormalCardStarConfig struct { |
| 129 | - Id string `json:"id"` // ID | |
| 130 | - SequenceId string `json:"user_sequence_id"` // 用户序列组ID | |
| 131 | - Cohort string `json:"cohort"` // 用户分组 | |
| 132 | - NormalCardSequenceId string `json:"normal_card_sequence_id"` // 非保底星级序列 | |
| 133 | - NormalCardSequenceIds []string `json:"normal_card_sequence_ids"` // 非保底星级序列 | |
| 129 | + Id int `json:"id"` // ID | |
| 130 | + SequenceId int `json:"user_sequence_id"` // 用户序列组ID | |
| 131 | + Cohort int `json:"cohort"` // 用户分组 | |
| 132 | + NormalCardSequenceId []int `json:"normal_card_sequence_id"` // 非保底星级序列 | |
| 134 | 133 | } |
| 135 | 134 | |
| 136 | 135 | // CardSequenceConfig 星级ID对应的卡片 |
| 137 | 136 | type CardSequenceConfig struct { |
| 138 | - Id string `json:"id"` // ID | |
| 139 | - SequenceId string `json:"user_sequence_id"` // 用户序列组ID | |
| 140 | - Cohort string `json:"cohort"` // 用户分组 | |
| 141 | - CardIdList string `json:"card_id_list"` // 卡牌抽取序列 | |
| 142 | - CardIdLists []string `json:"card_id_lists"` // 卡牌抽取序列 | |
| 137 | + Id int `json:"id"` // ID | |
| 138 | + SequenceId int `json:"user_sequence_id"` // 用户序列组ID | |
| 139 | + Cohort int `json:"cohort"` // 用户分组 | |
| 140 | + CardIdList []int `json:"card_id_list"` // 卡牌抽取序列 | |
| 143 | 141 | } |
| 144 | 142 | |
| 145 | 143 | // StarShopConfig 星星商店配置 | ... | ... |
configs/confcardholder/decode.go
| ... | ... | @@ -5,7 +5,6 @@ import ( |
| 5 | 5 | "encoding/json" |
| 6 | 6 | "errors" |
| 7 | 7 | "fmt" |
| 8 | - "strings" | |
| 9 | 8 | ) |
| 10 | 9 | |
| 11 | 10 | // Decode 解析配置原始数据 |
| ... | ... | @@ -82,7 +81,6 @@ func (c *ActivityConfig) Decode(gameId string, rawData any) { |
| 82 | 81 | return |
| 83 | 82 | } |
| 84 | 83 | for _, i2 := range configs { |
| 85 | - i2.NormalCardSequenceIds = strings.Split(i2.NormalCardSequenceId, ",") | |
| 86 | 84 | combineId := CombineIdSequenceIdCohort(i2.Id, i2.SequenceId, i2.Cohort) |
| 87 | 85 | c.NormalCardStarConfig[combineId] = i2 |
| 88 | 86 | } |
| ... | ... | @@ -96,7 +94,6 @@ func (c *ActivityConfig) Decode(gameId string, rawData any) { |
| 96 | 94 | return |
| 97 | 95 | } |
| 98 | 96 | for _, i2 := range configs { |
| 99 | - i2.CardIdLists = strings.Split(i2.CardIdList, ",") | |
| 100 | 97 | combineId := CombineIdSequenceIdCohort(i2.Id, i2.SequenceId, i2.Cohort) |
| 101 | 98 | c.CardSequenceConfig[combineId] = i2 |
| 102 | 99 | } |
| ... | ... | @@ -144,12 +141,12 @@ func (c *ActivityConfig) GenerateConfigClient() { |
| 144 | 141 | } |
| 145 | 142 | |
| 146 | 143 | // CombineIdSequenceIdCohort 组合ID k=ID_用户序列_用户分组 |
| 147 | -func CombineIdSequenceIdCohort(id, sequenceId, cohort string) string { | |
| 144 | +func CombineIdSequenceIdCohort(id, sequenceId, cohort int) string { | |
| 148 | 145 | return fmt.Sprintf("%s_%s_%s", id, sequenceId, cohort) |
| 149 | 146 | } |
| 150 | 147 | |
| 151 | 148 | // FindNormalCardStarConfig 查找配置 非保底卡星级ID |
| 152 | -func (c *ActivityConfig) FindNormalCardStarConfig(id, sequenceId, cohort string) (conf NormalCardStarConfig, has bool) { | |
| 149 | +func (c *ActivityConfig) FindNormalCardStarConfig(id, sequenceId, cohort int) (conf NormalCardStarConfig, has bool) { | |
| 153 | 150 | combineId := CombineIdSequenceIdCohort(id, sequenceId, cohort) |
| 154 | 151 | conf, has = c.NormalCardStarConfig[combineId] |
| 155 | 152 | if !has { |
| ... | ... | @@ -159,7 +156,7 @@ func (c *ActivityConfig) FindNormalCardStarConfig(id, sequenceId, cohort string) |
| 159 | 156 | } |
| 160 | 157 | |
| 161 | 158 | // FindCardSequenceConfig 查找配置 星级ID对应的卡片 |
| 162 | -func (c *ActivityConfig) FindCardSequenceConfig(id, sequenceId, cohort string) (conf CardSequenceConfig, has bool) { | |
| 159 | +func (c *ActivityConfig) FindCardSequenceConfig(id, sequenceId, cohort int) (conf CardSequenceConfig, has bool) { | |
| 163 | 160 | combineId := CombineIdSequenceIdCohort(id, sequenceId, cohort) |
| 164 | 161 | conf, has = c.CardSequenceConfig[combineId] |
| 165 | 162 | if !has { | ... | ... |
service/cardholder/dto-record.go
| ... | ... | @@ -9,17 +9,17 @@ import ( |
| 9 | 9 | |
| 10 | 10 | // RecordBase 日志公共 |
| 11 | 11 | type RecordBase struct { |
| 12 | - Id int64 `gorm:"primaryKey;comment:日志ID"` | |
| 13 | - Uid int64 `gorm:"comment:玩家唯一ID"` | |
| 14 | - SequenceId string `gorm:"type:varchar(255);comment:用户序列组ID"` | |
| 15 | - Cohort string `gorm:"type:varchar(255);comment:用户分组ID"` | |
| 16 | - ActivityId int64 `gorm:"comment:当前活动ID"` | |
| 17 | - Round int `gorm:"comment:当前轮次"` | |
| 18 | - CreateTime int64 `gorm:"comment:创建时间戳"` | |
| 19 | - UpdateTime int64 `gorm:"comment:修改时间戳"` | |
| 12 | + Id int64 `gorm:"primaryKey;comment:日志ID"` | |
| 13 | + Uid int64 `gorm:"comment:玩家唯一ID"` | |
| 14 | + SequenceId int `gorm:"type:varchar(255);comment:用户序列组ID"` | |
| 15 | + Cohort int `gorm:"type:varchar(255);comment:用户分组ID"` | |
| 16 | + ActivityId int64 `gorm:"comment:当前活动ID"` | |
| 17 | + Round int `gorm:"comment:当前轮次"` | |
| 18 | + CreateTime int64 `gorm:"comment:创建时间戳"` | |
| 19 | + UpdateTime int64 `gorm:"comment:修改时间戳"` | |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -func NewRecordBase(uid int64, sequenceId string, cohort string, activityId int64, round int) RecordBase { | |
| 22 | +func NewRecordBase(uid int64, sequenceId int, cohort int, activityId int64, round int) RecordBase { | |
| 23 | 23 | secNow := lxtime.NowUninx() |
| 24 | 24 | return RecordBase{ |
| 25 | 25 | CreateTime: secNow, | ... | ... |
service/cardholder/logic.go
| ... | ... | @@ -38,18 +38,18 @@ func CheckGameData(d *Player, conf *confcardholder.ActivityConfig) string { |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // GetUserSequenceIdAndCohort 获取 用户序列组ID(sequenceId) 用户分组(cohort) |
| 41 | -func GetUserSequenceIdAndCohort(uid int64) (sequenceId, cohort string) { | |
| 41 | +func GetUserSequenceIdAndCohort(uid int64) (sequenceId, cohort int) { | |
| 42 | 42 | // todo 这里后续要对接 用户序列组ID(sequenceId) 用户分组(cohort) |
| 43 | - sequenceId = "1" | |
| 44 | - cohort = "1" | |
| 43 | + sequenceId = 1 | |
| 44 | + cohort = 1 | |
| 45 | 45 | return |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // GetOneFromArray 从配置的数组里获取一个值 scale=之前刻度 |
| 49 | -func GetOneFromArray(array []string, scale int) string { | |
| 49 | +func GetOneFromArray(array []int, scale int) int { | |
| 50 | 50 | length := len(array) |
| 51 | 51 | if length < 1 { |
| 52 | - return "" | |
| 52 | + return 0 | |
| 53 | 53 | } |
| 54 | 54 | if length == 1 { |
| 55 | 55 | return array[0] |
| ... | ... | @@ -58,8 +58,8 @@ func GetOneFromArray(array []string, scale int) string { |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // GetListFromArray 从配置的数组里获取一组值 scale=之前刻度 count=数目 |
| 61 | -func GetListFromArray(array []string, scale, count int) []string { | |
| 62 | - list := make([]string, 0) | |
| 61 | +func GetListFromArray(array []int, scale, count int) []int { | |
| 62 | + list := make([]int, 0) | |
| 63 | 63 | if count < 0 { |
| 64 | 64 | return list |
| 65 | 65 | } |
| ... | ... | @@ -144,7 +144,7 @@ func DoOpen(gameId string, |
| 144 | 144 | player *Player, |
| 145 | 145 | config *confcardholder.ActivityConfig, |
| 146 | 146 | confCardholder confcardholder.OpenCardholderConfig, |
| 147 | - sequenceId, cohort string, | |
| 147 | + sequenceId, cohort int, | |
| 148 | 148 | openMode int) (newCards []int) { |
| 149 | 149 | |
| 150 | 150 | newCards = make([]int, 0) |
| ... | ... | @@ -156,23 +156,22 @@ func DoOpen(gameId string, |
| 156 | 156 | player.Details.Cards[cardId] += 1 |
| 157 | 157 | newCards = append(newCards, cardId) |
| 158 | 158 | } else { |
| 159 | - getCardFunc := func(cardConfigId string) { | |
| 159 | + getCardFunc := func(cardConfigId int) { | |
| 160 | 160 | confCardSequence, hasCardSequence := config.FindCardSequenceConfig(cardConfigId, sequenceId, cohort) |
| 161 | 161 | if hasCardSequence { |
| 162 | 162 | combineId := confcardholder.CombineIdSequenceIdCohort(cardConfigId, sequenceId, cohort) |
| 163 | 163 | scale := player.Details.CardSequenceScales[combineId] |
| 164 | - cardId := GetOneFromArray(confCardSequence.CardIdLists, scale) | |
| 165 | - cardIdInt := utstring.StringToInt(cardId) | |
| 164 | + cardId := GetOneFromArray(confCardSequence.CardIdList, scale) | |
| 166 | 165 | // 增加刻度 |
| 167 | 166 | player.Details.CardSequenceScales[combineId] = scale + 1 |
| 168 | 167 | // 增加卡牌 |
| 169 | - player.Details.Cards[cardIdInt] += 1 | |
| 170 | - newCards = append(newCards, cardIdInt) | |
| 168 | + player.Details.Cards[cardId] += 1 | |
| 169 | + newCards = append(newCards, cardId) | |
| 171 | 170 | } |
| 172 | 171 | } |
| 173 | 172 | // 正常抽卡 |
| 174 | 173 | // 先抽保底卡 |
| 175 | - if confCardholder.GuaranteedStarCardId != "0" { | |
| 174 | + if confCardholder.GuaranteedStarCardId != 0 { | |
| 176 | 175 | getCardFunc(confCardholder.GuaranteedStarCardId) |
| 177 | 176 | } |
| 178 | 177 | // 非保底卡 |
| ... | ... | @@ -182,7 +181,7 @@ func DoOpen(gameId string, |
| 182 | 181 | if hasNormalCardStar { |
| 183 | 182 | combineIdStar := confcardholder.CombineIdSequenceIdCohort(confCardholder.MinimumGuaranteeCardId, sequenceId, cohort) |
| 184 | 183 | scaleStar := player.Details.StarSequenceScales[combineIdStar] |
| 185 | - starIds := GetListFromArray(confNormalCardStar.NormalCardSequenceIds, scaleStar, count) | |
| 184 | + starIds := GetListFromArray(confNormalCardStar.NormalCardSequenceId, scaleStar, count) | |
| 186 | 185 | // 增加星级刻度 |
| 187 | 186 | player.Details.StarSequenceScales[combineIdStar] = scaleStar + count |
| 188 | 187 | // 遍历星级刻度抽取n张卡牌 |
| ... | ... | @@ -207,7 +206,7 @@ func DoOpen(gameId string, |
| 207 | 206 | func DoOpenCheckAward(gameId string, |
| 208 | 207 | player *Player, |
| 209 | 208 | config *confcardholder.ActivityConfig, |
| 210 | - sequenceId, cohort string, | |
| 209 | + sequenceId, cohort int, | |
| 211 | 210 | newCards []int, |
| 212 | 211 | openMode int) (awardAlbum map[int]string, awardRound string) { |
| 213 | 212 | ... | ... |