Esempio n. 1
0
 private void Apply(UserJoinedGameEvent @event)
 {
     _users.Add(@event.UserId);
 }
Esempio n. 2
0
        public Game AddUser(Guid userId)
        {
            if (_users.Any(id => userId == id))
            {
                throw new InvalidOperationException("User is already in game.");
            }

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

            var userJoinedEvent = new UserJoinedGameEvent(Guid.NewGuid(), Id, userId, Version + 1);
            RaiseEvent(userJoinedEvent);
            return this;
        }