Commit f0df1f48055de83b22c4d0bdde3ee0f2b7b7dd5d
1 parent
77286ab9
Exists in
master
and in
1 other branch
feat:抽卡暂存
Showing
4 changed files
with
75 additions
and
12 deletions
Show diff stats
dto/ht-cardholder.go
service/constd/index.go
| ... | ... | @@ -40,10 +40,11 @@ const ( |
| 40 | 40 | RECODE_MERGE_TONGXINGZHENGBUCUNZAI_ERROR = "2051" |
| 41 | 41 | RECODE_MERGE_QINGXIANGMTXZ_ERROR = "2052" |
| 42 | 42 | |
| 43 | - RECODE_MERGE_CARDHOLDER_NOTOPEN1_ERROR = "2101" | |
| 44 | - RECODE_MERGE_CARDHOLDER_NOTOPEN2_ERROR = "2102" | |
| 45 | - RECODE_MERGE_CARDHOLDER_CARDHOLDERID_ERROR = "2103" | |
| 46 | - RECODE_MERGE_CARDHOLDER_COUNTILLEGAL_ERROR = "2104" | |
| 43 | + RECODE_MERGE_CARDHOLDER_NOTOPEN1_ERROR = "2101" | |
| 44 | + RECODE_MERGE_CARDHOLDER_NOTOPEN2_ERROR = "2102" | |
| 45 | + RECODE_MERGE_CARDHOLDER_CARDHOLDERID_ERROR = "2103" | |
| 46 | + RECODE_MERGE_CARDHOLDER_COUNTILLEGAL_ERROR = "2104" | |
| 47 | + RECODE_MERGE_CARDHOLDER_CARDHOLDER_NOTENOUGH_ERROR = "2105" | |
| 47 | 48 | ) |
| 48 | 49 | |
| 49 | 50 | var recodeText = map[string]string{ |
| ... | ... | @@ -84,10 +85,11 @@ var recodeText = map[string]string{ |
| 84 | 85 | RECODE_MERGE_TONGXINGZHENGBUCUNZAI_ERROR: "通行证不存在", |
| 85 | 86 | RECODE_MERGE_QINGXIANGMTXZ_ERROR: "请先购买通行证", |
| 86 | 87 | |
| 87 | - RECODE_MERGE_CARDHOLDER_NOTOPEN1_ERROR: "活动未开始", | |
| 88 | - RECODE_MERGE_CARDHOLDER_NOTOPEN2_ERROR: "活动已结束", | |
| 89 | - RECODE_MERGE_CARDHOLDER_CARDHOLDERID_ERROR: "卡包ID错误", | |
| 90 | - RECODE_MERGE_CARDHOLDER_COUNTILLEGAL_ERROR: "数目不合法", | |
| 88 | + RECODE_MERGE_CARDHOLDER_NOTOPEN1_ERROR: "活动未开始", | |
| 89 | + RECODE_MERGE_CARDHOLDER_NOTOPEN2_ERROR: "活动已结束", | |
| 90 | + RECODE_MERGE_CARDHOLDER_CARDHOLDERID_ERROR: "卡包ID错误", | |
| 91 | + RECODE_MERGE_CARDHOLDER_COUNTILLEGAL_ERROR: "数目不合法", | |
| 92 | + RECODE_MERGE_CARDHOLDER_CARDHOLDER_NOTENOUGH_ERROR: "卡包不足", | |
| 91 | 93 | } |
| 92 | 94 | |
| 93 | 95 | func RecodeText(code string) string { | ... | ... |
service/ht-cardholder/config-registry.go
| ... | ... | @@ -4,6 +4,7 @@ import ( |
| 4 | 4 | "apigame/lx-util/lxalilog" |
| 5 | 5 | "apigame/service/constd" |
| 6 | 6 | "encoding/json" |
| 7 | + "errors" | |
| 7 | 8 | ) |
| 8 | 9 | |
| 9 | 10 | var ( |
| ... | ... | @@ -109,3 +110,21 @@ func (r *RegistryConfigs) Decode(confRaw CardActivityConfigRaw) { |
| 109 | 110 | //logs.Debug("🐸", conf.NormalCardStarSequence) |
| 110 | 111 | //logs.Debug("🐸", conf.CardSequenceConfig) |
| 111 | 112 | } |
| 113 | + | |
| 114 | +// FindCardSequenceConfig 查找配置 星级ID对应的卡片 | |
| 115 | +func FindCardSequenceConfig(id, sequenceId, cohort string) (conf CardSequenceConfig, has bool) { | |
| 116 | + conf = CardSequenceConfig{} | |
| 117 | + has = false | |
| 118 | + for _, c := range Registry.Config.CardSequenceConfig { | |
| 119 | + if c.Id == id && | |
| 120 | + c.SequenceId == sequenceId && | |
| 121 | + c.Cohort == cohort { | |
| 122 | + has = true | |
| 123 | + return | |
| 124 | + } | |
| 125 | + } | |
| 126 | + if !has { | |
| 127 | + lxalilog.Errors(errors.New("ht_cardholder CardSequenceConfig error"), " LoadData Error", id, sequenceId, cohort) | |
| 128 | + } | |
| 129 | + return | |
| 130 | +} | ... | ... |
service/ht-cardholder/handle.go
| ... | ... | @@ -34,16 +34,18 @@ func HandleGetNew(req *dto.ReqHtCardHolderGetNew) (code string, rsp dto.RspHtCar |
| 34 | 34 | // 尝试更新配置 |
| 35 | 35 | TryUpdateConfigs() |
| 36 | 36 | |
| 37 | + // 检查活动状态 | |
| 37 | 38 | code = CheckStatus() |
| 38 | 39 | if code != constd.RECODE_OK { |
| 39 | 40 | return |
| 40 | 41 | } |
| 41 | - | |
| 42 | - if _, ok := Registry.Config.CardholderConfig[strconv.Itoa(req.Id)]; !ok { | |
| 42 | + // 检查卡包ID | |
| 43 | + _, okCardholderConfig := Registry.Config.CardholderConfig[strconv.Itoa(req.Id)] | |
| 44 | + if !okCardholderConfig { | |
| 43 | 45 | code = constd.RECODE_MERGE_CARDHOLDER_CARDHOLDERID_ERROR |
| 44 | 46 | return |
| 45 | 47 | } |
| 46 | - | |
| 48 | + // 检查卡包数量 | |
| 47 | 49 | if req.Count < 1 { |
| 48 | 50 | code = constd.RECODE_MERGE_CARDHOLDER_COUNTILLEGAL_ERROR |
| 49 | 51 | return |
| ... | ... | @@ -51,6 +53,7 @@ func HandleGetNew(req *dto.ReqHtCardHolderGetNew) (code string, rsp dto.RspHtCar |
| 51 | 53 | |
| 52 | 54 | // 读取游戏数据 |
| 53 | 55 | gameData := LoadData(req.UID) |
| 56 | + | |
| 54 | 57 | gameData.DetailsData.Cardholder[req.Id] += req.Count |
| 55 | 58 | SaveData(gameData) |
| 56 | 59 | |
| ... | ... | @@ -67,8 +70,37 @@ func HandleOpen(req *dto.ReqHtCardHolderOpen) (code string, rsp dto.RspHtCardHol |
| 67 | 70 | // 尝试更新配置 |
| 68 | 71 | TryUpdateConfigs() |
| 69 | 72 | |
| 70 | - // 读取游戏数据 | |
| 73 | + // 检查活动状态 | |
| 74 | + code = CheckStatus() | |
| 75 | + if code != constd.RECODE_OK { | |
| 76 | + return | |
| 77 | + } | |
| 78 | + //// 检查卡包ID | |
| 79 | + //confCardholder, okCardholderConfig := Registry.Config.CardholderConfig[strconv.Itoa(req.Id)] | |
| 80 | + //if !okCardholderConfig { | |
| 81 | + // code = constd.RECODE_MERGE_CARDHOLDER_CARDHOLDERID_ERROR | |
| 82 | + // return | |
| 83 | + //} | |
| 84 | + // | |
| 85 | + //// 读取游戏数据 | |
| 71 | 86 | //gameData := LoadData(req.UID) |
| 87 | + // | |
| 88 | + //// 判断卡包数目 | |
| 89 | + //countOld, _ := gameData.DetailsData.Cardholder[req.Id] | |
| 90 | + //if countOld < 1 { | |
| 91 | + // code = constd.RECODE_MERGE_CARDHOLDER_CARDHOLDER_NOTENOUGH_ERROR | |
| 92 | + // return | |
| 93 | + //} | |
| 94 | + // | |
| 95 | + //// 开始处理抽卡 | |
| 96 | + //sequenceId, cohort := GetUserSequenceIdAndCohort(req.UID) | |
| 97 | + //// 先抽保底卡 | |
| 98 | + //if confCardholder.GuaranteedStar != "0" { | |
| 99 | + // confGuaranteed, hasGuaranteed := FindCardSequenceConfig(confCardholder.GuaranteedStar, sequenceId, cohort) | |
| 100 | + // if hasGuaranteed { | |
| 101 | + // | |
| 102 | + // } | |
| 103 | + //} | |
| 72 | 104 | |
| 73 | 105 | return |
| 74 | 106 | } |
| ... | ... | @@ -132,3 +164,11 @@ func CheckStatus() string { |
| 132 | 164 | } |
| 133 | 165 | return constd.RECODE_OK |
| 134 | 166 | } |
| 167 | + | |
| 168 | +// GetUserSequenceIdAndCohort 获取 用户序列组ID(sequenceId) 用户分组(cohort) | |
| 169 | +func GetUserSequenceIdAndCohort(uid int64) (sequenceId, cohort string) { | |
| 170 | + // todo 这里后续要对接 | |
| 171 | + sequenceId = "1" | |
| 172 | + cohort = "1" | |
| 173 | + return | |
| 174 | +} | ... | ... |