From b08a29d30fac996573b323de7edf5d8f7bb411e6 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 17 Jul 2023 17:47:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E7=BD=B2=E5=90=8C=E6=AD=A5=20?= =?UTF-8?q?=E4=BD=93=E5=8A=9B=E9=A2=84=E5=85=88=E6=B6=88=E8=80=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hunting/api_challenge.go | 21 +++++++++------------ modules/hunting/api_challengeover.go | 6 +++--- modules/viking/api_challenge.go | 24 ++++++++++-------------- modules/viking/api_challengeover.go | 5 +++-- 4 files changed, 25 insertions(+), 31 deletions(-) diff --git a/modules/hunting/api_challenge.go b/modules/hunting/api_challenge.go index 7df33f977..dfbcc0174 100644 --- a/modules/hunting/api_challenge.go +++ b/modules/hunting/api_challenge.go @@ -47,7 +47,8 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallen return } - if v1, ok := hunting.Ps[req.BossType]; !ok || v1 == 0 { + pskey := req.BossType<<8 + req.Difficulty + if v1, ok := hunting.Ps[pskey]; !ok || v1 == 0 { for _, v := range cfgData.PsConsume { if v.A == "attr" && v.T == "ps" { @@ -69,24 +70,20 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallen return } - hunting.Ps[req.BossType] = ps + hunting.Ps[pskey] = ps this.module.modelHunting.modifyHuntingDataByObjId(session.GetUserId(), map[string]interface{}{ "ps": hunting.Ps, }) } - 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 { + 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) } value, ok := hunting.Boss[req.BossType] diff --git a/modules/hunting/api_challengeover.go b/modules/hunting/api_challengeover.go index 7c32f641a..a95e230a2 100644 --- a/modules/hunting/api_challengeover.go +++ b/modules/hunting/api_challengeover.go @@ -74,10 +74,10 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha hunting.Boss[req.BossType] = req.Difficulty mapData["boss"] = hunting.Boss } - + pskey := req.BossType<<8 + req.Difficulty errdata, bWin = this.module.battle.CheckBattleReport(session, req.Report) - consumPs = hunting.Ps[req.BossType] - hunting.Ps[req.BossType] = 0 // 清空预扣体力值 + consumPs = hunting.Ps[pskey] + hunting.Ps[pskey] = 0 // 清空预扣体力值 mapData["ps"] = hunting.Ps if !bWin { // 战斗失败了 直接返回 diff --git a/modules/viking/api_challenge.go b/modules/viking/api_challenge.go index 4ad0f18cc..bd0dcae3f 100644 --- a/modules/viking/api_challenge.go +++ b/modules/viking/api_challenge.go @@ -37,8 +37,8 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng } return } - - if v1, ok := viking.Ps[req.BossId]; !ok || v1 == 0 { + pskey := req.BossId<<8 + req.Difficulty + if v1, ok := viking.Ps[pskey]; !ok || v1 == 0 { for _, v := range cfgData.PsConsume { if v.A == "attr" && v.T == "ps" { @@ -59,26 +59,22 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng return } - viking.Ps[req.BossId] = ps + viking.Ps[pskey] = ps this.module.modelViking.modifyVikingDataByObjId(session.GetUserId(), map[string]interface{}{ "ps": viking.Ps, }) } - 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 { // 体力不够 + 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) + } if req.Difficulty == 1 && viking.Boss[req.BossId] == 0 { // 当前难度第一次打 diff --git a/modules/viking/api_challengeover.go b/modules/viking/api_challengeover.go index febaac284..90f482084 100644 --- a/modules/viking/api_challengeover.go +++ b/modules/viking/api_challengeover.go @@ -79,8 +79,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal } errdata, bWin = this.module.battle.CheckBattleReport(session, req.Report) - consumPs = viking.Ps[req.BossId] - viking.Ps[req.BossId] = 0 // 清空预扣体力值 + pskey := req.BossId<<8 + req.Difficulty + consumPs = viking.Ps[pskey] + viking.Ps[pskey] = 0 // 清空预扣体力值 mapData["ps"] = viking.Ps if !bWin { // 战斗失败了 直接返回 if errdata = this.module.DispenseRes(session, vikingCfg.PsConsume, true); errdata != nil { // 返还预扣体力