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)); }
private int CountTouchDownsHome(IEnumerable <PlayerProgression> trainerResults) { return(trainerResults.Count(playerProgression => HomeTeamPlayers.Contains(playerProgression.PlayerId) && playerProgression.ProgressionEvent == ProgressionEvent.PlayerMadeTouchdown)); }