package oldtimes import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" ) func (this *apiComp) GetallCheck(session comm.IUserSession, req *pb.OldtimesGetallReq) (errdata *pb.ErrorData) { return } func (this *apiComp) Getall(session comm.IUserSession, req *pb.OldtimesGetallReq) (errdata *pb.ErrorData) { uid := session.GetUserId() rsp := &pb.OldtimesGetallResp{} d := this.module.modelOldtimes.getDBOldtimes(uid) // 解锁的关卡 var unlockLevelIds []int32 // 更新关卡状态 levels := this.module.combat.GetLevels(uid) for _, chapter := range d.Chapters { if chapter.Status == int32(lock) { continue } for _, level := range chapter.Levels { if level.Status == int32(finish) { unlockLevelIds = append(unlockLevelIds, level.Lid) // continue } conf := this.module.configure.getMaintaskCfgBy(level.Lid) if conf != nil { if v, ok := levels[conf.Stageid]; ok { if v.Pass == 1 || v.Pass == 2 { level.Status = int32(finish) level.Progress = v.Progress if err := this.module.modelOldtimes.updateOldtimes(uid, d); err != nil { this.module.Error("oldtime更新失败", log.Field{Key: "uid", Value: uid}) continue } unlockLevelIds = append(unlockLevelIds, level.Lid) } else if v.Pass == 0 { level.Progress = v.Progress if err := this.module.modelOldtimes.updateOldtimes(uid, d); err != nil { this.module.Error("oldtime更新失败", log.Field{Key: "uid", Value: uid}) continue } } } } } } glmt, err := this.module.configure.getMaintaskCfg() if err != nil || glmt == nil { return } // 查询出前置是已完成的任务ID var levelIds []int32 for _, conf := range glmt.GetDataList() { for _, id := range unlockLevelIds { if conf.SubTask == id { levelIds = append(levelIds, conf.Id) } } } //添加解锁关卡 for _, lid := range levelIds { // 判断是否已加入 if !this.module.modelOldtimes.isExist(lid, d) { levelConf := this.module.configure.getMaintaskCfgBy(lid) if levelConf != nil { chapter := this.module.modelOldtimes.getChatper(levelConf.Group, d) if chapter != nil { chapter.Levels = append(chapter.Levels, &pb.Level{Lid: lid, Status: int32(unlock)}) } else { chapter := &pb.Chapter{ Cid: levelConf.Group, } chapter.Levels = append(chapter.Levels, &pb.Level{Lid: lid, Status: int32(unlock)}) d.Chapters = append(d.Chapters, chapter) } } } } this.module.modelOldtimes.updateOldtimes(uid, d) rsp.Data = d session.SendMsg(string(this.module.GetType()), "getall", rsp) return }