diff --git a/modules/hunting/api_buy.go b/modules/hunting/api_buy.go index b3bf915fd..71b9db2a2 100644 --- a/modules/hunting/api_buy.go +++ b/modules/hunting/api_buy.go @@ -47,6 +47,11 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code } else { curByCount = list.BuyCount } + curByCount += req.Count // 当前需要购买的数量 + if this.configure.GetMaxBuyChallengeCount() < curByCount { + code = pb.ErrorCode_HuntingBuyMaxCount + return + } conf := this.module.configure.GetGlobalConf() if conf == nil { code = pb.ErrorCode_ConfigNoFound @@ -88,11 +93,6 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code list.RecoveryTime = 0 } mapData["recoveryTime"] = list.RecoveryTime - curByCount += req.Count // 当前需要购买的数量 - if this.configure.GetMaxBuyChallengeCount() < curByCount { - code = pb.ErrorCode_HuntingBuyMaxCount - return - } for i := list.BuyCount + 1; i <= curByCount; i++ { _cfg := this.configure.GetBuyChallengeCount(i) @@ -109,6 +109,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code if v.A == v1.A && v.T == v1.T { v1.N += v.N bFound = true + break } } if !bFound {