Ejemplo n.º 1
0
        public void CanPickUpCards()
        {
            var sut  = new Player("Anders", true);
            var deck = StackOfCards.CreateFullDeckOfCards();

            Assert.IsNull(sut.OpenCards[0]);            // First open slot of four is not occupied.
            sut.PickUpCard(deck.DrawCard());            // Player picks up one card.
            Assert.IsNotNull(sut.OpenCards[0]);         // First open slot of four is now occupied.
            Assert.IsTrue(sut.Hand.Cards.Count == 0);   // Closed stack of cards on hand should be the same
                                                        // until all open slots are taken.

            Assert.IsNull(sut.OpenCards[1]);
            sut.PickUpCard(deck.DrawCard());
            Assert.IsNotNull(sut.OpenCards[1]);
            Assert.IsTrue(sut.Hand.Cards.Count == 0);

            Assert.IsNull(sut.OpenCards[2]);
            sut.PickUpCard(deck.DrawCard());
            Assert.IsNotNull(sut.OpenCards[2]);
            Assert.IsTrue(sut.Hand.Cards.Count == 0);

            Assert.IsNull(sut.OpenCards[3]);
            sut.PickUpCard(deck.DrawCard());
            Assert.IsNotNull(sut.OpenCards[3]);
            Assert.IsTrue(sut.Hand.Cards.Count == 0);

            sut.PickUpCard(deck.DrawCard());
            Assert.IsTrue(sut.Hand.Cards.Count == 1);   // All open slots taken. Card should go to closed stack.
        }
Ejemplo n.º 2
0
        public void CanCreateDeck()
        {
            var sut = StackOfCards.CreateFullDeckOfCards();

            Assert.IsNotNull(sut);
            Assert.AreEqual(sut.Cards.Count, 52);
        }
Ejemplo n.º 3
0
        public void CanShuffleDeck()
        {
            var sut = StackOfCards.CreateFullDeckOfCards();

            sut.Shuffle();

            Assert.AreEqual(sut.Cards.Count, 52);
        }
Ejemplo n.º 4
0
        private void Initialize()
        {
            Deck = StackOfCards.CreateFullDeckOfCards();
            Deck.Shuffle();

            LeftStack  = new OpenStackOfCards();
            RightStack = new OpenStackOfCards();

            PlayerOne = null;
            PlayerTwo = null;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Restarts the game with the same players
        /// </summary>
        public void RestartGame()
        {
            Deck = StackOfCards.CreateFullDeckOfCards();
            Deck.Shuffle();

            LeftStack  = new OpenStackOfCards();
            RightStack = new OpenStackOfCards();

            // todo: ugly
            var playerOneName = PlayerOne.NickName;
            var playerTwoName = PlayerTwo.NickName;

            PlayerOne = null;
            PlayerTwo = null;

            AddPlayer(playerOneName);
            AddPlayer(playerTwoName);
        }