主线流程优化
This commit is contained in:
parent
12dff3377f
commit
0c75ee0f0f
@ -38,18 +38,17 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
|
||||
code = pb.ErrorCode_MainlineNotFindChapter
|
||||
return
|
||||
}
|
||||
if node.Route == 1 {
|
||||
if node.Previoustage != curChapter.MainlineId {
|
||||
|
||||
for _, v := range curChapter.BranchID {
|
||||
if v == int32(req.MainlineId) { // 重复挑战
|
||||
code = pb.ErrorCode_MainlineNotFindChapter
|
||||
return
|
||||
}
|
||||
} else {
|
||||
for _, v := range curChapter.BranchID {
|
||||
if v == int32(req.MainlineId) { // 重复挑战
|
||||
code = pb.ErrorCode_MainlineNotFindChapter
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if node.Previoustage != curChapter.MainlineId {
|
||||
code = pb.ErrorCode_MainlineNotFindChapter
|
||||
return
|
||||
}
|
||||
|
||||
code, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||
|
@ -50,7 +50,10 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if node.Previoustage != mainline.MainlineId {
|
||||
code = pb.ErrorCode_MainlineNotFindChapter
|
||||
return
|
||||
}
|
||||
res = append(res, node.Award...)
|
||||
|
||||
mainline.MainlineId = int32(req.MainlineId)
|
||||
@ -60,7 +63,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
||||
mainline.BranchID = append(mainline.BranchID, int32(req.MainlineId))
|
||||
update := map[string]interface{}{
|
||||
"mainlineId": req.MainlineId,
|
||||
"ChapterId": mainline.ChapterId,
|
||||
"chapterId": mainline.ChapterId,
|
||||
"branchID": mainline.BranchID,
|
||||
}
|
||||
err := this.module.modelMainline.modifyMainlineData(session.GetUserId(), mainline.Id, update)
|
||||
@ -69,22 +72,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
||||
return
|
||||
}
|
||||
newChaptConfig := this.module.modelMainline.checkNewCapter(mainline.ChapterId+1, mainline.Intensity, mainline.MainlineId)
|
||||
if newChaptConfig != nil {
|
||||
// 如果本章节打完 则创建新的章节
|
||||
_data := &pb.DBMainline{}
|
||||
_data.Id = primitive.NewObjectID().Hex()
|
||||
_data.ChapterId = mainline.ChapterId + 1
|
||||
_data.MainlineId = 0 // 第二章数据默认0
|
||||
_mData := make(map[string]interface{}, 0)
|
||||
_data.Uid = session.GetUserId()
|
||||
_mData[_data.Id] = _data
|
||||
|
||||
this.module.modelMainline.addNewChapter(session.GetUserId(), _mData)
|
||||
// 推送新的章节
|
||||
session.SendMsg(string(this.module.GetType()), MainlineNewChapterPush, &pb.MainlineNewChapterPush{Data: _data})
|
||||
} else { // 切换下个难度
|
||||
node := this.module.configure.GetMainlineConfigData(int32(req.MainlineId+1), mainline.Intensity)
|
||||
if node == nil && mainline.Intensity < comm.MaxMainlineIntensity { // 配置文件校验
|
||||
if node.EndFlag > 0 { // 切换下个难度
|
||||
if mainline.Intensity < comm.MaxMainlineIntensity { // 配置文件校验
|
||||
_data := &pb.DBMainline{}
|
||||
_data.Id = primitive.NewObjectID().Hex()
|
||||
_data.ChapterId = 1 // 默认第一章节
|
||||
@ -95,6 +85,19 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
||||
this.module.modelMainline.addNewChapter(session.GetUserId(), _mData)
|
||||
session.SendMsg(string(this.module.GetType()), MainlineNewChapterPush, &pb.MainlineNewChapterPush{Data: _data})
|
||||
}
|
||||
} else if newChaptConfig != nil {
|
||||
// 如果本章节打完 则创建新的章节
|
||||
_data := &pb.DBMainline{}
|
||||
_data.Id = primitive.NewObjectID().Hex()
|
||||
_data.ChapterId = mainline.ChapterId + 1
|
||||
_data.MainlineId = int32(req.MainlineId)
|
||||
_mData := make(map[string]interface{}, 0)
|
||||
_data.Uid = session.GetUserId()
|
||||
_mData[_data.Id] = _data
|
||||
|
||||
this.module.modelMainline.addNewChapter(session.GetUserId(), _mData)
|
||||
// 推送新的章节
|
||||
session.SendMsg(string(this.module.GetType()), MainlineNewChapterPush, &pb.MainlineNewChapterPush{Data: _data})
|
||||
}
|
||||
// 发奖
|
||||
code = this.module.DispenseRes(session, res, true)
|
||||
|
@ -44,14 +44,14 @@ func (this *ModelMainline) addNewChapter(uId string, data map[string]interface{}
|
||||
|
||||
// check NewCapter
|
||||
func (this *ModelMainline) checkNewCapter(chapter, intensity, id int32) *cfg.GameMainlineData {
|
||||
conf := this.module.configure.GetMainlineChapter(chapter + 1)
|
||||
if conf == nil {
|
||||
return nil
|
||||
}
|
||||
newChaptConfig := this.module.configure.GetMainlineChapterConfigData(intensity, chapter+1) // 查下一章节
|
||||
if newChaptConfig.Previoustage == id {
|
||||
return newChaptConfig
|
||||
conf := this.module.configure.GetMainlineChapter(chapter)
|
||||
if conf != nil {
|
||||
nextChaptConfig := this.module.configure.GetMainlineChapterConfigData(intensity, chapter) // 查下一章节
|
||||
if nextChaptConfig.Previoustage == id {
|
||||
return nextChaptConfig
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user