示例#1
0
        private async Task <CareerPlayerTeamStatistic> Load(TeamMatch teamMatch, GameXPlayer playerGame)
        {
            var teamID    = this.DetermineOposingTeamID(teamMatch, playerGame);
            var statistic = await this._careerPlayerTeamStatisticRepository.Get(playerGame.Game.AssociationID, playerGame.Player.ID, playerGame.Game.SeasonID, teamID);

            if (statistic == null)
            {
                statistic = new CareerPlayerTeamStatistic
                {
                    Association = new Association
                    {
                        ID = playerGame.Game.AssociationID
                    },
                    Party = new Common.Domain.Entities.Player
                    {
                        ID = playerGame.Player.ID
                    },
                    Season = new Season
                    {
                        ID = playerGame.Game.SeasonID
                    },
                    Team = new Common.Domain.Entities.Team
                    {
                        ID = teamID
                    }
                };
            }

            return(statistic);
        }
示例#2
0
        public static void RemoveResultFromLists(GameXPlayer playerGame, List <int> opponentScoresInWonGames, List <int> playerScoresInLostGames)
        {
            if (playerGame.ResultTypeID == ResultType.Win)
            {
                switch (playerGame.SideID)
                {
                case Sides.Home:
                    opponentScoresInWonGames.Remove(playerGame.Game.AwayScore);
                    break;

                case Sides.Away:
                    opponentScoresInWonGames.Remove(playerGame.Game.HomeScore);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else if (playerGame.ResultTypeID == ResultType.Lose)
            {
                switch (playerGame.SideID)
                {
                case Sides.Home:
                    playerScoresInLostGames.Remove(playerGame.Game.HomeScore);
                    break;

                case Sides.Away:
                    playerScoresInLostGames.Remove(playerGame.Game.AwayScore);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
示例#3
0
        public async Task Remove(TeamMatch teamMatch, GameXPlayer playerGame)
        {
            var data = await this.Load(teamMatch, playerGame);

            data.Remove(playerGame);

            await this._careerPlayerTeamStatisticRepository.Save(data);
        }
        public async Task Remove(GameXPlayer playerGame)
        {
            var data = await this.Load(playerGame);

            data.Remove(playerGame);

            await this._careerPlayerPitchStatisticRepository.Save(data);
        }
示例#5
0
        public async Task Remove(GameXPlayer playerGame, int competitionID, int competitionStageID)
        {
            var lookupKey = this.GetLookupKey(playerGame, competitionID, competitionStageID);
            var data      = await this.Load(lookupKey);

            data.Remove(playerGame);

            await this._sessionProvider.Session.SaveAsync(data);
        }
        private async Task <CareerPlayerPitchStatistic> Load(GameXPlayer playerGame)
        {
            CareerPlayerPitchStatistic statistic = null;

            var key = new CareerPlayerPitchStatistic
            {
                Association = new Association()
                {
                    ID = playerGame.Game.AssociationID
                },
                Party = new Common.Domain.Entities.Player()
                {
                    ID = playerGame.Player.ID
                },
                Season = new Season()
                {
                    ID = playerGame.Game.SeasonID
                },
                Pitch = new Pitch()
                {
                    ID = playerGame.Game.Pitch.ID
                }
            };

            statistic = await this._careerPlayerPitchStatisticRepository.Get(key);

            if (statistic == null)
            {
                statistic = new CareerPlayerPitchStatistic
                {
                    Association = new Association
                    {
                        ID = playerGame.Game.AssociationID
                    },
                    Party = new Common.Domain.Entities.Player
                    {
                        ID = playerGame.Player.ID
                    },
                    Season = new Season
                    {
                        ID = playerGame.Game.SeasonID
                    },
                    Pitch = new Pitch
                    {
                        ID = playerGame.Game.Pitch.ID
                    }
                };
            }

            return(statistic);
        }
示例#7
0
        private int DetermineOposingTeamID(TeamMatch teamMatch, GameXPlayer playerGame)
        {
            switch (playerGame.SideID)
            {
            case Sides.Home:
                return(teamMatch.GetTeamBySide(Sides.Away).ID);

            case Sides.Away:
                return(teamMatch.GetTeamBySide(Sides.Home).ID);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public virtual void Add(GameXPlayer gamePlayer)
        {
            if (!gamePlayer.Game.Completed)
            {
                throw new NotImplementedException("Game must be marked as Complete");
            }

            if (gamePlayer.Player.ID != this.Party.ID)
            {
                throw new ArgumentOutOfRangeException("Game supplied is not for Player [" + this.Party.ID + "]");
            }

            switch (gamePlayer.Game.VenueTypeID)
            {
            case VenueTypes.HomeAway:
                switch (gamePlayer.SideID)
                {
                case Sides.Home:
                    this.AddHomeResult(gamePlayer.ResultTypeID.Value, gamePlayer.Game.HomeWalkover, gamePlayer.Game.HomeScore, gamePlayer.Game.AwayScore);
                    break;

                case Sides.Away:
                    this.AddAwayResult(gamePlayer.ResultTypeID.Value, gamePlayer.Game.AwayWalkover, gamePlayer.Game.AwayScore, gamePlayer.Game.HomeScore);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;

            case VenueTypes.Neutral:
                switch (gamePlayer.SideID)
                {
                case Sides.Home:
                    this.AddNeutralResult(gamePlayer.ResultTypeID.Value, gamePlayer.Game.HomeWalkover, gamePlayer.Game.HomeScore, gamePlayer.Game.AwayScore);
                    break;

                case Sides.Away:
                    this.AddNeutralResult(gamePlayer.ResultTypeID.Value, gamePlayer.Game.AwayWalkover, gamePlayer.Game.AwayScore, gamePlayer.Game.HomeScore);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public short CalculateDroppedChalks(GameXPlayer gamePlayer)
        {
            switch (gamePlayer.SideID)
            {
            case Sides.Home:
                return((byte)(this.GameScoreTarget - gamePlayer.Game.HomeScore));

            case Sides.Away:
                return((byte)(this.GameScoreTarget - gamePlayer.Game.AwayScore));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private void CalculateAdditionalData(PlayerMeritTableLine line, GameXPlayer playerGame, CompetitionEvent competitionEvent, MeritCalculationEngine config, IGameCalculationEngine engine, List <int> opponentScoresInWonGames,
                                             List <int> playerScoresInLostGames)
        {
            line.DataDecimal1 = CalculationHelper.CalculateAvLost(line, engine);
            line.DataDecimal2 = CalculationHelper.CalculateAvAll(line);

            if (config.EnableDropWorseResults)
            {
                this.SnapshotTotals(line);
                this.CalculateForDroppedGames(line, opponentScoresInWonGames, playerScoresInLostGames, competitionEvent.DataInt1.Value, competitionEvent.DataInt2.Value, engine);
            }

            line.DataString1 = ListHelper.ListToCsv(opponentScoresInWonGames);
            line.DataString2 = ListHelper.ListToCsv(playerScoresInLostGames);
        }
        public Task Remove(PlayerMeritTable playerMeritTable, GameXPlayer playerGame, Team team, CompetitionEvent competitionEvent, MeritCalculationEngine config)
        {
            var line = playerMeritTable.GetOrCreateLine(team, playerGame.Player);
            var gameCalculationEngine = this._gameCalculationEngineFactory.Create(playerGame.Game.GameCalculationEngineID);

            line.Remove(playerGame);
            var droppedChalks = gameCalculationEngine.CalculateDroppedChalks(playerGame);

            line.RemoveDroppedChalks(playerGame, droppedChalks);

            var opponentScoresInWonGames = ListHelper.ConvertToList(line.DataString1);
            var playerScoresInLostGames  = ListHelper.ConvertToList(line.DataString2);

            ListHelper.RemoveResultFromLists(playerGame, opponentScoresInWonGames, playerScoresInLostGames);

            this.CalculateAdditionalData(line, playerGame, competitionEvent, config, gameCalculationEngine, opponentScoresInWonGames, playerScoresInLostGames);

            return(Task.CompletedTask);
        }
        public virtual void RemoveDroppedChalks(GameXPlayer gamePlayer, short droppedChalks)
        {
            if (!gamePlayer.Game.Completed)
            {
                throw new NotImplementedException("Game must be marked as Complete");
            }

            if (gamePlayer.Player.ID != this.Party.ID)
            {
                throw new ArgumentOutOfRangeException("Game supplied is not for Player [" + this.Party.ID + "]");
            }

            switch (gamePlayer.Game.VenueTypeID)
            {
            case VenueTypes.HomeAway:
                switch (gamePlayer.SideID)
                {
                case Sides.Home:
                    this.HomeChalksDropped -= droppedChalks;
                    break;

                case Sides.Away:
                    this.AwayChalksDropped -= droppedChalks;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;

            case VenueTypes.Neutral:
                this.NeutralChalksDropped -= droppedChalks;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private static CompetitionPlayerGameStatistic CreateDataObject(int competitionHeaderID, int seasonID, int competitionID, int competitionStageID, int competitionEventID, TeamMatch match, TeamMatchXGame teamMatchGame, GameXPlayer playerGame)
        {
            var data = new CompetitionPlayerGameStatistic();

            data.CompetitionHeaderID         = competitionHeaderID;
            data.SeasonID                    = seasonID;
            data.CompetitionID               = competitionID;
            data.CompetitionStageID          = competitionStageID;
            data.CompetitionEventID          = competitionEventID;
            data.MatchID                     = match.ID;
            data.MatchFormatXGameVariationID = teamMatchGame.MatchFormatXGameVariation.ID;
            data.GameNumber                  = match.TeamFixture.CompetitionRound.GameNumber;
            data.Date         = playerGame.Game.Date;
            data.PlayerID     = playerGame.Player.ID;
            data.Team         = match.GetTeamBySide(playerGame.SideID);
            data.GameFormatID = playerGame.Game.GameFormatID;
            return(data);
        }
        public void Remove(int competitionHeaderID, int seasonID, int competitionID, int competitionStageID, int competitionEventID, TeamMatch match, TeamMatchXGame teamMatchGame, GameXPlayer playerGame)
        {
            var data = CreateDataObject(competitionHeaderID, seasonID, competitionID, competitionStageID, competitionEventID, match, teamMatchGame, playerGame);

            this._competitionPlayerGameStatisticRepository.Delete(data);
        }
 public bool IsSatisfied(GameXPlayer playerGame)
 {
     return(!playerGame.Player.IsInternalPlayer());
 }
示例#16
0
 private Tuple <int, int, short, int, int, GameCalculationEngines> GetLookupKey(GameXPlayer playerGame, int competitionID, int competitionStageID)
 {
     return(new Tuple <int, int, short, int, int, GameCalculationEngines>(playerGame.Game.AssociationID, playerGame.Player.ID, playerGame.Game.SeasonID, competitionID,
                                                                          competitionStageID, playerGame.Game.GameCalculationEngineID));
 }
 public Task <bool> IsSatisfied(GameXPlayer playerGame)
 {
     return(Task.FromResult(((!playerGame.Player.IsInternalPlayer()) && playerGame.Game.Pitch != null)));
 }
示例#18
0
 public Task <bool> IsSatisfied(TeamMatch teamMatch, GameXPlayer playerGame)
 {
     return(Task.FromResult(!playerGame.Player.IsInternalPlayer()));
 }