package parkour import ( "go_dreamfactory/comm" "go_dreamfactory/pb" ) //参数校验 func (this *apiComp) RaceMatchCheck(session comm.IUserSession, req *pb.ParkourRaceMatchReq) (errdata *pb.ErrorData) { return } ///匹配请求 func (this *apiComp) RaceMatch(session comm.IUserSession, req *pb.ParkourRaceMatchReq) (errdata *pb.ErrorData) { var ( info *pb.DBParkour err error ) if errdata = this.RaceMatchCheck(session, req); errdata != nil { return } if info, err = this.module.parkourComp.queryinfo(session.GetUserId()); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } if info.Defmts == "" { //没有默认坐骑 errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), Message: "no Defmts!", } return } info.State = pb.RaceTeamState_teaming if req.Rtype == pb.RaceType_ordinary { if err = this.module.matchTrain.MatchReq(&pb.DBMatchPlayer{ Suser: info.User, Dan: info.Dan, Integral: info.Integral, Weekintegral: info.Weekintegral, Mount: info.Mount, Property: info.Property, Mlv: info.Mlv, }); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } } else { if err = this.module.matchrank.MatchReq(&pb.DBMatchPlayer{ Suser: info.User, Dan: info.Dan, Integral: info.Integral, Weekintegral: info.Weekintegral, Mount: info.Mount, Property: info.Property, Mlv: info.Mlv, }); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } } if err = this.module.parkourComp.Change(session.GetUserId(), map[string]interface{}{ "state": pb.RaceTeamState_matching, "rtype": info.Rtype, }); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } session.SendMsg(string(this.module.GetType()), "racematch", &pb.ParkourRaceMatchResp{}) return }