主线记录已挑战数据
This commit is contained in:
parent
7b671c59b2
commit
a96dc9884f
@ -40,7 +40,7 @@ func (this *ModelRank) ChangeUserRank(uid string, objId string, value map[string
|
|||||||
func (this *ModelRank) GetRankData(bossType int32) (data []*pb.DBHuntingRank, err error) {
|
func (this *ModelRank) GetRankData(bossType int32) (data []*pb.DBHuntingRank, err error) {
|
||||||
tmpdata := make([]*pb.DBHuntingRank, 0)
|
tmpdata := make([]*pb.DBHuntingRank, 0)
|
||||||
data = make([]*pb.DBHuntingRank, 0)
|
data = make([]*pb.DBHuntingRank, 0)
|
||||||
err = this.Redis.LRange(comm.TableVikingRank, 0, -1, &tmpdata)
|
err = this.Redis.LRange(comm.TableVikingRankList, 0, -1, &tmpdata)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, v := range tmpdata {
|
for _, v := range tmpdata {
|
||||||
if v.Bosstype == bossType {
|
if v.Bosstype == bossType {
|
||||||
|
@ -22,9 +22,9 @@ func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.Mainl
|
|||||||
///挑战主线关卡
|
///挑战主线关卡
|
||||||
func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineChallengeOverReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineChallengeOverReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
curChapter *pb.DBMainline // 当前章节信息
|
mainline *pb.DBMainline // 当前章节信息
|
||||||
bBranch bool // 当前挑战关卡是不是分支
|
bBranch bool // 当前挑战关卡是不是分支
|
||||||
res []*cfg.Gameatn // 小章节奖励
|
res []*cfg.Gameatn // 小章节奖励
|
||||||
)
|
)
|
||||||
res = make([]*cfg.Gameatn, 0)
|
res = make([]*cfg.Gameatn, 0)
|
||||||
|
|
||||||
@ -33,54 +33,47 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
|||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
// 校验关卡存不存在
|
// 校验关卡存不存在
|
||||||
curChapter = this.module.modelMainline.getOneChapterInfo(session.GetUserId(), req.ChapterObj)
|
mainline = this.module.modelMainline.getOneChapterInfo(session.GetUserId(), req.ChapterObj)
|
||||||
if curChapter == nil {
|
if mainline == nil {
|
||||||
code = pb.ErrorCode_MainlineNotFound
|
code = pb.ErrorCode_MainlineNotFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
node := this.module.configure.GetMainlineConfigData(int32(req.MainlineId), curChapter.Intensity)
|
node := this.module.configure.GetMainlineConfigData(int32(req.MainlineId), mainline.Intensity)
|
||||||
if node == nil { // 配置文件校验
|
if node == nil { // 配置文件校验
|
||||||
code = pb.ErrorCode_MainlineNotFindChapter
|
code = pb.ErrorCode_MainlineNotFindChapter
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if node.Route == 1 {
|
for _, v := range mainline.BranchID {
|
||||||
if node.Previoustage != curChapter.MainlineId {
|
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) { // 重复挑战
|
|
||||||
code = pb.ErrorCode_MainlineNotFindChapter
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res = append(res, node.Award...)
|
res = append(res, node.Award...)
|
||||||
|
|
||||||
curChapter.MainlineId = int32(req.MainlineId)
|
mainline.MainlineId = int32(req.MainlineId)
|
||||||
if bBranch {
|
if bBranch {
|
||||||
curChapter.BranchID = append(curChapter.BranchID, int32(req.MainlineId)) // 记录分支关卡
|
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": curChapter.ChapterId,
|
"ChapterId": mainline.ChapterId,
|
||||||
"branchID": curChapter.BranchID,
|
"branchID": mainline.BranchID,
|
||||||
}
|
}
|
||||||
err := this.module.modelMainline.modifyMainlineData(session.GetUserId(), curChapter.Id, update)
|
err := this.module.modelMainline.modifyMainlineData(session.GetUserId(), mainline.Id, update)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
newChaptConfig := this.module.modelMainline.checkNewCapter(curChapter.ChapterId+1, curChapter.Intensity, curChapter.MainlineId)
|
newChaptConfig := this.module.modelMainline.checkNewCapter(mainline.ChapterId+1, mainline.Intensity, mainline.MainlineId)
|
||||||
if newChaptConfig != nil {
|
if newChaptConfig != nil {
|
||||||
// 如果本章节打完 则创建新的章节
|
// 如果本章节打完 则创建新的章节
|
||||||
_data := &pb.DBMainline{}
|
_data := &pb.DBMainline{}
|
||||||
_data.Id = primitive.NewObjectID().Hex()
|
_data.Id = primitive.NewObjectID().Hex()
|
||||||
_data.ChapterId = curChapter.ChapterId + 1
|
_data.ChapterId = mainline.ChapterId + 1
|
||||||
_data.MainlineId = 0 // 第二章数据默认0
|
_data.MainlineId = 0 // 第二章数据默认0
|
||||||
_mData := make(map[string]interface{}, 0)
|
_mData := make(map[string]interface{}, 0)
|
||||||
_data.Uid = session.GetUserId()
|
_data.Uid = session.GetUserId()
|
||||||
@ -90,15 +83,14 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
|||||||
// 推送新的章节
|
// 推送新的章节
|
||||||
session.SendMsg(string(this.module.GetType()), MainlineNewChapterPush, &pb.MainlineNewChapterPush{Data: _data})
|
session.SendMsg(string(this.module.GetType()), MainlineNewChapterPush, &pb.MainlineNewChapterPush{Data: _data})
|
||||||
} else { // 切换下个难度
|
} else { // 切换下个难度
|
||||||
|
node := this.module.configure.GetMainlineConfigData(int32(req.MainlineId+1), mainline.Intensity)
|
||||||
node := this.module.configure.GetMainlineConfigData(int32(req.MainlineId+1), curChapter.Intensity)
|
if node == nil && mainline.Intensity < comm.MaxMainlineIntensity { // 配置文件校验
|
||||||
if node == nil && curChapter.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 // 默认第一章节
|
||||||
_mData := make(map[string]interface{}, 0)
|
_mData := make(map[string]interface{}, 0)
|
||||||
_data.Uid = session.GetUserId()
|
_data.Uid = session.GetUserId()
|
||||||
_data.Intensity = curChapter.Intensity + 1 // 难度+1
|
_data.Intensity = mainline.Intensity + 1 // 难度+1
|
||||||
_mData[_data.Id] = _data
|
_mData[_data.Id] = _data
|
||||||
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})
|
||||||
@ -109,6 +101,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
|||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), MainlineChallengeOverResp, &pb.MainlineChallengeOverResp{Data: curChapter})
|
session.SendMsg(string(this.module.GetType()), MainlineChallengeOverResp, &pb.MainlineChallengeOverResp{Data: mainline})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng
|
|||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
|
|
||||||
viking, err := this.module.modelViking.getVikingList(session.GetUserId())
|
viking, err := this.module.modelViking.getVikingList(session.GetUserId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_VikingBoosType
|
code = pb.ErrorCode_VikingBoosType
|
||||||
|
@ -64,19 +64,21 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
|||||||
}
|
}
|
||||||
viking.Boss[req.BossType] += 1
|
viking.Boss[req.BossType] += 1
|
||||||
mapData["Boss"] = viking.Boss
|
mapData["Boss"] = viking.Boss
|
||||||
// viking.ChallengeTime[req.BossType<<16+req.Difficulty] = 0 // todo 耗时
|
|
||||||
// mapData["challengeTime"] = viking.ChallengeTime
|
if req.Report != nil && len(req.Report.Info.Redflist) > 0 {
|
||||||
sz := make([]*pb.LineUp, 5)
|
sz := make([]*pb.LineUp, 5)
|
||||||
for i, v := range req.Report.Info.Redflist[0].Team {
|
for i, v := range req.Report.Info.Redflist[0].Team {
|
||||||
if v != nil {
|
if v != nil {
|
||||||
sz[i] = &pb.LineUp{
|
sz[i] = &pb.LineUp{
|
||||||
Cid: v.HeroID,
|
Cid: v.HeroID,
|
||||||
Star: v.Star,
|
Star: v.Star,
|
||||||
Lv: v.Lv,
|
Lv: v.Lv,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.module.modulerank.updateVikingRankList(session, req.Difficulty, req.BossType, req.Report.Info.Redflist[0].Leadpos, sz)
|
||||||
}
|
}
|
||||||
this.module.modulerank.updateVikingRankList(session, req.Difficulty, req.BossType, req.Report.Info.Redflist[0].Leadpos, sz)
|
|
||||||
}
|
}
|
||||||
// 耗时校验 当前战斗胜利时间消耗小于之前刷新数据
|
// 耗时校验 当前战斗胜利时间消耗小于之前刷新数据
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ func (this *ModelRank) ChangeUserRank(uid string, objId string, value map[string
|
|||||||
func (this *ModelRank) GetRankData(bossType int32) (data []*pb.DBVikingRank, err error) {
|
func (this *ModelRank) GetRankData(bossType int32) (data []*pb.DBVikingRank, err error) {
|
||||||
tmpdata := make([]*pb.DBVikingRank, 0)
|
tmpdata := make([]*pb.DBVikingRank, 0)
|
||||||
data = make([]*pb.DBVikingRank, 0)
|
data = make([]*pb.DBVikingRank, 0)
|
||||||
err = this.Redis.LRange(comm.TableVikingRank, 0, -1, &tmpdata)
|
err = this.Redis.LRange(comm.TableVikingRankList, 0, -1, &tmpdata)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, v := range tmpdata {
|
for _, v := range tmpdata {
|
||||||
if v.Bosstype == bossType {
|
if v.Bosstype == bossType {
|
||||||
|
Loading…
Reference in New Issue
Block a user