Пример #1
0
        public Player(IEndPlayerInfo userIdentity, int cheeseCount, NumberCollection numbers)
        {
            if (userIdentity == null)
            {
                throw new ArgumentNullException(nameof(userIdentity));
            }
            if (numbers == null)
            {
                throw new ArgumentNullException(nameof(numbers));
            }
            if (cheeseCount >= numbers.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(cheeseCount), "You can't have more cheese than there is in the game.");
            }
            if (cheeseCount <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(cheeseCount), "You need some cheese in the game to be a player.");
            }

            _userIdentity = userIdentity;
            Status        = PlayerStatus.Playing;

            _cheeseCount = cheeseCount;
            _draws.AddRange(from i in ThreadSafeRandom.Pick(cheeseCount, numbers.CountInUse)
                            select new Draw(i, numbers[i].Name));
        }
Пример #2
0
        public override async Task SpawnAsync(NewGameStarted newGameStarting)
        {
            await base.SpawnAsync(newGameStarting).ConfigureAwait(false);

            _gameNumbers = ThreadSafeRandom.Pick(AllNumbers.CountInUse, AllNumbers.CountInUse).ToList();
        }