更新 优化体力

This commit is contained in:
meixiongfeng 2023-07-17 17:44:27 +08:00
parent 8d5eaf8547
commit 7a8ddde9dd
4 changed files with 27 additions and 30 deletions

View File

@ -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,13 +70,13 @@ 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 {
@ -84,9 +85,6 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallen
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]

View File

@ -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 { // 战斗失败了 直接返回

View File

@ -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,18 +54,18 @@ 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 {
@ -75,9 +75,6 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng
m[resSell.T] = resSell.N
this.module.ModuleItems.SellItem(session, m, true)
} else { // 体力不够
return
}
}
if req.Difficulty == 1 && viking.Boss[req.BossId] == 0 { // 当前难度第一次打

View File

@ -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 { // 返还预扣体力