/// <summary> /// ホームチーム直近試合結果計算処理 /// </summary> public JlgGameResultCounts CalculateJlgRecentGameResultCounts(int TargetTeamId, IEnumerable<IJlgRecentResults> targetRecentGameResults) { var jlgRecentGameResultCounts = new JlgGameResultCounts(); var homeItems = targetRecentGameResults.Where(m => m.HomeTeamId == TargetTeamId).ToList(); foreach (var item in homeItems) { IncrementRecentGameResultCounts(jlgRecentGameResultCounts, item.HomeScore.Value, item.AwayScore.Value); } var awayItems = targetRecentGameResults.Where(m => m.AwayTeamId == TargetTeamId).ToList(); foreach (var item in awayItems) { IncrementRecentGameResultCounts(jlgRecentGameResultCounts, item.AwayScore.Value, item.HomeScore.Value); } return jlgRecentGameResultCounts; }
/// <summary> /// 直近試合結果インクリメント /// </summary> private static void IncrementRecentGameResultCounts(JlgGameResultCounts jlgRecentGameResultCounts, int ownScore, int enemiesScore) { if (ownScore > enemiesScore) { jlgRecentGameResultCounts.WinCount += 1; } else if (ownScore == enemiesScore) { jlgRecentGameResultCounts.DrawCount += 1; } else if (ownScore < enemiesScore) { jlgRecentGameResultCounts.LoseCount += 1; } }