Commit 0b461d56c472e37446ac97c01476a1bbce50e309
1 parent
823e90e6
Exists in
master
feat✨:卡牌活动星星商店的卡包可能为多个
Showing
4 changed files
with
43 additions
and
32 deletions
Show diff stats
models/cardholder.go
| @@ -96,5 +96,5 @@ type RspAutoExchangeInfo struct { | @@ -96,5 +96,5 @@ type RspAutoExchangeInfo struct { | ||
| 96 | AwardAlbum map[int]string `form:"award_album" json:"award_album"` // 触发的卡组奖励列表 k=出发的卡组ID v=对应奖励 | 96 | AwardAlbum map[int]string `form:"award_album" json:"award_album"` // 触发的卡组奖励列表 k=出发的卡组ID v=对应奖励 |
| 97 | AwardRound string `form:"award_round" json:"award_round"` // 触发的轮次奖励列表 空字符串未触发 | 97 | AwardRound string `form:"award_round" json:"award_round"` // 触发的轮次奖励列表 空字符串未触发 |
| 98 | LastStarCount int `form:"last_star_count" json:"last_star_count"` // 上期活动剩余星星点数 | 98 | LastStarCount int `form:"last_star_count" json:"last_star_count"` // 上期活动剩余星星点数 |
| 99 | - AutoExchangeHolder int `form:"auto_exchange_holder" json:"auto_exchange_holder"` // 活动切换时自动兑换的卡包 | 99 | + AutoExchangeHolder []int `form:"auto_exchange_holder" json:"auto_exchange_holder"` // 活动切换时自动兑换的卡包 |
| 100 | } | 100 | } |
service/cardholder/dto-player.go
| @@ -47,7 +47,7 @@ type PlayerDetails struct { | @@ -47,7 +47,7 @@ type PlayerDetails struct { | ||
| 47 | Round int // 卡册当前轮次 | 47 | Round int // 卡册当前轮次 |
| 48 | StarCount int // 星星点数 | 48 | StarCount int // 星星点数 |
| 49 | LastStarCount int // 上期活动剩余星星点数 | 49 | LastStarCount int // 上期活动剩余星星点数 |
| 50 | - AutoExchangeHolder int // 活动切换时自动兑换的卡包 2024年4月26日 这里策划要求改为只能兑换一个最高级的 | 50 | + AutoExchangeHolder []int // 活动切换时自动兑换的卡包 |
| 51 | SequenceId int // 用户序列组ID | 51 | SequenceId int // 用户序列组ID |
| 52 | } | 52 | } |
| 53 | 53 | ||
| @@ -59,7 +59,7 @@ func NewPlayerDetails() *PlayerDetails { | @@ -59,7 +59,7 @@ func NewPlayerDetails() *PlayerDetails { | ||
| 59 | CardSequenceScales: make(map[string]int), | 59 | CardSequenceScales: make(map[string]int), |
| 60 | Round: 1, | 60 | Round: 1, |
| 61 | StarCount: 0, | 61 | StarCount: 0, |
| 62 | - AutoExchangeHolder: 0, | 62 | + AutoExchangeHolder: make([]int, 0), |
| 63 | } | 63 | } |
| 64 | } | 64 | } |
| 65 | 65 |
service/cardholder/handle.go
| @@ -7,7 +7,6 @@ import ( | @@ -7,7 +7,6 @@ import ( | ||
| 7 | "apigame/service/code-msg" | 7 | "apigame/service/code-msg" |
| 8 | "apigame/util/util-lx/lxalilog" | 8 | "apigame/util/util-lx/lxalilog" |
| 9 | "apigame/util/util-lx/lxtime" | 9 | "apigame/util/util-lx/lxtime" |
| 10 | - "apigame/util/zconvert" | ||
| 11 | "apigame/util/zslice" | 10 | "apigame/util/zslice" |
| 12 | ) | 11 | ) |
| 13 | 12 | ||
| @@ -269,38 +268,29 @@ func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp model | @@ -269,38 +268,29 @@ func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp model | ||
| 269 | } | 268 | } |
| 270 | 269 | ||
| 271 | // 从配置里拿到卡包ID和数量列表 | 270 | // 从配置里拿到卡包ID和数量列表 |
| 272 | - cardholderIdCount := make(map[int]int) | ||
| 273 | - cardholderIdCountList := zconvert.ToListListInt(confStarShop.CardBagIds, "|", ",") | ||
| 274 | - for _, i2 := range cardholderIdCountList { | ||
| 275 | - if len(i2) >= 3 { | ||
| 276 | - cardholderIdCount[i2[1]] = i2[2] | ||
| 277 | - } | ||
| 278 | - } | 271 | + rsp.NewHolders = GetCardholder(confStarShop) |
| 279 | // 开始处理抽卡 | 272 | // 开始处理抽卡 |
| 280 | openMode := 1 | 273 | openMode := 1 |
| 281 | sequenceId := player.Details.SequenceId | 274 | sequenceId := player.Details.SequenceId |
| 282 | cohort := GetCohort(player.Uid) | 275 | cohort := GetCohort(player.Uid) |
| 283 | allNewCards := make([]int, 0) | 276 | allNewCards := make([]int, 0) |
| 284 | - for cardholderId, cardholderCount := range cardholderIdCount { | 277 | + for _, cardholderId := range rsp.NewHolders { |
| 285 | confCardholder, okCardholder := config.CardholderConfig[cardholderId] | 278 | confCardholder, okCardholder := config.CardholderConfig[cardholderId] |
| 286 | if !okCardholder { | 279 | if !okCardholder { |
| 287 | lxalilog.Errors("StarShopConfig.CardBagIds error", confStarShop.Id) | 280 | lxalilog.Errors("StarShopConfig.CardBagIds error", confStarShop.Id) |
| 288 | continue | 281 | continue |
| 289 | } | 282 | } |
| 290 | - rsp.NewHolders = append(rsp.NewHolders, cardholderId) | ||
| 291 | - for i := 0; i < cardholderCount; i++ { | ||
| 292 | - newCards := DoOpen(gameId, | ||
| 293 | - player, config, | ||
| 294 | - confCardholder, | ||
| 295 | - sequenceId, cohort, | ||
| 296 | - openMode) | ||
| 297 | - // 打乱顺序 | ||
| 298 | - zslice.Shuffle(newCards) | ||
| 299 | - for _, i3 := range newCards { | ||
| 300 | - allNewCards = append(allNewCards, i3) | ||
| 301 | - } | ||
| 302 | - rsp.NewCards = append(rsp.NewCards, newCards) | 283 | + newCards := DoOpen(gameId, |
| 284 | + player, config, | ||
| 285 | + confCardholder, | ||
| 286 | + sequenceId, cohort, | ||
| 287 | + openMode) | ||
| 288 | + // 打乱顺序 | ||
| 289 | + zslice.Shuffle(newCards) | ||
| 290 | + for _, i3 := range newCards { | ||
| 291 | + allNewCards = append(allNewCards, i3) | ||
| 303 | } | 292 | } |
| 293 | + rsp.NewCards = append(rsp.NewCards, newCards) | ||
| 304 | } | 294 | } |
| 305 | 295 | ||
| 306 | awardAlbum, awardRound := DoOpenCheckAward(gameId, | 296 | awardAlbum, awardRound := DoOpenCheckAward(gameId, |
| @@ -330,7 +320,7 @@ func HandleAutoExchangeInfo(req *models.ReqAutoExchangeInfo) (code string, rsp m | @@ -330,7 +320,7 @@ func HandleAutoExchangeInfo(req *models.ReqAutoExchangeInfo) (code string, rsp m | ||
| 330 | rsp = models.RspAutoExchangeInfo{ | 320 | rsp = models.RspAutoExchangeInfo{ |
| 331 | NewCards: make([]int, 0), | 321 | NewCards: make([]int, 0), |
| 332 | AwardAlbum: make(map[int]string), | 322 | AwardAlbum: make(map[int]string), |
| 333 | - AutoExchangeHolder: 0, | 323 | + AutoExchangeHolder: make([]int, 0), |
| 334 | } | 324 | } |
| 335 | code = code_msg.RECODE_OK | 325 | code = code_msg.RECODE_OK |
| 336 | gameId := req.GameID | 326 | gameId := req.GameID |
| @@ -373,7 +363,7 @@ func HandleAutoExchangeInfo(req *models.ReqAutoExchangeInfo) (code string, rsp m | @@ -373,7 +363,7 @@ func HandleAutoExchangeInfo(req *models.ReqAutoExchangeInfo) (code string, rsp m | ||
| 373 | } | 363 | } |
| 374 | 364 | ||
| 375 | player.Details.LastStarCount = 0 | 365 | player.Details.LastStarCount = 0 |
| 376 | - player.Details.AutoExchangeHolder = 0 | 366 | + player.Details.AutoExchangeHolder = make([]int, 0) |
| 377 | // 存档 | 367 | // 存档 |
| 378 | SavePlayer(gameId, player) | 368 | SavePlayer(gameId, player) |
| 379 | 369 |
service/cardholder/logic.go
| @@ -364,6 +364,23 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need | @@ -364,6 +364,23 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need | ||
| 364 | return | 364 | return |
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | +func GetCardholder(confStarShop confcardholder.StarShopConfig) (list []int) { | ||
| 368 | + // 从配置里拿到卡包ID和数量列表 | ||
| 369 | + cardholderIdCount := make(map[int]int) | ||
| 370 | + cardholderIdCountList := zconvert.ToListListInt(confStarShop.CardBagIds, "|", ",") | ||
| 371 | + for _, i2 := range cardholderIdCountList { | ||
| 372 | + if len(i2) >= 3 { | ||
| 373 | + cardholderIdCount[i2[1]] = i2[2] | ||
| 374 | + } | ||
| 375 | + } | ||
| 376 | + for cardholderId, cardholderCount := range cardholderIdCount { | ||
| 377 | + for i := 0; i < cardholderCount; i++ { | ||
| 378 | + list = append(list, cardholderId) | ||
| 379 | + } | ||
| 380 | + } | ||
| 381 | + return | ||
| 382 | +} | ||
| 383 | + | ||
| 367 | // NextActivityAutoExchange 活动切换时自动兑换卡包 | 384 | // NextActivityAutoExchange 活动切换时自动兑换卡包 |
| 368 | func NextActivityAutoExchange(gameId string, player *Player, config *confcardholder.ActivityConfig) { | 385 | func NextActivityAutoExchange(gameId string, player *Player, config *confcardholder.ActivityConfig) { |
| 369 | // 把星星的配置按照需要的星星数降序排列 | 386 | // 把星星的配置按照需要的星星数降序排列 |
| @@ -373,9 +390,9 @@ func NextActivityAutoExchange(gameId string, player *Player, config *confcardhol | @@ -373,9 +390,9 @@ func NextActivityAutoExchange(gameId string, player *Player, config *confcardhol | ||
| 373 | }) | 390 | }) |
| 374 | list = lo.Reverse(list) | 391 | list = lo.Reverse(list) |
| 375 | // 遍历 | 392 | // 遍历 |
| 376 | - for _, config := range list { | ||
| 377 | - if player.Details.LastStarCount >= config.NeedStarNumber { | ||
| 378 | - player.Details.AutoExchangeHolder = config.Id | 393 | + for _, configStarShop := range list { |
| 394 | + if player.Details.LastStarCount >= configStarShop.NeedStarNumber { | ||
| 395 | + player.Details.AutoExchangeHolder = GetCardholder(configStarShop) | ||
| 379 | break | 396 | break |
| 380 | } | 397 | } |
| 381 | } | 398 | } |
| @@ -385,8 +402,12 @@ func NextActivityAutoExchange(gameId string, player *Player, config *confcardhol | @@ -385,8 +402,12 @@ func NextActivityAutoExchange(gameId string, player *Player, config *confcardhol | ||
| 385 | sequenceId := player.Details.SequenceId | 402 | sequenceId := player.Details.SequenceId |
| 386 | cohort := GetCohort(player.Uid) | 403 | cohort := GetCohort(player.Uid) |
| 387 | allNewCards := make([]int, 0) | 404 | allNewCards := make([]int, 0) |
| 388 | - if player.Details.AutoExchangeHolder != 0 { | ||
| 389 | - confCardholder, _ := config.CardholderConfig[player.Details.AutoExchangeHolder] | 405 | + for _, cardholderId := range player.Details.AutoExchangeHolder { |
| 406 | + confCardholder, okCardholder := config.CardholderConfig[cardholderId] | ||
| 407 | + if !okCardholder { | ||
| 408 | + lxalilog.Errors("StarShopConfig.CardBagIds error", cardholderId) | ||
| 409 | + continue | ||
| 410 | + } | ||
| 390 | newCards := DoOpen(gameId, | 411 | newCards := DoOpen(gameId, |
| 391 | player, config, | 412 | player, config, |
| 392 | confCardholder, | 413 | confCardholder, |