Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
 public void Handle(MatchProgressed domainEvent)
 {
     GameResult         = domainEvent.GameResult;
     PlayerProgressions = PlayerProgressions.Append(domainEvent.PlayerProgression);
 }
Ejemplo n.º 3
0
 public void Apply(MatchProgressed domainEvent)
 {
     PlayerProgressions = PlayerProgressions.Append(domainEvent.PlayerProgression);
 }