public RecordLite(Team team, Match match) { Team = team; TeamID = team != null ? team.Number : -1; Match = match; MatchID = match != null ? match.Number : -1; if (match != null) { Color = match.GetTeamColor(team); Position = match.GetTeamPosition(team); Ratings = new RatingSet(); } }
/// <summary> /// Get alliance color of a team. /// </summary> /// <param name="team">Team whose color to get</param> /// <returns>Color of team, Indeterminate if team isn't found</returns> public AllianceColor GetTeamColor(Team team) { if (team == null) { Util.DebugLog(LogLevel.Critical, "Team is null."); return AllianceColor.Indeterminate; } if (BlueAlliance.Contains(team)) { return AllianceColor.Blue; } else if (RedAlliance.Contains(team)) { return AllianceColor.Red; } else { Util.DebugLog(LogLevel.Error, "Neither alliance contains team " + team.Number.ToString()); return AllianceColor.Indeterminate; } }
public TeamAnalysis LoadTeam(Team team) { return LoadTeam(team.Number); }
/// <summary> /// Instantiates a Tote goal (TOTE). /// </summary> /// <param name="team">Team who placed the tote</param> /// <param name="time">Time at which the tote was placed</param> /// <returns>New Goal of type Gray Tote</returns> public static Goal MakeGrayTote(Team team, int time, AllianceColor col) { return(new Goal(GoalType.GrayTote, time, team, col, false, null, null, false, false, 0)); }
/// <summary> /// Instantiates a pregame recording of a match /// </summary> /// <param name="number">Match number</param> /// <param name="team">Team number</param> /// <param name="alliance">Alliance number</param> public RecordedMatch(int number, Team team, AllianceColor alliance) { MatchNumber = number; TrackedTeam = team; TrackedTeamID = team.Number; TeamDescription = team.Description; TeamExpectations = team.Expectations; Alliance = alliance; ScoredGoals = new List<Goal>(); AlliancePenalties = new List<Penalty>(); Working = true; // default Defense = -1; // default Winner = AllianceColor.Indeterminate; // indeterminate AllianceFinalScore = -1; // starting value }
/// <summary> /// Gets whether a team was functioning properly in this match. /// </summary> /// <param name="team">Team in question</param> /// <returns>True if working, false if malfunctioning</returns> public bool GetWorking(Team team) { AllianceColor color = GetTeamColor(team); if (color == AllianceColor.Blue) { AlliancePosition pos = BlueAlliance.GetPositionOf(team); return BlueWorking[pos]; } else if (color == AllianceColor.Red) { AlliancePosition pos = RedAlliance.GetPositionOf(team); return RedWorking[pos]; } else { Util.DebugLog(LogLevel.Critical, "Invalid alliance color: " + color.ToString()); throw new IndexOutOfRangeException("Invalid alliance color: " + color.ToString()); } }
private void UpdateTeamSummary(Team team) { if (team == null) { TeamHeaderTxt.Text = "NULL"; TeamLocationTxt.Text = "NULL"; TeamDescriptionTxt.Text = "NULL"; return; } TeamHeaderTxt.Text = team.ToString(); TeamLocationTxt.Text = "From " + team.School; TeamDescriptionTxt.Text = team.Description; }
/// <summary> /// Instantiates a Tote goal (TOTE). /// </summary> /// <param name="team">Team who placed the tote</param> /// <param name="time">Time at which the tote was placed</param> /// <returns>New Goal of type Gray Tote</returns> public static Goal MakeGrayTote(Team team, int time, AllianceColor col) { return new Goal(GoalType.GrayTote, time, team, col, false, null, null, false, false, 0); }
/// <summary> /// Instantiates a Contanier goal (CONTAINER). /// </summary> /// <param name="level">Vertical level of the container</param> /// <param name="team">Team who placed the container</param> /// <param name="time">Time at which the container was placed</param> /// <returns>New Goal of type Container</returns> public static Goal MakeContainerTeleop(int level, Team team, int time, AllianceColor col) { return new Goal(GoalType.ContainerTeleop, time, team, col, false, null, level, false, false, 0); }
/// <summary> /// Creates an instance of goal. Using the static methods is preferrable. /// </summary> /// <param name="type">Type of goal scored</param> /// <param name="timeScored">Time at which the goal was scored, in seconds</param> /// <param name="scorer">Scoring team, null if an alliance or all teams</param> /// <param name="scorerAl">Alliance color of scoring team/alliance, null if all teams</param> /// <param name="auto">True if scored in autonomous, false if in teleop</param> /// <param name="stack">True if a stacked form of the goal, null if inapplicable</param> /// <param name="level"> /// Level the container was at when scored, null for all other /// goal types. /// </param> /// <param name="alliance">True if scored by the entire alliance</param> /// <param name="global">True if scored by all participating teams (coopertition)</param> internal Goal(GoalType type, int timeScored, Team scorer, AllianceColor? scorerAl, bool auto, bool? stack, int? level, bool alliance, bool global, int dummy) { Type = type; TimeScoredInt = timeScored; ScoringTeam = scorer; if (scorer != null) { ScoringTeamID = scorer.Number; } ScoringAlliance = scorerAl; Autonomous = auto; Stack = stack; FullAlliance = alliance; Global = global; Level = level; }
/// <summary> /// Performs additional loading once deserialized from JSON /// </summary> /// <param name="e">Event to create references from</param> public void PostJsonLoading(FrcEvent e) { if (ScoringTeamID.HasValue) { ScoringTeam = e.LoadTeam(ScoringTeamID.Value); } else { ScoringTeam = null; } }
public TeamDataContext(Team t, AllianceColor col) { Team = t; Color = col; }
/// <summary> /// Instantiates a Recycled Litter goal (RECYCLED LITTER). /// </summary> /// <param name="team">Team who recycled the litter</param> /// <param name="time">Time at which the litter was recycled</param> /// <returns>New Goal of type Recycled Litter</returns> public static Goal MakeRecycledLitter(Team team, int time, AllianceColor col) { return(new Goal(GoalType.RecycledLitter, time, team, col, false, null, null, false, false, 0)); }
/// <summary> /// Instantiates a Contanier goal (CONTAINER). /// </summary> /// <param name="level">Vertical level of the container</param> /// <param name="team">Team who placed the container</param> /// <param name="time">Time at which the container was placed</param> /// <returns>New Goal of type Container</returns> public static Goal MakeContainerTeleop(int level, Team team, int time, AllianceColor col) { return(new Goal(GoalType.ContainerTeleop, time, team, col, false, null, level, false, false, 0)); }
public AlliancePosition GetTeamPosition(Team team) { if (team == null) { Util.DebugLog(LogLevel.Critical, "Team is null."); return AlliancePosition.A; } AllianceColor color = GetTeamColor(team); if (color == AllianceColor.Blue) { return BlueAlliance.GetIndexOf(team); } else if (color == AllianceColor.Red) { return RedAlliance.GetIndexOf(team); } else { Util.DebugLog(LogLevel.Error, "Neither alliance contains team."); return AlliancePosition.A; } }
/// <summary> /// Instantiates a Recycled Litter goal (RECYCLED LITTER). /// </summary> /// <param name="team">Team who recycled the litter</param> /// <param name="time">Time at which the litter was recycled</param> /// <returns>New Goal of type Recycled Litter</returns> public static Goal MakeRecycledLitter(Team team, int time, AllianceColor col) { return new Goal(GoalType.RecycledLitter, time, team, col, false, null, null, false, false, 0); }
/// <summary> /// Gets all goals scored by a team, including those scored by the /// whole alliance and global goals. /// </summary> /// <param name="team">Team whose goals to retrieve</param> /// <returns>List of goals scored by the team</returns> public List<Goal> GetGoalsByTeam(Team team) { AllianceColor color = GetTeamColor(team); if (Goals == null) { return new List<Goal>(); } return Goals.FindAll((g) => { if (g.Global) { return true; } if (g.FullAlliance) { if (g.ScoringAlliance.HasValue) { return g.ScoringAlliance == color; } return false; // INVALID } return g.ScoringTeam == team; }); }
/// <summary> /// Instantiates a new penalty object /// </summary> /// <param name="time">Time the penalty was scored</param> /// <param name="reason">Reason given for the penalty</param> /// <param name="penalizedAlliance">Alliance penalized</param> /// <param name="teamID">ID of team at fault</param> public Penalty(int time, string reason, AllianceColor penalizedAlliance, Team team) { TimeOfPenaltyInt = time; Reasoning = reason; PenalizedAlliance = penalizedAlliance; BlamedTeam = team; if (BlamedTeam != null) { BlamedTeamID = team.Number; } }
/// <summary> /// Gets the defense rating of a team. /// </summary> /// <param name="team">Team in question</param> /// <returns>Defense rating of team</returns> public int GetDefense(Team team) { AllianceColor color = GetTeamColor(team); if (color == AllianceColor.Blue) { AlliancePosition pos = BlueAlliance.GetPositionOf(team); return BlueDefense[pos]; } else if (color == AllianceColor.Red) { AlliancePosition pos = RedAlliance.GetPositionOf(team); return RedDefense[pos]; } else { Util.DebugLog(LogLevel.Error, "Invalid alliance color: " + color.ToString()); return -1; } }
public Team MakeTeam() { Team res = new Team(); res.Number = TeamNumber; res.Name = TeamName; res.School = Location; res.Description = Description; res.Expectations = Expectations; return res; }
private void UpdateTeamAnalysis(Team team, TeamAnalysis analysis) { if (team == null || analysis == null) { TeamWorkingTxt.Text = "NULL"; TeamWorkingTxt.Foreground = new SolidColorBrush(TITLE_GRAY); WinrateValText.Text = "NULL"; WinRateZText.Text = "NULL"; ScoredPointsValText.Text = "NULL"; ScoredPointsZText.Text = "NULL"; FinalScoreValText.Text = "NULL"; FinalScoreZText.Text = "NULL"; PenaltiesValText.Text = "NULL"; PenaltiesZText.Text = "NULL"; DefenseValText.Text = "NULL"; DefenseZText.Text = "NULL"; ResponsivenessValText.Text = "NULL"; ResponsivenessZText.Text = "NULL"; return; } TeamWorkingTxt.Text = analysis.WorkingCurrently ? "WORKING" : "MALFUNCTIONING"; TeamWorkingTxt.Foreground = new SolidColorBrush( analysis.WorkingCurrently ? WORKING_GREEN : MALFUNCTIONING_RED); WinrateValText.Text = analysis.WinRate.ToStringPct(); WinRateZText.Text = "[z = " + analysis.WinRateZ.ToString() + "]"; ScoredPointsValText.Text = analysis.ScoredPoints.ToString(); ScoredPointsZText.Text = "[z = " + analysis.ScoredPoints.CenterZScore.ToString() + "]"; FinalScoreValText.Text = analysis.FinalScore.ToString(); FinalScoreZText.Text = "[z = " + analysis.FinalScore.CenterZScore.ToString() + "]"; PenaltiesValText.Text = analysis.Penalties.ToString(); PenaltiesZText.Text = "[z = " + analysis.Penalties.CenterZScore.ToString() + "]"; DefenseValText.Text = analysis.Defense.ToString(); DefenseZText.Text = "[z = " + analysis.Defense.CenterZScore.ToString() + "]"; ResponsivenessValText.Text = analysis.ResponsivenessRate.ToStringPct(); ResponsivenessZText.Text = "[z = " + analysis.ResponsivenessRateZ.ToString() + "]"; }
/// <summary> /// Instantiates an analysis object /// </summary> /// <param name="e">Host event</param> /// <param name="linked">Corresponding team</param> public TeamAnalysis(FrcEvent e, Team linked) { Event = e; Team = linked; }