/// <summary> /// Calculation Match Result From Games /// </summary> public void CalculateResultFromGames(PlayerMatch match) { if (match.MatchStatusID != MatchStatuses.Incomplete) { return; } if (match.Games.Count > 0 && match.Games.All(x => x.Game.Completed)) { match.HomeResultTypeID = ResultType.Draw; match.AwayResultTypeID = ResultType.Draw; this.InnerCalculateResultFromGames(match); if (match.HomeResultTypeID == ResultType.Draw || match.AwayResultTypeID == ResultType.Draw) { throw new InvalidOperationException(string.Format("Match [{0}] cannot end in a draw for Knockout Calculation Engines", match.ID)); } match.SetComplete(); } else { match.SetIncomplete(); } }
protected virtual PlayerMatch CreateMatch(bool entrant1Home) { if (this._matches.Count == this.Legs) { throw new InvalidOperationException("Too many Matches added for this fixture. Fixture already has enough matches for the configured number of legs."); } var matchFormat = this.CompetitionRound.CompetitionEvent.GetMatchFormat(); var leg = (byte)(this._matches.Count + 1); var match = new PlayerMatch { PlayerFixture = this, Date = this.PendingDate.Value, Leg = leg, MatchFormat = matchFormat, MatchStatusID = MatchStatuses.Pending }; match.MatchCalculationEngineID = this.CompetitionRound.CompetitionEvent.GetMatchCalculationEngine(); match.Home = entrant1Home ? this.Entrant1 : this.Entrant2; match.Away = entrant1Home ? this.Entrant2 : this.Entrant1; match.VenueTypeID = this.PendingVenueTypeID.Value; match.Pitch = this.ResolvePitch(); if (leg == 1 && match.Pitch != null) { match.SetIncomplete(); } else { match.SetAuditFields(); } this._matches.Add(match); return(match); }