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