Commit 59e1f82b1af621ecdd2a9749b97bd99d0ed8bc8d
1 parent
7529d4bb
Exists in
master
feat✨:卡牌系统
Showing
4 changed files
with
7 additions
and
9 deletions
Show diff stats
models/cardholder.go
| ... | ... | @@ -92,7 +92,7 @@ type ReqAutoExchangeInfo struct { |
| 92 | 92 | // RspAutoExchangeInfo 返回 上期剩余星星自动兑换信息 |
| 93 | 93 | type RspAutoExchangeInfo struct { |
| 94 | 94 | CardHolderInfo |
| 95 | - NewCards []int `form:"new_cards" json:"new_cards"` // 新获得的卡牌列表 | |
| 95 | + NewCards [][]int `form:"new_cards" json:"new_cards"` // 新获得的卡牌列表 | |
| 96 | 96 | AwardAlbum map[int]string `form:"award_album" json:"award_album"` // 触发的卡组奖励列表 k=出发的卡组ID v=对应奖励 |
| 97 | 97 | AwardRound string `form:"award_round" json:"award_round"` // 触发的轮次奖励列表 空字符串未触发 |
| 98 | 98 | LastStarCount int `form:"last_star_count" json:"last_star_count"` // 上期活动剩余星星点数 | ... | ... |
service/cardholder/dto-player.go
| ... | ... | @@ -48,6 +48,7 @@ type PlayerDetails struct { |
| 48 | 48 | StarCount int // 星星点数 |
| 49 | 49 | LastStarCount int // 上期活动剩余星星点数 |
| 50 | 50 | AutoExchangeHolderIds []int // 活动切换时自动兑换的卡包 |
| 51 | + AutoExchangeNewCards [][]int // 活动切换时自动兑换的卡 | |
| 51 | 52 | SequenceId int // 用户序列组ID |
| 52 | 53 | } |
| 53 | 54 | |
| ... | ... | @@ -60,6 +61,7 @@ func NewPlayerDetails() *PlayerDetails { |
| 60 | 61 | Round: 1, |
| 61 | 62 | StarCount: 0, |
| 62 | 63 | AutoExchangeHolderIds: make([]int, 0), |
| 64 | + AutoExchangeNewCards: make([][]int, 0), | |
| 63 | 65 | } |
| 64 | 66 | } |
| 65 | 67 | ... | ... |
service/cardholder/handle.go
| ... | ... | @@ -318,7 +318,7 @@ func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp model |
| 318 | 318 | // HandleAutoExchangeInfo 上期剩余星星自动兑换信息 |
| 319 | 319 | func HandleAutoExchangeInfo(req *models.ReqAutoExchangeInfo) (code string, rsp models.RspAutoExchangeInfo) { |
| 320 | 320 | rsp = models.RspAutoExchangeInfo{ |
| 321 | - NewCards: make([]int, 0), | |
| 321 | + NewCards: make([][]int, 0), | |
| 322 | 322 | AwardAlbum: make(map[int]string), |
| 323 | 323 | AutoExchangeHolder: make([]int, 0), |
| 324 | 324 | } |
| ... | ... | @@ -354,16 +354,11 @@ func HandleAutoExchangeInfo(req *models.ReqAutoExchangeInfo) (code string, rsp m |
| 354 | 354 | |
| 355 | 355 | rsp.LastStarCount = player.Details.LastStarCount |
| 356 | 356 | rsp.AutoExchangeHolder = player.Details.AutoExchangeHolderIds |
| 357 | - | |
| 358 | - // 把当前的卡包内数据放在新卡数据里给客户端 | |
| 359 | - for i1, i2 := range player.Details.Cards { | |
| 360 | - for i := 0; i < i2; i++ { | |
| 361 | - rsp.NewCards = append(rsp.NewCards, i1) | |
| 362 | - } | |
| 363 | - } | |
| 357 | + rsp.NewCards = player.Details.AutoExchangeNewCards | |
| 364 | 358 | |
| 365 | 359 | player.Details.LastStarCount = 0 |
| 366 | 360 | player.Details.AutoExchangeHolderIds = make([]int, 0) |
| 361 | + player.Details.AutoExchangeNewCards = make([][]int, 0) | |
| 367 | 362 | // 存档 |
| 368 | 363 | SavePlayer(gameId, player) |
| 369 | 364 | ... | ... |
service/cardholder/logic.go
| ... | ... | @@ -413,6 +413,7 @@ func NextActivityAutoExchange(gameId string, player *Player, config *confcardhol |
| 413 | 413 | confCardholder, |
| 414 | 414 | sequenceId, cohort, |
| 415 | 415 | openMode) |
| 416 | + player.Details.AutoExchangeNewCards = append(player.Details.AutoExchangeNewCards, newCards) | |
| 416 | 417 | // 打乱顺序 |
| 417 | 418 | zslice.Shuffle(newCards) |
| 418 | 419 | for _, i3 := range newCards { | ... | ... |