public virtual PlayerMatchXGame AddGame(MatchFormatXGameVariation matchFormatGameVariation, Game.Game game) { if (game == null) { throw new ArgumentNullException(nameof(game)); } var existing = this.Games.SingleOrDefault(x => x.MatchFormatXGameVariation.ID == matchFormatGameVariation.ID); if (existing != null) { throw new InvalidOperationException($"Game for Variation ID {matchFormatGameVariation.ID} has already been added"); } var matchGame = new PlayerMatchXGame(); matchGame.Match = this; matchGame.MatchFormatXGameVariation = matchFormatGameVariation; matchGame.Game = game; this.Games.Add(matchGame); //if (!this._games.Add(matchGame)) { //throw new InvalidOperationException("Game already added to Match."); } return(matchGame); }
public virtual TeamMatchXGame AddGame(MatchFormatXGameVariation matchFormatGameVariation, Game.Game game) { if (game == null) { throw new ArgumentNullException(nameof(game)); } var existing = this.Games.SingleOrDefault(x => x.MatchFormatXGameVariation.ID == matchFormatGameVariation.ID); if (existing != null) { throw new InvalidOperationException($"Game for Variation ID {matchFormatGameVariation.ID} has already been added"); } var matchGame = new TeamMatchXGame { Match = this, MatchFormatXGameVariation = matchFormatGameVariation, Game = game }; this.Games.Add(matchGame); return(matchGame); }
public static MatchFormatGameVariationDto AssembleDto(this MatchFormatXGameVariation data) { return(new MatchFormatGameVariationDto { ID = data.ID, Handicap = data.Handicap, Sequence = data.Sequence, GameVariation = data.GameVariation.AssembleDto(), GameCalculationEngine = data.GameCalculationEngineID }); }
private void GuardCheckLoadedPlayerGenders(IEnumerable <Player> players, MatchFormatXGameVariation matchConfiguration) { // Only check when not mixed as mixed games will allow different sexes!!! Genders genderToCheck = matchConfiguration.GameVariation.GenderID; if (genderToCheck != Genders.Mixed) { if (players.Any(x => !x.IsInternalPlayer() && x.GenderID != genderToCheck)) { throw new InvalidResultsEngineOperationException($"All players should be [{genderToCheck}]"); } } }
protected void SetVoidGameValues(TData gameData, GameResult gameResult, MatchFormatXGameVariation matchConfiguration) { gameData.GameStatusID = GameStatuses.Void; gameData.HomeWalkover = false; gameData.AwayWalkover = false; gameData.HomeHandicap = gameResult.HomeHandicap; gameData.AwayHandicap = gameResult.AwayHandicap; gameData.HomeScore = gameResult.HomeScore; gameData.AwayScore = gameResult.AwayScore; gameData.GameVariation = matchConfiguration.GameVariation; gameData.GameCalculationEngineID = matchConfiguration.GameCalculationEngineID; }
protected void SetCommonGameValues(TData gameData, GameResult gameResult, MatchFormatXGameVariation matchConfiguration) { gameData.GameStatusID = GameStatuses.Standard; gameData.HomeWalkover = WalkoverHelper.MapHomeWalkoverValue(gameResult.Walkover); gameData.AwayWalkover = WalkoverHelper.MapAwayWalkoverValue(gameResult.Walkover); gameData.HomeHandicap = gameResult.HomeHandicap; gameData.AwayHandicap = gameResult.AwayHandicap; gameData.HomeScore = gameResult.HomeScore; gameData.AwayScore = gameResult.AwayScore; gameData.GameVariation = matchConfiguration.GameVariation; gameData.GameCalculationEngineID = matchConfiguration.GameCalculationEngineID; }
public IGameService Create(MatchFormatXGameVariation matchConfiguration) { switch (matchConfiguration.GameVariation.GameFormatID) { case GameFormats.Singles: return(this._serviceProvider.GetService <IGameService <SinglesGame> >()); case GameFormats.Doubles: return(this._serviceProvider.GetService <IGameService <DoublesGame> >()); case GameFormats.Threesomes: return(this._serviceProvider.GetService <IGameService <ThreesomesGame> >()); case GameFormats.Fours: return(this._serviceProvider.GetService <IGameService <FoursomesGame> >()); default: throw new ArgumentOutOfRangeException(); } }