/// <summary> /// Updates the specified results. /// </summary> /// <param name="results">The results.</param> public void Update(GameResults results) { this.gamesPlayed++; this.totalRuns += results.ScoreBoard.HomeScore; this.totalRuns += results.ScoreBoard.VisitorScore; if ((results.ScoreBoard.Inning - 1) != 9) { this.extraInningGames++; } foreach (var team in results.PlayerStatsDictionary) { foreach (var key in team.Keys) { var player = team[key]; this.TotalHits += player.BattingStats.Hits; } } }
/// <summary> /// Handles post game fatigue values. /// </summary> /// <param name="teams">The teams.</param> /// <param name="results">The results.</param> public void PostGame(Team[] teams, GameResults results) { for (Int32 loopCount = 0; loopCount < 2; loopCount++) { var pitchers = results.Pitchers[loopCount]; Boolean starter = true; foreach (var pitcher in pitchers) { // Get the pitcher's fatigue Fatigue fatigue = this.GetPlayerFatigue(pitcher.Identifier); // Increment streak fatigue.Streak++; // Find pitcher's gane stats var stats = results.GetPitchersStats(pitcher.Identifier); if (stats != null) { Double daysOff = 0; Double inningsPitched = stats.TotalOuts / 3.0; if (starter) { daysOff = Math.Sqrt((inningsPitched * 3) / 4) + 1; } else { daysOff = Math.Sqrt(inningsPitched * 4) - 1.4; } daysOff = Math.Floor(daysOff); fatigue.DaysOff = (Int32)daysOff; } if (fatigue.Streak >= 3) { fatigue.DaysOff++; } starter = false; } teams[loopCount].Players.SortByStat(StatToSort.Innings); foreach (var player in teams[loopCount].Players) { if (player.PitchingStats.Innings > 0) { if (pitchers.Contains(player) == false) { // Get the pitcher's fatigue Fatigue fatigue = this.GetPlayerFatigue(player.Identifier); fatigue.Streak = 0; if (fatigue.DaysOff > 0) { fatigue.DaysOff--; } } } } } }