From 3fe6c89068633baeb1a042ed6f528eeb48d9e4a7 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 8 Jun 2023 11:39:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9E=E7=BB=AD=E8=87=AA=E5=8A=A8=E6=88=98?= =?UTF-8?q?=E6=96=97=20=E8=87=AA=E5=8A=A8=E4=BD=BF=E7=94=A8=E4=BD=93?= =?UTF-8?q?=E5=8A=9B=E8=8D=AF=E5=89=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hunting/api_challenge.go | 29 +++++++++++++---------------- modules/viking/api_challenge.go | 30 ++++++++++++++---------------- 2 files changed, 27 insertions(+), 32 deletions(-) diff --git a/modules/hunting/api_challenge.go b/modules/hunting/api_challenge.go index 7981ceaff..4b91c8873 100644 --- a/modules/hunting/api_challenge.go +++ b/modules/hunting/api_challenge.go @@ -80,22 +80,19 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallen "ps": hunting.Ps, }) } - // if errdata = this.module.CheckRes(session, cfgData.PsConsume); errdata != nil { - // if req.AutoBuy { // 不够的时候看是否能自动购买 - // var count int32 - // for _, v := range cfgData.PsConsume { - // if v.N > 0 { - // count += v.N - // } - // } - // if errdata = this.module.ModuleItems.BuyUnifiedTicket(session, count); errdata != nil { - // return - // } - // } else { - // code = pb.ErrorCode_VikingMaxChallengeCount - // return - // } - // } + if errdata = this.module.CheckRes(session, cfgData.PsConsume); errdata != nil { + if req.AutoBuy { // 不够的时候看是否能自动购买 + resSell := this.module.ModuleTools.GetGlobalConf().PsItem + if errdata = this.module.CheckRes(session, []*cfg.Gameatn{resSell}); errdata != nil { + return + } + m := make(map[string]int32, 0) + m[resSell.T] = resSell.N + this.module.ModuleItems.SellItem(session, m, true) + } else { + return + } + } value, ok := hunting.Boss[req.BossType] if !ok { // 类型校验 diff --git a/modules/viking/api_challenge.go b/modules/viking/api_challenge.go index 5fabadf60..bea7f29c3 100644 --- a/modules/viking/api_challenge.go +++ b/modules/viking/api_challenge.go @@ -69,22 +69,20 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng }) } - // if errdata = this.module.CheckRes(session, cfgData.PsConsume); errdata != nil { - // if req.AutoBuy { // 不够的时候自动使用 - // var count int32 - // for _, v := range cfgData.PsConsume { - // if v.N > 0 { - // count += v.N - // } - // } - // if errdata = this.module.ModuleItems.BuyUnifiedTicket(session, count); errdata != nil { - // return - // } - // } else { - // code = pb.ErrorCode_VikingMaxChallengeCount - // return - // } - // } + if errdata = this.module.CheckRes(session, cfgData.PsConsume); errdata != nil { + if req.AutoBuy { // 不够的时候自动使用 + resSell := this.module.ModuleTools.GetGlobalConf().PsItem + if errdata = this.module.CheckRes(session, []*cfg.Gameatn{resSell}); errdata != nil { + return + } + m := make(map[string]int32, 0) + m[resSell.T] = resSell.N + this.module.ModuleItems.SellItem(session, m, true) + + } else { // 体力不够 + return + } + } if req.Difficulty == 1 && viking.Boss[req.BossId] == 0 { // 当前难度第一次打 viking.Boss[req.BossId] = 1