Commit 1dd66484df877081dc5e1c990d75894eb6017013

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

feat✨:卡牌活动星星商店接口修改

models/cardholder.go
... ... @@ -62,7 +62,8 @@ type ReqStarShopExchange struct {
62 62 // RspStarShopExchange 返回 星星商店兑换
63 63 type RspStarShopExchange struct {
64 64 CardHolderInfo
65   - NewCards []int `form:"new_cards" json:"new_cards"` // 新获得的卡牌列表
  65 + NewHolders []int `form:"new_holders" json:"new_holders"` // 新获得的卡包列表
  66 + NewCards [][]int `form:"new_cards" json:"new_cards"` // 新获得的卡牌列表
66 67 AwardAlbum map[int]string `form:"award_album" json:"award_album"` // 触发的卡组奖励列表 k=出发的卡组ID v=对应奖励
67 68 AwardRound string `form:"award_round" json:"award_round"` // 触发的轮次奖励列表 空字符串未触发
68 69 }
... ...
service/cardholder/handle.go
... ... @@ -8,7 +8,6 @@ import (
8 8 "apigame/util/util-lx/lxtime"
9 9 "apigame/util/utslice"
10 10 "apigame/util/utstring"
11   - "strings"
12 11 )
13 12  
14 13 // HandleGetConfig 活动配置
... ... @@ -139,7 +138,8 @@ func HandleOpen(req *models.ReqCardHolderOpen) (code string, rsp models.RspCardH
139 138 // HandleShopExchange 星星商店兑换
140 139 func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp models.RspStarShopExchange) {
141 140 rsp = models.RspStarShopExchange{
142   - NewCards: make([]int, 0),
  141 + NewHolders: make([]int, 0),
  142 + NewCards: make([][]int, 0),
143 143 AwardAlbum: make(map[int]string),
144 144 }
145 145 code = code_msg.RECODE_OK
... ... @@ -179,27 +179,6 @@ func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp model
179 179 return
180 180 }
181 181  
182   - // 判断配置
183   - cardBagIdsStr := strings.Split(confStarShop.CardBagIds, ",")
184   - cardBagIds := utstring.ListStringToListInt(cardBagIdsStr)
185   - if len(cardBagIds) < 3 {
186   - lxalilog.Errors("StarShopConfig.CardBagIds error", confStarShop.Id)
187   - code = code_msg.RECODE_MERGE_CONFIG_ERROR
188   - return
189   - }
190   - cardholderId := cardBagIds[1]
191   - cardholderCount := cardBagIds[2]
192   - if cardholderCount < 1 {
193   - lxalilog.Errors("StarShopConfig.CardBagIds error", confStarShop.Id)
194   - code = code_msg.RECODE_MERGE_CONFIG_ERROR
195   - return
196   - }
197   - confCardholder, okCardholder := config.CardholderConfig[cardholderId]
198   - if !okCardholder {
199   - code = code_msg.RECODE_MERGE_CONFIG_ERROR
200   - return
201   - }
202   -
203 182 // 按照规则扣除星星
204 183 enough, cardList := GetStarCardList(player, config, confStarShop.NeedStarNumber)
205 184 if !enough {
... ... @@ -210,23 +189,44 @@ func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp model
210 189 player.Details.Cards[i] -= i2
211 190 }
212 191  
  192 + // 从配置里拿到卡包ID和数量列表
  193 + cardholderIdCount := make(map[int]int)
  194 + cardholderIdCountList := utstring.StringToListListInt(confStarShop.CardBagIds, "|", ",")
  195 + for _, i2 := range cardholderIdCountList {
  196 + if len(i2) >= 3 {
  197 + cardholderIdCount[i2[1]] = i2[2]
  198 + }
  199 + }
213 200 // 开始处理抽卡
214 201 openMode := 1
215 202 sequenceId, cohort := GetUserSequenceIdAndCohort(player.Uid)
216   - for i := 0; i < cardholderCount; i++ {
217   - newCards := DoOpen(gameId,
218   - player, config,
219   - confCardholder,
220   - sequenceId, cohort,
221   - openMode)
222   - for _, i3 := range newCards {
223   - rsp.NewCards = append(rsp.NewCards, i3)
  203 + allNewCards := make([]int, 0)
  204 + for cardholderId, cardholderCount := range cardholderIdCount {
  205 + confCardholder, okCardholder := config.CardholderConfig[cardholderId]
  206 + if !okCardholder {
  207 + lxalilog.Errors("StarShopConfig.CardBagIds error", confStarShop.Id)
  208 + continue
  209 + }
  210 + rsp.NewHolders = append(rsp.NewHolders, cardholderId)
  211 + for i := 0; i < cardholderCount; i++ {
  212 + newCards := DoOpen(gameId,
  213 + player, config,
  214 + confCardholder,
  215 + sequenceId, cohort,
  216 + openMode)
  217 + // 打乱顺序
  218 + utslice.Shuffle(newCards)
  219 + for _, i3 := range newCards {
  220 + allNewCards = append(allNewCards, i3)
  221 + }
  222 + rsp.NewCards = append(rsp.NewCards, newCards)
224 223 }
225 224 }
  225 +
226 226 awardAlbum, awardRound := DoOpenCheckAward(gameId,
227 227 player, config,
228 228 sequenceId, cohort,
229   - rsp.NewCards,
  229 + allNewCards,
230 230 openMode)
231 231 rsp.AwardAlbum = awardAlbum
232 232 rsp.AwardRound = awardRound
... ...
service/cardholder/logic.go
... ... @@ -349,7 +349,7 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need
349 349 needCardCount = cardCount - 1
350 350 }
351 351 cardList[cardId] = needCardCount
352   - starAmount += needCardCount * star
  352 + starAmount += needCardCount * (star + 1)
353 353 }
354 354 }
355 355 if starAmount >= needStar {
... ...