diff --git a/modules/hunting/api_challenge.go b/modules/hunting/api_challenge.go index 7df33f977..6a5a90346 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,21 @@ 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 cb504f180..989ba2694 100644 --- a/modules/hunting/api_challengeover.go +++ b/modules/hunting/api_challengeover.go @@ -78,8 +78,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha } errdata, bWin = this.module.battle.CheckBattleReport(session, req.Report) - consumPs = hunting.Ps[req.BossType] - hunting.Ps[req.BossType] = 0 // 清空预扣体力值 + pskey := req.BossType<<8 + req.Difficulty + 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 40d13c679..938a19826 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" { ps += v.N @@ -54,30 +54,27 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng T: "ps", N: ps, } + this.module.Debugf("开始扣除:%d", ps) if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{psAnt}, true); errdata != nil { 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 681433040..6c8b23a5a 100644 --- a/modules/viking/api_challengeover.go +++ b/modules/viking/api_challengeover.go @@ -78,9 +78,10 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal mapData["boss"] = viking.Boss } + pskey := req.BossId<<8 + req.Difficulty errdata, bWin = this.module.battle.CheckBattleReport(session, req.Report) - consumPs = viking.Ps[req.BossId] - viking.Ps[req.BossId] = 0 // 清空预扣体力值 + 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 { // 返还预扣体力