Esempio n. 1
0
 private void Apply(GameStartedGameEvent @event)
 {
     Status = GameStatus.Playing;
     CurrentUserId = @event.UserId;
     _deck.Shuffle(@event.Seed);
     var hands = _deck.DrawHands(_users.Count);
     for (var i = 0; i < hands.Count; i++)
     {
         var hand = hands[i];
         var user = _users[i];
         _hands.Add(user, hand.ToList());
     }
 }
Esempio n. 2
0
        public Game Start(int seed)
        {
            if (Status != GameStatus.Waiting)
            {
                throw new InvalidOperationException("Game is not waiting for players.");
            }

            if (!IsFull())
            {
                throw new InvalidOperationException("Game is not full.");
            }

            var firstUser = _users.Last();
            var e = new GameStartedGameEvent(Guid.NewGuid(), Id, firstUser, Version + 1, seed);
            RaiseEvent(e);
            return this;
        }