public static IEnumerable<PlayEvent> SplitIntoMultiplePenalties(this IList<PlayEvent> penalties) { var penaltyList = new List<PlayEvent>(); penaltyList.AddRange(penalties.Where(p => !p.PenaltyIsDouble)); foreach (var playEvent in penalties.Where(p => p.PenaltyIsDouble)) { var extraPenalty = new PlayEvent(playEvent); if (playEvent.Description.Contains("2 + 2")) { var endTime = playEvent.StartTime + 120; playEvent.EndTime = endTime; extraPenalty.StartTime = endTime; } if (playEvent.Description.Contains("2 + 10")) { var endTime = playEvent.StartTime + 120; playEvent.EndTime = endTime; extraPenalty.StartTime = endTime; extraPenalty.EndTime = extraPenalty.StartTime + 600; } if (playEvent.Description.Contains("5 + GM")) { var endTime = playEvent.StartTime + 300; playEvent.EndTime = endTime; extraPenalty.StartTime = endTime; extraPenalty.EndTime = extraPenalty.StartTime + 1200; } penaltyList.Add(playEvent); penaltyList.Add(extraPenalty); } return penaltyList; }
public void HandlePowerPlayGoal(PlayEvent powerPlayGoal) { var penaltyThatExpiresForPowerPlayGoal = GetPenaltyThatExpiresForPowerPlayGoal(powerPlayGoal); if (penaltyThatExpiresForPowerPlayGoal == null) { Logger.Debug(string.Format("{1} No expiring Penalty for PP Second {0}", powerPlayGoal.StartTime.ToClockTime(), _gameId)); return; } Logger.Debug(string.Format("{4} Penalty for PP Second {0} => S {1} E {2} D {3}", powerPlayGoal.StartTime.ToClockTime(), penaltyThatExpiresForPowerPlayGoal.StartTime.ToClockTime(), penaltyThatExpiresForPowerPlayGoal.EndTime.ToClockTime(), penaltyThatExpiresForPowerPlayGoal.Description, _gameId)); penaltyThatExpiresForPowerPlayGoal.EndTime = powerPlayGoal.StartTime; ExpirePenalties(new List<PlayEvent> { penaltyThatExpiresForPowerPlayGoal }); }
private PlayEvent GetPenaltyThatExpiresForPowerPlayGoal(PlayEvent powerPlayGoal) { var penalties = _penalties .WithoutKvittningar() .OrderBy(p => p.PenaltyTime) .Where(p => p.PenaltyIsMinor) .Where(p => p.HomeTeam != powerPlayGoal.HomeTeam) .Where(p => p.StartTime <= powerPlayGoal.StartTime && p.EndTime >= powerPlayGoal.StartTime); return penalties.FirstOrDefault(); }
private void Log(PlayEvent playEvent, int second) { Logger.Debug(string.Format("{4} Start Second {0} => S {1} E {2} D {3} PoI {5} Ha {6} Cs {7} Home {8}", second.ToClockTime(), playEvent.StartTime.ToClockTime(), playEvent.EndTime.ToClockTime(), playEvent.Description, _gameId, _penaltyBox.PlayersOnIce, _homeTeamAdvantage, _scoreBoard.CurrentScore, playEvent.HomeTeam)); }