package integral import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) //参数校验 func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.IntegralChallengeOverReq) (errdata *pb.ErrorData) { if req.Nandu <= 0 { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), } return } return } ///挑战主线关卡 func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.IntegralChallengeOverReq) (errdata *pb.ErrorData) { var ( update map[string]interface{} res []*cfg.Gameatn award []*cfg.Gameatn first bool // 是否是首通 line []*pb.LineUp // 阵容数据 harm int32 changExp map[string]int32 atno []*pb.UserAtno // atno 类型 ) changExp = make(map[string]int32) harm = req.Report.Score update = make(map[string]interface{}, 0) if errdata = this.ChallengeOverCheck(session, req); errdata != nil { return // 参数校验失败直接返回 } list, err := this.module.modelIntegral.getIntegralList(session) if err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_PagodaNotFound, Title: pb.ErrorCode_PagodaNotFound.ToString(), } return } if _, ok := list.Score[req.Nandu]; !ok { list.Score[req.Nandu] = harm update["score"] = list.Score first = true } cfgData, err := this.module.configure.GetStageBoss(list.Hid, req.Nandu) if err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, // 道具数量不足 Title: pb.ErrorCode_ConfigNoFound.ToString(), Message: err.Error(), } return } // check errdata, _ = this.module.battle.CheckBattleReport(session, req.Report) if errdata != nil { return } userinfo, err := this.module.GetUserForSession(session) if err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } list.Count++ update["count"] = list.Count // 更新积分数据 if list.Score[req.Nandu] < harm { list.Score[req.Nandu] = harm update["score"] = list.Score } if list.Maxscore < harm { // 更新最大积分数据 list.Maxscore = harm update["maxscore"] = list.Maxscore } list.Totalscore += harm update["totalscore"] = list.Totalscore if first { for _, v := range cfgData.Firstprize { // 发放通关随机奖励 res = append(res, v) } } for _, v := range req.Report.Info.Redflist[0].Team { line = append(line, &pb.LineUp{ Cid: v.HeroID, Star: v.Star, Lv: v.Lv, }) } list.Line[req.Nandu] = &pb.LineData{ Leadpos: req.Report.Info.Redflist[0].Leadpos, Line: line, } update["line"] = list.Line reward := this.module.ModuleTools.GetGroupDataByLottery(cfgData.Drop, userinfo.Vip, userinfo.Lv) res = append(res, reward...) if len(res) > 0 { if errdata = this.module.DispenseRes(session, res, true); errdata != nil { return } go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "IntegralChallengeOverReq", res) }) } if first { res = append(res, cfgData.Firstprize...) } if user, err := this.module.GetUserForSession(session); err == nil { reward = this.module.ModuleTools.GetGroupDataByLottery(cfgData.Drop, user.Vip, user.Lv) res = append(res, reward...) } // 加经验 if cfgData.Heroexp > 0 { var heroObjs []string if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { for _, v := range req.Report.Info.Redflist[0].Team { if v.HeroID != "" { if !v.Ishelp { // 助战英雄不加经验 heroObjs = append(heroObjs, v.Oid) } } } } if changExp, award, errdata = this.module.ModuleHero.AddHerosExp(session, heroObjs, cfgData.Heroexp); errdata != nil { return } res = append(res, award...) } if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil { return } list.Carrybuff[req.Nandu] = &pb.FreightBuff{ Buff: req.Report.Info.Buffer, } update["carrybuff"] = list.Carrybuff var user *pb.DBUser if user, err = this.module.GetUserForSession(session); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Message: err.Error(), } return } list.Uinfo = comm.GetUserBaseInfo(user) update["uinfo"] = list.Uinfo // 更新base if err = this.module.modelIntegral.modifyIntegralData(session.GetUserId(), update); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Message: err.Error(), } return } this.module.modelRank.updateRank(harm, session.GetUserId(), int(req.Nandu)) session.SendMsg(string(this.module.GetType()), "challengeover", &pb.IntegralChallengeOverResp{ Data: list, Atno: atno, Heroexp: changExp, }) // 任务埋点 var tasks []*pb.BuriedParam tasks = append(tasks, comm.GetBuriedParam(comm.Rtype254, 1, req.Nandu)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype255, 1)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype256, req.Report.Grade)) var skillgroup int32 // 异化埋点数据校验 if c, e := this.module.configure.GetIntegralBUffSkillGroup(); e == nil { for _, v := range c { if mp, e := this.module.configure.GetIntegralBUff(v); e == nil { // 必须是一样的 if len(req.Report.Info.Buffer) == len(mp) { skillgroup = v for _, v1 := range req.Report.Info.Buffer { if _, ok := mp[v1]; !ok { skillgroup = 0 break } } } if skillgroup != 0 { break } } } } for _, v := range req.Report.Completetask { if v == 144 { // 临时数据 等配置来 tasks = append(tasks, comm.GetBuriedParam(comm.Rtype257, 1)) } if v == 145 { tasks = append(tasks, comm.GetBuriedParam(comm.Rtype258, 1)) } } if skillgroup != 0 { // 统计型任务 来统计积分boss难度对应的异化值 tasks = append(tasks, comm.GetBuriedParam(comm.Rtype259, 1, skillgroup)) // 改任意难度 } go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.ModuleBuried.TriggerBuried(session, tasks...) }) return }