Exemple #1
0
        public DomainResult ProgressMatch(PlayerProgression playerProgression)
        {
            if (!_isStarted)
            {
                return(DomainResult.Error(new MatchDidNotStartYet()));
            }
            if (_isFinished)
            {
                return(DomainResult.Error(new MatchAllreadyFinished()));
            }

            var playerIsNotInHomeOrGuestTeam =
                !HomeTeamPlayers.Contains(playerProgression.PlayerId) &&
                !GuestTeamPlayers.Contains(playerProgression.PlayerId);

            if (playerIsNotInHomeOrGuestTeam)
            {
                return(DomainResult.Error(new PlayerWasNotPartOfTheTeamWhenStartingTheMatch(playerProgression.PlayerId)));
            }

            var playerProgressions = PlayerProgressions.Append(playerProgression);
            var gameResult         = CreateGameResult(playerProgressions);

            var matchResultUploaded = new MatchProgressed(MatchId, playerProgression, gameResult);

            return(DomainResult.Ok(matchResultUploaded));
        }
Exemple #2
0
 private int CountTouchDownsHome(IEnumerable <PlayerProgression> trainerResults)
 {
     return(trainerResults.Count(playerProgression => HomeTeamPlayers.Contains(playerProgression.PlayerId) &&
                                 playerProgression.ProgressionEvent == ProgressionEvent.PlayerMadeTouchdown));
 }