From 809d5d2dc59923bd5b4e6c5b60ed9f8120df770d Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 28 Nov 2022 21:28:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E6=97=B6=E9=97=B4=E8=AE=A1?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hunting/api_buy.go | 24 +++++++++++++----------- modules/hunting/api_getlist.go | 26 +++++++++++--------------- modules/viking/api_buy.go | 24 +++++++++++------------- modules/viking/api_getlist.go | 20 +++++++++++--------- 4 files changed, 46 insertions(+), 48 deletions(-) diff --git a/modules/hunting/api_buy.go b/modules/hunting/api_buy.go index 55e40e6dc..b3bf915fd 100644 --- a/modules/hunting/api_buy.go +++ b/modules/hunting/api_buy.go @@ -63,15 +63,17 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code if list.RecoveryTime == 0 { list.RecoveryTime = configure.Now().Unix() } - count := (configure.Now().Unix() - list.RecoveryTime) / int64(conf.HuntingRecovery*60) - if count > 1 { - curCount += int32(count) - } - if curCount >= conf.HuntingNum { - curCount = conf.HuntingNum - list.RecoveryTime = 0 - } else { - list.RecoveryTime += count * int64(conf.VikingExpeditionRecoveryTime*60) // 更新刷新时间 + for { // 计算恢复时间 + if list.RecoveryTime+int64(conf.HuntingRecovery*60) <= configure.Now().Unix() { + curCount++ + list.RecoveryTime += int64(conf.HuntingRecovery * 60) + if curCount >= conf.HuntingNum { + list.RecoveryTime = 0 + break + } + } else { + break + } } if curCount-amount > 0 { if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{ @@ -88,14 +90,14 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code mapData["recoveryTime"] = list.RecoveryTime curByCount += req.Count // 当前需要购买的数量 if this.configure.GetMaxBuyChallengeCount() < curByCount { - code = pb.ErrorCode_VikingBuyMaxCount + code = pb.ErrorCode_HuntingBuyMaxCount return } for i := list.BuyCount + 1; i <= curByCount; i++ { _cfg := this.configure.GetBuyChallengeCount(i) if _cfg == nil { - code = pb.ErrorCode_VikingBuyMaxCount + code = pb.ErrorCode_HuntingBuyMaxCount return } szCostRes = append(szCostRes, _cfg.Need...) diff --git a/modules/hunting/api_getlist.go b/modules/hunting/api_getlist.go index 8da85c8fc..5b97bedf2 100644 --- a/modules/hunting/api_getlist.go +++ b/modules/hunting/api_getlist.go @@ -46,34 +46,30 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.HuntingGetListRe code = pb.ErrorCode_ConfigNoFound return } - costRes := conf.VikingExpeditionCos + costRes := conf.HuntingCos if costRes == nil { code = pb.ErrorCode_ConfigNoFound return } amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量 curCount = amount - if amount < conf.VikingNum { + if amount < conf.HuntingNum { if list.RecoveryTime == 0 { list.RecoveryTime = configure.Now().Unix() } for { // 计算恢复时间 - amount++ - if amount > conf.VikingNum { - list.RecoveryTime = 0 + if list.RecoveryTime+int64(conf.HuntingRecovery*60) <= configure.Now().Unix() { + curCount++ + list.RecoveryTime += int64(conf.HuntingRecovery * 60) + if curCount >= conf.HuntingNum { + list.RecoveryTime = 0 + break + } + } else { break } } - count := (configure.Now().Unix() - list.RecoveryTime) / int64(conf.HuntingRecovery*60) // 暂时用维京配置 11月21号统一修改配置 - if count > 1 { - curCount += int32(count) - } - if curCount > conf.VikingNum { - curCount = conf.VikingNum - list.RecoveryTime = 0 - } else { - list.RecoveryTime += count * int64(conf.HuntingRecovery*60) // 更新刷新时间 - } + addCount := curCount - amount if addCount > 0 { if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{ diff --git a/modules/viking/api_buy.go b/modules/viking/api_buy.go index 1ae1f1fb0..9283410a2 100644 --- a/modules/viking/api_buy.go +++ b/modules/viking/api_buy.go @@ -64,19 +64,17 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code if list.RecoveryTime == 0 { list.RecoveryTime = configure.Now().Unix() } - if conf.VikingExpeditionRecoveryTime == 0 { // 配置校验 被除数不能为0 - code = pb.ErrorCode_ConfigNoFound - return - } - count := (configure.Now().Unix() - list.RecoveryTime) / int64(conf.VikingExpeditionRecoveryTime*60) - if count > 1 { - curCount += int32(count) - } - if curCount > conf.VikingNum { - curCount = conf.VikingNum - list.RecoveryTime = 0 - } else { - list.RecoveryTime += count * int64(conf.VikingExpeditionRecoveryTime*60) // 更新刷新时间 + for { // 计算恢复时间 + if list.RecoveryTime+int64(conf.VikingExpeditionRecoveryTime*60) <= configure.Now().Unix() { + curCount++ + list.RecoveryTime += int64(conf.VikingExpeditionRecoveryTime * 60) + if curCount >= conf.HuntingNum { + list.RecoveryTime = 0 + break + } + } else { + break + } } if curCount-amount > 0 { if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{ diff --git a/modules/viking/api_getlist.go b/modules/viking/api_getlist.go index e6c796c58..6545e7622 100644 --- a/modules/viking/api_getlist.go +++ b/modules/viking/api_getlist.go @@ -59,15 +59,17 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq if list.RecoveryTime == 0 { list.RecoveryTime = configure.Now().Unix() } - count := (configure.Now().Unix() - list.RecoveryTime) / int64(conf.VikingExpeditionRecoveryTime*60) - if count > 1 { - curCount += int32(count) - } - if curCount >= conf.VikingNum { - curCount = conf.VikingNum - list.RecoveryTime = 0 - } else { - list.RecoveryTime += count * int64(conf.VikingExpeditionRecoveryTime*60) // 更新刷新时间 + for { // 计算恢复时间 + if list.RecoveryTime+int64(conf.VikingExpeditionRecoveryTime*60) <= configure.Now().Unix() { + curCount++ + list.RecoveryTime += int64(conf.VikingExpeditionRecoveryTime * 60) + if curCount >= conf.HuntingNum { + list.RecoveryTime = 0 + break + } + } else { + break + } } addCount := curCount - amount if addCount > 0 {