Exemplo n.º 1
0
        internal static void Main()
        {
            ICard card = new Card(CardFace.Ace, CardSuit.Clubs);
            Console.WriteLine(card);

            IHand hand = new Hand(new List<ICard>()
            {
                new Card(CardFace.Five, CardSuit.Diamonds),
                new Card(CardFace.Five, CardSuit.Spades),
                new Card(CardFace.Nine, CardSuit.Clubs),
                new Card(CardFace.Nine, CardSuit.Diamonds),
                new Card(CardFace.King, CardSuit.Hearts),
            });
            Console.WriteLine(hand);

            IHand otherHand = new Hand(new List<ICard>()
            {
                new Card(CardFace.Six, CardSuit.Hearts),
                new Card(CardFace.Six, CardSuit.Spades),
                new Card(CardFace.Three, CardSuit.Hearts),
                new Card(CardFace.Three, CardSuit.Diamonds),
                new Card(CardFace.King, CardSuit.Clubs),
            });
            Console.WriteLine(otherHand);

            IPokerHandsChecker checker = new PokerHandsChecker();
            Console.WriteLine(checker.IsStraightFlush(hand));
            Console.WriteLine(checker.IsStraight(hand));
            Console.WriteLine(checker.IsThreeOfAKind(hand));
            Console.WriteLine(checker.IsFlush(hand));
            Console.WriteLine(checker.IsOnePair(hand));
            Console.WriteLine(checker.IsTwoPair(hand));

            Console.WriteLine(checker.CompareHands(hand, otherHand));
        }
Exemplo n.º 2
0
        private IEnumerable<PictureBox> InitializeDeck()
        {
            int number = 0;
            foreach (Rank rank in Enum.GetValues(typeof(Rank)))
            {
                foreach (Suit suit in Enum.GetValues(typeof(Suit)))
                {
                    var cardName = rank + "_of_" + suit;
                    var image = Image.FromFile(CardsPath + "\\" + cardName + ".png");
                    ICard card = new Card(rank, suit, image);
                    this.deck.Add(number + 1, card);
                    this.holder[number] = new PictureBox();
                    this.holder[number].Image = image;

                    holder[number].SizeMode = PictureBoxSizeMode.StretchImage;
                    holder[number].Height = 130;
                    holder[number].Width = 80;
                    // Add this in table
                    // this.table.Controls.Add(holder[number]);
                    holder[number].Name = "pb" + number;
                    number++;
                }
            }

            return this.holder;
        }
Exemplo n.º 3
0
        public void ToStringOfTwoOfSpades()
        {
            var twoSpades = new Card(CardFace.Two, CardSuit.Spades);
            var expected = "2♠";
            var actual = twoSpades.ToString();

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 4
0
        public void ToStringOfAceOfHearts()
        {
            var aceHearts = new Card(CardFace.Ace, CardSuit.Hearts);
            var expected = "A♥";
            var actual = aceHearts.ToString();

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 5
0
        public void ToStringOfSevenOfDiamonds()
        {
            var sevenDiamonds = new Card(CardFace.Seven, CardSuit.Diamonds);
            var expected = "7♦";
            var actual = sevenDiamonds.ToString();

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 6
0
        public void ToStringOfTenOfClubs()
        {
            var tenClubes = new Card(CardFace.Ten, CardSuit.Clubs);
            var expected = "10♣";
            var actual = tenClubes.ToString();

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 7
0
        private Deck()
        {
            this.Cards = new List<ICard>();
            string[] imagesLocations = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly);
            for (int i = 0; i < imagesLocations.Length; i++)
            {
                var charsToRemove = new string[] { "Assets\\Cards\\", ".png" };
                Image cardImage = Image.FromFile(imagesLocations[i]);
                foreach (var c in charsToRemove)
                {
                    imagesLocations[i] = imagesLocations[i].Replace(c, string.Empty);
                }

                int cardNumber = int.Parse(imagesLocations[i]) - 1;
                Card currentCard = new Card(cardNumber, cardImage);
                this.Cards.Add(currentCard);
            }
        }
        public ICard CreateCard(decimal cardPower, CardType cardType)
        {
            var card = new Card(cardPower, cardType);

            return card;
        }