Esempio n. 1
0
        public void TestCardToHand()
        {
            System.Collections.Generic.List <Card> deck = new System.Collections.Generic.List <Card>();
            Card.Suits    suit = Card.Suits.Diamonds;
            Card.CardType typ  = Card.CardType.Five;
            Card          card = new Card(typ, suit);

            deck.Add(card);
            deck.Add(card);
            deck.Add(card);

            // Test the number of cards in the deck
            Assert.AreEqual(3, deck.Count);

            CardPlayer cardPlayer = new CardPlayer();

            //Test the number of cards on hand
            Assert.AreEqual(0, cardPlayer.HandValue);

            cardPlayer.addCardToHand();

            // Test the number of cards after play
            Assert.AreEqual(2, deck.Count);
            Assert.AreEqual(5, cardPlayer.HandValue);
        }
Esempio n. 2
0
 public Deck()
 {
     for (int i = 0; i < 52; i++)
     {
         Card.Suits suite = (Card.Suits)(i / 13);
         int        val   = i % 13 + 2;
         Cards.Add(new Card(val, suite));
     }
 }
Esempio n. 3
0
 public void CreateDeck()
 {
     for (int i = 0; i < 52; i++)
     {
         Card.Suits suit = (Card.Suits)(Math.Floor((decimal)i / 13));
         int        val  = i % 13 + 2;
         Cards.Add(new Card(val, suit));
     }
     //Creates the cards assinging them a value and a suit for all 52 cards
 }
Esempio n. 4
0
 public static void BUildSuite(Deck <Card> deck, Card.Suits suit)
 {
     deck.Add(new Card(suit, "Ace"));
     for (int i = 2; i <= 10; i++)
     {
         deck.Add(new Card(suit, i.ToString()));
     }
     deck.Add(new Card(suit, "Jack"));
     deck.Add(new Card(suit, "Queen"));
     deck.Add(new Card(suit, "King"));
 }
Esempio n. 5
0
        /// <summary>
        /// Finds the location of the first matching card in the deck.
        /// </summary>
        /// <param name="suit">Suit to match.</param>
        /// <param name="number">Value to match.</param>
        /// <returns></returns>
        public int Findcard(Card.Suits suit, Card.Numbers number)
        {
            int card = 0;

            for (int i = 0; i < _deck.Count; i++)
            {
                if (_deck[i].Suit == suit && _deck[i].Number == number)
                {
                    card = i;
                    break;
                }
            }
            return(card);
        }
        public static string GetSuit(Card.Suits suit)
        {
            switch (suit)
            {
            case Card.Suits.Clubs:
                return("<span style=\"color: black;\">&clubs;</span>");

            case Card.Suits.Diamonds:
                return("<span style=\"color: red;\">&diams;</span>");

            case Card.Suits.Hearts:
                return("<span style=\"color: red;\">&hearts;</span>");

            default:
                return("<span style=\"color: black;\">&spades;</span>");
            }
        }
Esempio n. 7
0
        public void TestHandValue()
        {
            CardPlayer cardPlayer = new CardPlayer();

            System.Collections.Generic.List <Card> cards = new System.Collections.Generic.List <Card>();
            Card.Suits    suit = Card.Suits.Diamonds;
            Card.CardType typ  = Card.CardType.Five;
            Card          card = new Card(typ, suit);

            cards.Add(card);
            cards.Add(card);
            cards.Add(card);



            cardPlayer.Hand = cards;

            cardPlayer.getHandValue();

            // Test correctness of card counting
            Assert.AreEqual(15, cardPlayer.HandValue);
        }
Esempio n. 8
0
 public Hand(PokerEvaluator.PokerHands presetHand, List <Card> cards, Card.Suits _suit, int highCardValue)
 {
     //Used for the flushes. Much easier passing the suit value then reworking it out again.
     HighCard     = highCardValue;
     HandType     = presetHand;
     CardRankings = new List <int>();
     cards.ForEach(a => {
         if (a.Suit == _suit)
         {
             CardRankings.Add(a.Order);
         }
     });
     if (CardRankings.Count < 5)
     {
         throw new Exception("Flush was passed to Hand constructor, but there were less than 5 valid cards for a flush");
     }
     CardRankings.Sort(new CardComparerDesc());
     if (presetHand <= PokerEvaluator.PokerHands.AHIGH)
     {
         highCardValue = (int)presetHand;
     }
     ConvertToReadable(cards);
 }
 //assigns the suits to cards
 public Foundation(Card.Suits suit)
 {
     Suit  = suit;
     Cards = new List <Card>();
 }
Esempio n. 10
0
 public Card(Card.Suits suit, Card.Values value)
 {
     this.suit  = suit;
     this.value = value;
 }
Esempio n. 11
0
 /// <summary>
 /// Removes the first matching card from the deck.
 /// </summary>
 /// <param name="suit">Suit to match.</param>
 /// <param name="number">Value to match.</param>
 /// <returns></returns>
 public Card Takecard(Card.Suits suit, Card.Numbers number)
 {
     return(Takecard(Findcard(suit, number)));
 }
 public void Set_card(Card.Ranks ran, Card.Suits sui, bool reveal)
 {
     card_in_component.Set_card(ran, sui, reveal);
     update_card_sprite();
 }
 public void set_suit(Card.Suits sui)
 {
     card_in_component.set_suit(sui);
     update_card_sprite();
 }
Esempio n. 14
0
 public void ShouldHaveBySuits(Card.Suits suit, int expectedCount) =>
 Deck.Count(card => card.Suit == suit).ShouldEqual(expectedCount);