예제 #1
0
 public void PutCardToBeanFieldTest()
 {
     var target = new BeanField();
     Card card = new BohnanzaCard(BohnanzaCard.CardEnum.CocoaBeans);
     target.PutCardToBeanField(card);
     Assert.IsTrue(target.NumberOfCards == 1);
 }
예제 #2
0
 public void FirstCardOnBeanFieldTest()
 {
     var target = new BeanField();
     Card card = new BohnanzaCard(BohnanzaCard.CardEnum.CocoaBeans);
     target.PutCardToBeanField(card);
     var actual = target.FirstCardOnBeanField;
     Assert.AreEqual(card,actual);
 }
예제 #3
0
        /// <summary>
        /// Adds a card to the given beanfield.
        /// </summary>
        /// <param name="card"> Some card. </param>
        /// <param name="beanField"> Some beanField. </param>
        /// <returns> List of cards that is possible harvested when the card you wanted to place did not match the type of the beanField. </returns>
        internal List<Card> PutCardToBeanField(Card card, BeanField beanField)
        {
            List<Card> result = null;

            //If the cards on the beanField do not match the card-type you want to place, then harvest first.
            if(beanField.FirstCardOnBeanField != null)
            {
                if ( ((BohnanzaCard)card).TypeOfCard != ((BohnanzaCard)beanField.FirstCardOnBeanField).TypeOfCard)
                {
                    result = HarvestBeanField(beanField); //Cards returned from the harvest need to be returned.
                }
            }

            //The card needs to be placed on the chosen beanField.
            beanField.PutCardToBeanField(card);

            //Return cards that need to be put back on the discardPile (if any)
            return result;
        }