主线流程优化
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
|
code = pb.ErrorCode_MainlineNotFindChapter
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if node.Route == 1 {
|
|
||||||
if node.Previoustage != curChapter.MainlineId {
|
for _, v := range curChapter.BranchID {
|
||||||
|
if v == int32(req.MainlineId) { // 重复挑战
|
||||||
code = pb.ErrorCode_MainlineNotFindChapter
|
code = pb.ErrorCode_MainlineNotFindChapter
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
for _, v := range curChapter.BranchID {
|
|
||||||
if v == int32(req.MainlineId) { // 重复挑战
|
if node.Previoustage != curChapter.MainlineId {
|
||||||
code = pb.ErrorCode_MainlineNotFindChapter
|
code = pb.ErrorCode_MainlineNotFindChapter
|
||||||
return
|
return
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
code, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||||
|
@ -50,7 +50,10 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if node.Previoustage != mainline.MainlineId {
|
||||||
|
code = pb.ErrorCode_MainlineNotFindChapter
|
||||||
|
return
|
||||||
|
}
|
||||||
res = append(res, node.Award...)
|
res = append(res, node.Award...)
|
||||||
|
|
||||||
mainline.MainlineId = int32(req.MainlineId)
|
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))
|
mainline.BranchID = append(mainline.BranchID, int32(req.MainlineId))
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
"mainlineId": req.MainlineId,
|
"mainlineId": req.MainlineId,
|
||||||
"ChapterId": mainline.ChapterId,
|
"chapterId": mainline.ChapterId,
|
||||||
"branchID": mainline.BranchID,
|
"branchID": mainline.BranchID,
|
||||||
}
|
}
|
||||||
err := this.module.modelMainline.modifyMainlineData(session.GetUserId(), mainline.Id, update)
|
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
|
return
|
||||||
}
|
}
|
||||||
newChaptConfig := this.module.modelMainline.checkNewCapter(mainline.ChapterId+1, mainline.Intensity, mainline.MainlineId)
|
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)
|
if node.EndFlag > 0 { // 切换下个难度
|
||||||
// 推送新的章节
|
if mainline.Intensity < comm.MaxMainlineIntensity { // 配置文件校验
|
||||||
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 { // 配置文件校验
|
|
||||||
_data := &pb.DBMainline{}
|
_data := &pb.DBMainline{}
|
||||||
_data.Id = primitive.NewObjectID().Hex()
|
_data.Id = primitive.NewObjectID().Hex()
|
||||||
_data.ChapterId = 1 // 默认第一章节
|
_data.ChapterId = 1 // 默认第一章节
|
||||||
@ -95,6 +85,19 @@ 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})
|
||||||
}
|
}
|
||||||
|
} 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)
|
code = this.module.DispenseRes(session, res, true)
|
||||||
|
@ -44,14 +44,14 @@ func (this *ModelMainline) addNewChapter(uId string, data map[string]interface{}
|
|||||||
|
|
||||||
// check NewCapter
|
// check NewCapter
|
||||||
func (this *ModelMainline) checkNewCapter(chapter, intensity, id int32) *cfg.GameMainlineData {
|
func (this *ModelMainline) checkNewCapter(chapter, intensity, id int32) *cfg.GameMainlineData {
|
||||||
conf := this.module.configure.GetMainlineChapter(chapter + 1)
|
conf := this.module.configure.GetMainlineChapter(chapter)
|
||||||
if conf == nil {
|
if conf != nil {
|
||||||
return nil
|
nextChaptConfig := this.module.configure.GetMainlineChapterConfigData(intensity, chapter) // 查下一章节
|
||||||
}
|
if nextChaptConfig.Previoustage == id {
|
||||||
newChaptConfig := this.module.configure.GetMainlineChapterConfigData(intensity, chapter+1) // 查下一章节
|
return nextChaptConfig
|
||||||
if newChaptConfig.Previoustage == id {
|
}
|
||||||
return newChaptConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user