Esempio n. 1
0
        public void TestShuffle()
        {
            var shuffler      = new CardsShuffler();
            var shuffledCards = shuffler.Shuffle();

            Assert.AreEqual <int>(4, shuffledCards.Count);
            foreach (var playerCards in shuffledCards)
            {
                Assert.AreEqual <int>(13, playerCards.Count);
            }
        }
Esempio n. 2
0
        private Card[] GetShuffledCards()
        {
            if (_baseCards == null)
            {
                _baseCards = new Card[52];

                for (int i = 0; i < 13; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        _baseCards[i * 4 + j] = new Card((CardColor)j, (CardType)i);
                    }
                }
            }

            Card[] myCards = new Card[52];
            Array.Copy(_baseCards, myCards, 52);

            CardsShuffler.ShuffleCards(myCards, _random);

            return(myCards);
        }
Esempio n. 3
0
        private void SetupGame()
        {
            _cardsPlayers.Clear();
            _bidPlayerTeam = null;
            _round = null;
            _biddingPlayerIndex = 0;
            _isDouble = false;
            _players.ForEach(p => p.Score = 0);
            var playerIndex = 0;
            var cardsShuffler = new CardsShuffler();
            var deck = cardsShuffler.GetShuffledDeck();

            for (var i = 0; i < deck.Count; i++)
            {
                if (i != 0 && i % 13 == 0)
                    playerIndex++;
                _cardsPlayers.Add(deck[i], _players[playerIndex]);
            }

            _eventHandlerList[GameSetupCompletedConstant].SafelyInvoke(this,
                                                                       new GameSetupCompletedEventArgs { CardsPlayers = _cardsPlayers });
            _eventHandlerList[BiddingStartedConstant].SafelyInvoke(this,
                                                                   new BidEventArgs { NextCaller = _players[_biddingPlayerIndex] });
        }