Esempio n. 1
0
 public void ClearBeanFieldTest1()
 {
     var target = new BeanField();
     var expected = new List<Card>();
     var actual = target.ClearBeanField();
     Assert.AreEqual(actual.Count, expected.Count);
 }
Esempio n. 2
0
        /// <summary>
        ///  This will harvest a given field. Points are added to the player treasury.
        ///  Note that a beanField should be harvestable, which can be checked with method BeanFieldIsHarvestable().
        /// </summary>
        /// <param name="beanField"> BeanField which should be harvest. </param>
        /// <returns> The cards drawn from the given beanfield. So they can be returned to the discardPile eventually. </returns>
        internal List<Card> HarvestBeanField(BeanField beanField)
        {
            List<Card> cardsFromBeanField = beanField.ClearBeanField();

            if(cardsFromBeanField.Count > 0) //Prevents accessing non existing list element
            {
                //Get the number of coins earned
                int numberOfCoinsEarned = cardsFromBeanField[0].GetNumberOfCoinsforCards(cardsFromBeanField.Count);

                //Add the number of coins earned to the coinDeck.
                CoinDeck.PutCards(cardsFromBeanField.GetRange(0, numberOfCoinsEarned));

                //In the game, all points gained from harvesting are collected by turning this number of cards to the "coin-side" of the card, meaning that those cards will not be returned to the discardPile!
                //Therfore, remove the cards from cardsFromBeanField which have been added the coindeck.
                cardsFromBeanField.RemoveRange(0, numberOfCoinsEarned);
            }

            return cardsFromBeanField;
        }
 public void HarvestBeanFieldTest()
 {
     var target = _player;
     var beanField = new BeanField();
     beanField.PutCard(new BohnanzaCard(BohnanzaCard.CardEnum.CocoaBeans));
     beanField.PutCard(new BohnanzaCard(BohnanzaCard.CardEnum.CocoaBeans));
     var actual = target.HarvestBeanField(beanField);
     Assert.AreEqual(beanField.ClearBeanField(), actual);
 }