public void PutCardToBeanFieldTest() { var target = new BeanField(); Card card = new BohnanzaCard(BohnanzaCard.CardEnum.CocoaBeans); target.PutCardToBeanField(card); Assert.IsTrue(target.NumberOfCards == 1); }
public void ClearBeanFieldTest1() { var target = new BeanField(); var expected = new List<Card>(); var actual = target.ClearBeanField(); Assert.AreEqual(actual.Count, expected.Count); }
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); }
public void BeanFieldIsHarvestableTest() { var target = _player; var beanField = new BeanField(); beanField.PutCard(new BohnanzaCard(BohnanzaCard.CardEnum.CocoaBeans)); beanField.PutCard(new BohnanzaCard(BohnanzaCard.CardEnum.GreenBeans)); const bool expected = true; bool actual = target.BeanFieldIsHarvestable(beanField); Assert.AreEqual(expected, actual); }
/// <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); }
public void PutCardToBeanFieldTest() { var target = _player; Card card = new BohnanzaCard(BohnanzaCard.CardEnum.CoffeeBeans); var beanField = new BeanField(); var actual = target.PutCardToBeanField(card, beanField); Assert.AreEqual(null, actual); }
/// <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; }
/// <summary> /// This method checks whether it is allowed to harvest a beanField. /// See page 7, "Harvesting and selling beans", game manual. /// </summary> /// <param name="beanField"> Some beanField. </param> /// <returns> True if harvestable, false otherwise. </returns> internal bool BeanFieldIsHarvestable(BeanField beanField) { return beanField.NumberOfCards != 1 || BeanFields.All(someBeanField => someBeanField.NumberOfCards <= 1); }
public void BeanFieldConstructorTest() { BeanField target = new BeanField(); Assert.IsInstanceOfType(target, typeof (BeanField)); }