예제 #1
0
    private void VerifyPlayers(MatchSerie4 matchSerie)
    {
        do
        {
            if (rosterPlayers !.Contains(matchSerie.Game1.Player) == false)
            {
                break;
            }

            if (rosterPlayers.Contains(matchSerie.Game2.Player) == false)
            {
                break;
            }

            if (rosterPlayers.Contains(matchSerie.Game3.Player) == false)
            {
                break;
            }

            if (rosterPlayers.Contains(matchSerie.Game4.Player) == false)
            {
                break;
            }

            return;
        }while (false);

        throw new MatchException("Can only register players from roster");
    }
예제 #2
0
    public void Handle(Serie4Registered e, string aggregateId)
    {
        string id = ResultSeries4ReadModel.IdFromBitsMatchId(e.BitsMatchId, e.RosterId);
        ResultSeries4ReadModel results = DocumentSession.Load <ResultSeries4ReadModel>(id);

        MatchSerie4 matchSerie = e.MatchSerie;

        string[] playerIds = new[]
        {
            matchSerie.Game1.Player,
            matchSerie.Game2.Player,
            matchSerie.Game3.Player,
            matchSerie.Game4.Player
        };

        Dictionary <string, Player> players = DocumentSession.Load <Player>(playerIds).ToDictionary(x => x.Id);

        ResultSeries4ReadModel.Game game1 = CreateGame(players, matchSerie.Game1);
        ResultSeries4ReadModel.Game game2 = CreateGame(players, matchSerie.Game2);
        ResultSeries4ReadModel.Game game3 = CreateGame(players, matchSerie.Game3);
        ResultSeries4ReadModel.Game game4 = CreateGame(players, matchSerie.Game4);

        results.Series.Add(new ResultSeries4ReadModel.Serie
        {
            Games = new List <ResultSeries4ReadModel.Game>
            {
                game1,
                game2,
                game3,
                game4
            }
        });
    }
예제 #3
0
 public Series4Scores(MatchSerie4 matchSerie)
 {
     PlayerResults = new[]
     {
         matchSerie.Game1,
         matchSerie.Game2,
         matchSerie.Game3,
         matchSerie.Game4
     }
     .Select(x => new PlayerResult(x.Player, x.Pins, x.Score))
     .ToArray();
 }
예제 #4
0
    public void RegisterSerie(MatchSerie4 matchSerie)
    {
        if (matchSerie == null)
        {
            throw new ArgumentNullException(nameof(matchSerie));
        }

        if (rosterPlayers !.Count is not 4 and not 5)
        {
            throw new MatchException("Roster must have 4 or 5 players when registering results");
        }

        VerifyPlayers(matchSerie);

        ApplyChange(new Serie4Registered(matchSerie, BitsMatchId, RosterId !));
        DoAwardMedals(registeredSeries);
    }
예제 #5
0
 public void Add(int bitsMatchId, string rosterId, DateTime date, int turn, MatchSerie4 matchSerie)
 {
     (int tableNumber, MatchGame4 game)[] games = new[]
예제 #6
0
 public Serie4Registered(MatchSerie4 matchSerie, int bitsMatchId, string rosterId)
 {
     MatchSerie  = matchSerie ?? throw new ArgumentNullException(nameof(matchSerie));
     BitsMatchId = bitsMatchId;
     RosterId    = rosterId;
 }
예제 #7
0
 public Serie4Registered(MatchSerie4 matchSerie, int bitsMatchId)
 {
     if (matchSerie == null) throw new ArgumentNullException("matchSerie");
     MatchSerie = matchSerie;
     BitsMatchId = bitsMatchId;
 }