Commit 823e90e6b9565bc0272e7a03e81f58abb25056fc
1 parent
d188444d
Exists in
master
feat✨:卡牌活动增加用户序列组ID
Showing
7 changed files
with
35 additions
and
13 deletions
Show diff stats
configs-db/confcardholder/config.go
| ... | ... | @@ -27,6 +27,7 @@ type ActivityConfig struct { |
| 27 | 27 | NormalCardStarConfig map[string]NormalCardStarConfig // k=ID_用户序列_用户分组 卡片星级配置 |
| 28 | 28 | CardSequenceConfig map[string]CardSequenceConfig // k=ID_用户序列_用户分组 卡片星级对应卡牌配置 |
| 29 | 29 | StarShopConfig map[int]StarShopConfig // 星星商店配置 |
| 30 | + ListSequenceId []int // 用户序列组ID列表 | |
| 30 | 31 | |
| 31 | 32 | Client *ActivityConfigClient |
| 32 | 33 | GameId string // 所属游戏ID | ... | ... |
configs-db/confcardholder/decode.go
| ... | ... | @@ -2,6 +2,7 @@ package confcardholder |
| 2 | 2 | |
| 3 | 3 | import ( |
| 4 | 4 | "apigame/util/util-lx/lxalilog" |
| 5 | + "apigame/util/zslice" | |
| 5 | 6 | "encoding/json" |
| 6 | 7 | "errors" |
| 7 | 8 | "fmt" |
| ... | ... | @@ -83,6 +84,9 @@ func (c *ActivityConfig) Decode(gameId string, rawData any) { |
| 83 | 84 | for _, i2 := range configs { |
| 84 | 85 | combineId := CombineIdSequenceIdCohort(i2.Id, i2.SequenceId, i2.Cohort) |
| 85 | 86 | c.NormalCardStarConfig[combineId] = i2 |
| 87 | + if !zslice.Contains(c.ListSequenceId, i2.SequenceId) { | |
| 88 | + c.ListSequenceId = append(c.ListSequenceId, i2.SequenceId) | |
| 89 | + } | |
| 86 | 90 | } |
| 87 | 91 | } |
| 88 | 92 | // 卡片星级对应卡牌配置 |
| ... | ... | @@ -96,6 +100,9 @@ func (c *ActivityConfig) Decode(gameId string, rawData any) { |
| 96 | 100 | for _, i2 := range configs { |
| 97 | 101 | combineId := CombineIdSequenceIdCohort(i2.Id, i2.SequenceId, i2.Cohort) |
| 98 | 102 | c.CardSequenceConfig[combineId] = i2 |
| 103 | + if !zslice.Contains(c.ListSequenceId, i2.SequenceId) { | |
| 104 | + c.ListSequenceId = append(c.ListSequenceId, i2.SequenceId) | |
| 105 | + } | |
| 99 | 106 | } |
| 100 | 107 | } |
| 101 | 108 | // 星星商店配置 | ... | ... |
controllers/demo.go
| 1 | 1 | package controllers |
| 2 | 2 | |
| 3 | 3 | import ( |
| 4 | - "apigame/configs" | |
| 4 | + "apigame/configs-db/confcardholder" | |
| 5 | 5 | "apigame/models" |
| 6 | 6 | "apigame/service/code-msg" |
| 7 | 7 | "encoding/json" |
| ... | ... | @@ -43,13 +43,19 @@ func (c *DemoController) Demo() { |
| 43 | 43 | // } |
| 44 | 44 | //} |
| 45 | 45 | { |
| 46 | - cs := configs.GetTable(configs.AbTestCfg{}).Items() | |
| 46 | + //cs := configs.GetTable(configs.AbTestCfg{}).Items() | |
| 47 | 47 | //for _, dt := range cs { |
| 48 | 48 | // conf := dt.(*configs.AbTestCfg) |
| 49 | 49 | // fmt.Println(conf) |
| 50 | 50 | //} |
| 51 | 51 | //fmt.Println("cs", zjson.Str(cs)) |
| 52 | - rsp.Data = cs | |
| 52 | + //rsp.Data = cs | |
| 53 | + } | |
| 54 | + { | |
| 55 | + config, hasConfig := confcardholder.GetCurrent("10149") | |
| 56 | + if hasConfig { | |
| 57 | + fmt.Println(config.ListSequenceId) | |
| 58 | + } | |
| 53 | 59 | } |
| 54 | 60 | |
| 55 | 61 | c.RetRspCodeData(code_msg.RECODE_OK, rsp) | ... | ... |
service/cardholder/dto-player.go
service/cardholder/handle.go
| ... | ... | @@ -102,7 +102,8 @@ func HandleOpen(req *models.ReqCardHolderOpen) (code string, rsp models.RspCardH |
| 102 | 102 | |
| 103 | 103 | // 开始处理抽卡 |
| 104 | 104 | openMode := 0 |
| 105 | - sequenceId, cohort := GetUserSequenceIdAndCohort(player.Uid) | |
| 105 | + sequenceId := player.Details.SequenceId | |
| 106 | + cohort := GetCohort(player.Uid) | |
| 106 | 107 | allNewCards := make([]int, 0) |
| 107 | 108 | for _, idCardholder := range req.Ids { |
| 108 | 109 | confCardholder, _ := config.CardholderConfig[idCardholder] |
| ... | ... | @@ -180,7 +181,8 @@ func HandleCardAdd(req *models.ReqCardAdd) (code string, rsp models.RspCardAdd) |
| 180 | 181 | |
| 181 | 182 | // 剩余检查处理 |
| 182 | 183 | openMode := 0 |
| 183 | - sequenceId, cohort := GetUserSequenceIdAndCohort(player.Uid) | |
| 184 | + sequenceId := player.Details.SequenceId | |
| 185 | + cohort := GetCohort(player.Uid) | |
| 184 | 186 | allNewCards := []int{req.CardId} |
| 185 | 187 | |
| 186 | 188 | // 记录日志 |
| ... | ... | @@ -276,7 +278,8 @@ func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp model |
| 276 | 278 | } |
| 277 | 279 | // 开始处理抽卡 |
| 278 | 280 | openMode := 1 |
| 279 | - sequenceId, cohort := GetUserSequenceIdAndCohort(player.Uid) | |
| 281 | + sequenceId := player.Details.SequenceId | |
| 282 | + cohort := GetCohort(player.Uid) | |
| 280 | 283 | allNewCards := make([]int, 0) |
| 281 | 284 | for cardholderId, cardholderCount := range cardholderIdCount { |
| 282 | 285 | confCardholder, okCardholder := config.CardholderConfig[cardholderId] | ... | ... |
service/cardholder/logic.go
| ... | ... | @@ -38,12 +38,9 @@ func CheckGameData(d *Player, conf *confcardholder.ActivityConfig) string { |
| 38 | 38 | return code_msg.RECODE_OK |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | -// GetUserSequenceIdAndCohort 获取 用户序列组ID(sequenceId) 用户分组(cohort) | |
| 42 | -func GetUserSequenceIdAndCohort(uid int64) (sequenceId, cohort int) { | |
| 43 | - // todo 这里后续要对接 用户序列组ID(sequenceId) 用户分组(cohort) | |
| 44 | - sequenceId = 1 | |
| 45 | - cohort = 1 | |
| 46 | - return | |
| 41 | +// GetCohort 获取 用户序列组ID(sequenceId) 用户分组(cohort) | |
| 42 | +func GetCohort(uid int64) int { | |
| 43 | + return 1 | |
| 47 | 44 | } |
| 48 | 45 | |
| 49 | 46 | // GetOneFromArray 从配置的数组里获取一个值 scale=之前刻度 |
| ... | ... | @@ -385,7 +382,8 @@ func NextActivityAutoExchange(gameId string, player *Player, config *confcardhol |
| 385 | 382 | |
| 386 | 383 | // 开始处理抽卡 |
| 387 | 384 | openMode := 2 |
| 388 | - sequenceId, cohort := GetUserSequenceIdAndCohort(player.Uid) | |
| 385 | + sequenceId := player.Details.SequenceId | |
| 386 | + cohort := GetCohort(player.Uid) | |
| 389 | 387 | allNewCards := make([]int, 0) |
| 390 | 388 | if player.Details.AutoExchangeHolder != 0 { |
| 391 | 389 | confCardholder, _ := config.CardholderConfig[player.Details.AutoExchangeHolder] | ... | ... |
service/cardholder/player.go
| ... | ... | @@ -5,6 +5,7 @@ import ( |
| 5 | 5 | "apigame/service-common/svmysql" |
| 6 | 6 | "apigame/util/util-lx/lxalilog" |
| 7 | 7 | "apigame/util/util-lx/lxtime" |
| 8 | + "apigame/util/zslice" | |
| 8 | 9 | ) |
| 9 | 10 | |
| 10 | 11 | // SavePlayer 存储数据 |
| ... | ... | @@ -52,7 +53,12 @@ func LoadPlayer(gameId string, playerUid int64, config *confcardholder.ActivityC |
| 52 | 53 | player.Details.LastStarCount = starCount |
| 53 | 54 | NextActivityAutoExchange(gameId, player, config) |
| 54 | 55 | |
| 56 | + player.Details.SequenceId = zslice.RandomOne(config.ListSequenceId) | |
| 57 | + | |
| 55 | 58 | SavePlayer(gameId, player) |
| 56 | 59 | } |
| 60 | + if player.Details.SequenceId == 0 { | |
| 61 | + player.Details.SequenceId = 1 | |
| 62 | + } | |
| 57 | 63 | return |
| 58 | 64 | } | ... | ... |