package parkour import ( "go_dreamfactory/comm" "go_dreamfactory/pb" ) //参数校验 func (this *apiComp) RaceMatchCheck(session comm.IUserSession, req *pb.ParkourRaceMatchReq) (code pb.ErrorCode) { if session.GetUserId() != req.Captainid { code = pb.ErrorCode_ReqParameterError } return } ///匹配请求 func (this *apiComp) RaceMatch(session comm.IUserSession, req *pb.ParkourRaceMatchReq) (code pb.ErrorCode, data *pb.ErrorData) { var ( team *pb.DBParkour users []string err error ) if code = this.RaceMatchCheck(session, req); code != pb.ErrorCode_Success { return } if team, err = this.module.parkourComp.queryinfo(session.GetUserId()); err != nil { code = pb.ErrorCode_DBError return } if team.Captainid != session.GetUserId() { code = pb.ErrorCode_ReqParameterError return } if err = this.module.match(team); err != nil { code = pb.ErrorCode_DBError return } users = make([]string, len(team.Member)) for i, v := range team.Member { if !v.Isai { users[i] = v.Uid if err = this.module.parkourComp.Change(v.Uid, map[string]interface{}{ "state": pb.RaceTeamState_matching, }); err != nil { code = pb.ErrorCode_DBError return } } } this.module.SendMsgToUsers(string(this.module.GetType()), "racematchstart", &pb.ParkourRaceMatchStartPush{Team: team}, users...) session.SendMsg(string(this.module.GetType()), "racematch", &pb.ParkourRaceMatchResp{}) return }