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