package pagoda import ( "go_dreamfactory/comm" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" ) // 参数校验 func (this *apiComp) ChallengeCycleCheck(session comm.IUserSession, req *pb.PagodaChallengeCycleReq) (errdata *pb.ErrorData) { if req.Floor <= 0 { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), } return } return } // /六合塔开始挑战 func (this *apiComp) ChallengeCycle(session comm.IUserSession, req *pb.PagodaChallengeCycleReq) (errdata *pb.ErrorData) { var ( pagoda *pb.DBPagodaCycle err error pType pb.PlayType ) if errdata = this.ChallengeCycleCheck(session, req); errdata != nil { return // 参数校验失败直接返回 } pagoda, err = this.module.modelCyclePagoda.getPagodaCycleList(session.GetUserId()) if err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_PagodaNotFound, Title: pb.ErrorCode_PagodaNotFound.ToString(), } return } conf, err := this.module.configure.GetPagodaCirculateConf(pagoda.Itype, req.Floor) if err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_PagodaNotFound, Title: pb.ErrorCode_PagodaNotFound.ToString(), Message: err.Error(), } return } //判断开启时间 curWeekDay := int32(configure.Now().Weekday()) if curWeekDay == 0 { curWeekDay = 7 } if _, ok := pagoda.Data[conf.Floors]; !ok { if pagoda.Maxfloor+1 != conf.Floors { errdata = &pb.ErrorData{ // 挑战关卡数据不匹配 Code: pb.ErrorCode_PagodaLevlErr, Title: pb.ErrorCode_PagodaLevlErr.ToString(), } return } } if pagoda.Battlecount > 9999 { // 暂时不做限制 errdata = &pb.ErrorData{ // 今日挑战达到上限 Code: pb.ErrorCode_PagodaMaxCount, Title: pb.ErrorCode_PagodaMaxCount.ToString(), } return } errdata, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{ Rulesid: conf.BattlereadyID, Ptype: pType, Title: "", Format: req.Battle, Mformat: conf.Monsterlineup, }) if errdata != nil { return } session.SendMsg(string(this.module.GetType()), "challengecycle", &pb.PagodaChallengeCycleResp{ Info: &pb.BattleInfo{ Id: record.Id, Title: record.Title, Rulesid: conf.BattlereadyID, Btype: record.Btype, Ptype: record.Ptype, RedCompId: record.RedCompId, Redflist: record.Redflist, BlueCompId: record.BlueCompId, Buleflist: record.Buleflist, Tasks: record.Tasks, }, Floor: req.Floor, }) return }