diff --git a/src/MLBClient.cs b/src/MLBClient.cs index 715280d..a2e827b 100644 --- a/src/MLBClient.cs +++ b/src/MLBClient.cs @@ -21,6 +21,7 @@ public class MLBClient : IMLBClient { private static HttpClient _httpClient = new HttpClient(); private static readonly string _baseUrl = "https://statsapi.mlb.com/api/v1"; + private static readonly short _outsInCompletedInning = 3; private async Task GetResponseAsync(string endpoint) { @@ -197,6 +198,10 @@ public async Task> GetLineScoreAsync(int gameId) { CurrentInning = lineScoresJson?.currentInning, InningHalf = lineScoresJson?.inningHalf, + // If it's the last inning, use outs from the dto. Otherwise, use the number + // of outs in an inning. In the v1 api, "outs" at the root is the current number + // of outs in the current inning; it should not be extrapolated to all innings. + Outs = inning?.num == lineScoresJson?.currentInning ? lineScoresJson?.outs : _outsInCompletedInning, ScheduledInnings = lineScoresJson?.scheduledInnings, HometeamRuns = lineScoresJson?.teams?.home?.runs, HometeamHits = lineScoresJson?.teams?.home?.hits, diff --git a/src/Models/Linescore.cs b/src/Models/Linescore.cs index 51e98c5..0cecfc2 100644 --- a/src/Models/Linescore.cs +++ b/src/Models/Linescore.cs @@ -13,7 +13,12 @@ public class Linescore public string? InningHalf { get; set; } /// - /// The number of innings scheduled for the game.. + /// The number of outs in this half of the inning. + /// + public int? Outs { get; set; } + + /// + /// The number of innings scheduled for the game. /// public int? ScheduledInnings { get; set; }