/// <summary> /// Calculates win-loss-tie for a given team in a given list of matches. /// </summary> /// <param name="teamKey">The team in question (ex. "frc254")</param> /// <param name="matches">The list of matches the team was in.</param> /// <returns>A TBATeamRecord object containing the record of the team.</returns> public TBATeamRecord getTeamRecordAtEvent(string teamKey, List <TBAMatch> matches) { TBATeamRecord record = new TBATeamRecord(); foreach (TBAMatch match in matches) { if (match.alliances.blue.score > match.alliances.red.score) { if (match.alliances.blue.teams.Contains(teamKey)) { record.wins++; } else { record.losses++; } } else if (match.alliances.red.score > match.alliances.blue.score) { if (match.alliances.blue.teams.Contains(teamKey)) { record.losses++; } else { record.wins++; } } else if (match.alliances.blue.score == match.alliances.red.score) { record.ties++; } } return(record); }
/// <summary> /// Calculates win-loss-tie for a given team in a given list of matches. /// </summary> /// <param name="teamKey">The team in question (ex. "frc254")</param> /// <param name="matches">The list of matches the team was in.</param> /// <returns>A TBATeamRecord object containing the record of the team.</returns> public TBATeamRecord getTeamRecordAtEvent(string teamKey, List<TBAMatch> matches) { TBATeamRecord record = new TBATeamRecord(); foreach (TBAMatch match in matches) { if (match.alliances.blue.score > match.alliances.red.score) { if (match.alliances.blue.teams.Contains(teamKey)) { record.wins++; } else { record.losses++; } } else if (match.alliances.red.score > match.alliances.blue.score) { if (match.alliances.blue.teams.Contains(teamKey)) { record.losses++; } else { record.wins++; } } else if (match.alliances.blue.score == match.alliances.red.score) { record.ties++; } } return record; }