Example #1
0
        public void FaceCardQueenCanBeCreated()
        {
            //Act
            int            value        = 10;
            ECardSuitTypes cardSuitType = ECardSuitTypes.Clubs;
            ECardType      cardType     = ECardType.Queen;
            Card           testCard;

            //Arrange
            testCard = new FaceCard(cardSuitType, cardType);

            //Assert
            if (testCard.Value != value)
            {
                string errorMessage = $"Card is created with the wrong value. Expected card value is {value}. Actual card value is {testCard.Value}";
                Assert.Fail(errorMessage);
            }

            if (testCard.CardSuit != cardSuitType)
            {
                string errorMessage = $"Card is created with the wrong card suit type. Expected card suit type is {cardSuitType}. Actual card suit type is {testCard.CardSuit}";
                Assert.Fail(errorMessage);
            }

            if (testCard.CardType != cardType)
            {
                string errorMessage = $"Card is created with the wrong card type. Expected card type is {cardType}. Actual card suit type is {testCard.CardType}";
                Assert.Fail(errorMessage);
            }
        }
        public void WhoWonFaceCards(Face card1Face, Face card2Num, Winner winner)
        {
            ICard card1 = new FaceCard(card1Face, Suit.Heart);
            ICard card2 = new FaceCard(card2Num, Suit.Heart);

            Assert.Equal(winner, CardValueCalculator.WhoWon(card1, card2));
        }
Example #3
0
        public void ValidFace()
        {
            var face = Face.King;

            sut = new FaceCard(face, Suit.Heart);

            Assert.Equal(face, sut.Face());
        }
Example #4
0
        public void ValidCardValue()
        {
            var face = Face.Jack;

            sut = new FaceCard(face, Suit.Heart);
            var expected = CardValueCalculator.GetFor(face); //probably should mock

            Assert.Equal(expected, sut.Value());
        }
Example #5
0
 public void CardRev(FaceCard card)
 {
     if (m_first == null)
     {
         m_first = card;
     }
     else
     {
         m_second = card;
         StartCoroutine(CheckMatch());
     }
 }
Example #6
0
        private string GenerateCardValue()
        {
            int num = random.Next(2, 14);

            if (num > 10)
            {
                Array values = Enum.GetValues(typeof(FaceCard));
                FaceCard card = (FaceCard) values.GetValue(random.Next(values.Length));
                return card.ToString();
            }

            return num.ToString();
        }
Example #7
0
    private IEnumerator CheckMatch()
    {
        if (m_first.GetId() == m_second.GetId())
        {
            //Call Score

            addToScore.AddToScore();
        }
        else
        {
            yield return(new WaitForSeconds(0.5f));

            m_first.Reveal(); m_second.Reveal();
        }
        // Back to null
        //Debug.Log(m_first.GetId());
        m_first = null; m_second = null;
    }
Example #8
0
File: Game.cs Project: djericj/Uno
        private Card MatchOnNumber(Player player)
        {
            var numberCard = player.Hand.Where(x => !x.IsSpecialCard && x.Number == FaceCard.Number).FirstOrDefault();

            if (numberCard != null)
            {
                Log("TURN", $"Player {player.Number} matched NUMBER {numberCard.DisplayCard()} with FaceCard {FaceCard.DisplayCard()} ");
                return(numberCard);
            }
            return(numberCard);
        }
Example #9
0
File: Game.cs Project: djericj/Uno
        private Card MatchOnColor(Player player)
        {
            var colorCard = player.Hand.Where(x => x.Color == FaceCard.Color).FirstOrDefault();

            if (colorCard != null)
            {
                Log("TURN", $"Player {player.Number} matched COLOR {colorCard.DisplayCard()} with FaceCard {FaceCard.DisplayCard()}");
                return(colorCard);
            }
            else
            {
                return(null);
            }
        }