战斗开始体力预扣
This commit is contained in:
parent
e97b35ed32
commit
53af65a711
@ -3,6 +3,7 @@ package mainline
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -20,6 +21,8 @@ func (this *apiComp) ChallengeCheck(session comm.IUserSession, req *pb.MainlineC
|
|||||||
func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChallengeReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChallengeReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
curChapter *pb.DBMainline // 当前章节信息
|
curChapter *pb.DBMainline // 当前章节信息
|
||||||
|
ps int32
|
||||||
|
psAnt *cfg.Gameatn
|
||||||
)
|
)
|
||||||
|
|
||||||
code = this.ChallengeCheck(session, req)
|
code = this.ChallengeCheck(session, req)
|
||||||
@ -50,14 +53,37 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
|
|||||||
}
|
}
|
||||||
if curChapter.Ps != 0 {
|
if curChapter.Ps != 0 {
|
||||||
|
|
||||||
if code = this.module.CheckRes(session, node.PsMg); code != pb.ErrorCode_Success { // 扣1点
|
if code = this.module.ConsumeRes(session, node.PsMg, true); code != pb.ErrorCode_Success { // 扣1点
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if code = this.module.CheckRes(session, node.PsConsume); code != pb.ErrorCode_Success {
|
for _, v := range node.PsConsume {
|
||||||
|
if v.A == "attr" && v.T == "ps" {
|
||||||
|
ps += v.N
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, v := range node.PsMg {
|
||||||
|
if v.A == "attr" && v.T == "ps" {
|
||||||
|
ps += v.N
|
||||||
|
}
|
||||||
|
}
|
||||||
|
psAnt = &cfg.Gameatn{
|
||||||
|
A: "attr",
|
||||||
|
T: "ps",
|
||||||
|
N: ps,
|
||||||
|
}
|
||||||
|
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{psAnt}, true); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if code = this.module.CheckRes(session, node.PsMg); code != pb.ErrorCode_Success {
|
|
||||||
|
curChapter.Ps = ps
|
||||||
|
update := map[string]interface{}{
|
||||||
|
"ps": ps,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := this.module.modelMainline.modifyMainlineData(session.GetUserId(), curChapter.Id, update)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,35 +48,33 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
|||||||
code = pb.ErrorCode_MainlineNotFindChapter
|
code = pb.ErrorCode_MainlineNotFindChapter
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 消耗
|
for _, v := range mainline.BranchID {
|
||||||
// if code = this.module.ConsumeRes(session, node.PsConsume, true); code != pb.ErrorCode_Success {
|
if v == int32(req.MainlineId) { // 重复挑战
|
||||||
// return
|
code = pb.ErrorCode_MainlineNotFindChapter
|
||||||
// }
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
// 校验通过
|
// 校验通过
|
||||||
code, isWin = this.module.battle.CheckBattleReport(session, req.Report)
|
code, isWin = this.module.battle.CheckBattleReport(session, req.Report)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !isWin { // 战斗失败直接返回
|
if !isWin { // 战斗失败直接返回
|
||||||
|
// 返还
|
||||||
|
mainline.Ps = 0
|
||||||
|
this.module.modelMainline.modifyMainlineData(session.GetUserId(), mainline.Id, map[string]interface{}{
|
||||||
|
"ps": 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
if code = this.module.DispenseRes(session, node.PsConsume, true); code != pb.ErrorCode_Success { // 扣1点
|
||||||
|
return
|
||||||
|
}
|
||||||
code = pb.ErrorCode_BattleNoWin
|
code = pb.ErrorCode_BattleNoWin
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 胜利返回
|
|
||||||
if code = this.module.DispenseRes(session, node.PsConsume, true); code != pb.ErrorCode_Success { // 扣1点
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range mainline.BranchID {
|
|
||||||
if v == int32(req.MainlineId) { // 重复挑战
|
|
||||||
code = pb.ErrorCode_MainlineNotFindChapter
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if v == int32(req.MainlineId) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res = append(res, node.Award...)
|
res = append(res, node.Award...)
|
||||||
for _, v := range res {
|
for _, v := range node.Award {
|
||||||
if v.A == comm.HeroType {
|
if v.A == comm.HeroType {
|
||||||
hero = append(hero, v.T)
|
hero = append(hero, v.T)
|
||||||
}
|
}
|
||||||
@ -119,12 +117,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
|||||||
if mainline.Intensity < comm.MaxMainlineIntensity {
|
if mainline.Intensity < comm.MaxMainlineIntensity {
|
||||||
_data.Intensity = mainline.Intensity + 1 // 难度+1
|
_data.Intensity = mainline.Intensity + 1 // 难度+1
|
||||||
_data.ChapterId = 1 // 默认第一章节
|
_data.ChapterId = 1 // 默认第一章节
|
||||||
} else { // 全部通关 领奖拜拜
|
|
||||||
if code = this.module.DispenseRes(session, res, true); code != pb.ErrorCode_Success {
|
|
||||||
this.module.Debugf("DispenseRes err:+%v", res)
|
|
||||||
}
|
|
||||||
session.SendMsg(string(this.module.GetType()), MainlineChallengeOverResp, &pb.MainlineChallengeOverResp{Data: mainline, Newheros: newhero, Olv: user.Lv})
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +126,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
|||||||
|
|
||||||
this.module.modelMainline.addNewChapter(session.GetUserId(), _mData)
|
this.module.modelMainline.addNewChapter(session.GetUserId(), _mData)
|
||||||
session.SendMsg(string(this.module.GetType()), MainlineNewChapterPush, &pb.MainlineNewChapterPush{Data: _data}) // 推送新的章节
|
session.SendMsg(string(this.module.GetType()), MainlineNewChapterPush, &pb.MainlineNewChapterPush{Data: _data}) // 推送新的章节
|
||||||
|
|
||||||
}
|
}
|
||||||
// 发奖
|
// 发奖
|
||||||
if code = this.module.DispenseRes(session, res, true); code != pb.ErrorCode_Success {
|
if code = this.module.DispenseRes(session, res, true); code != pb.ErrorCode_Success {
|
||||||
|
Loading…
Reference in New Issue
Block a user