static void Main(string[] args)
        {
            //Set Encoding to print Unicode Characters.
            Console.OutputEncoding = System.Text.Encoding.Unicode;
            // create a new deck and display
            Deck deck = new Deck();
            Console.WriteLine("New Deck:\n");
            Console.WriteLine(deck); // NEED CHECK TOSTring is made for DECK!

            // shuffle deck and display
            deck.Shuffle();
            Console.WriteLine("\n\nShuffeled Deck:\n");
            Console.WriteLine(deck);//MAKE SURE that when deck is printed it will print the current deck.

            // deal hands from testDeck and display
            deck = new Deck(TestDeck());
            Console.WriteLine("\n\nDealing hands of 5 cards from the test deck:\n");

            //This checks that current deck cards size is greater than or = to 5 so,
            // We must remove cards from LIST!! Collection!!!
            while (deck.Card.Count >= 5)
            {
                // Instance of Hand instantiated with 5 cards asked for.
                Hand hand = new Hand(deck.Deal(5));
                Console.WriteLine(hand);
            }

            Console.WriteLine();
        }
Пример #2
0
 public Turn(PlayerTurn pt, Vector2 loc)
     : base(loc)
 {
     turn = pt;
     hand = new Hand(pt);
     deck = new Deck(pt);
 }
Пример #3
0
        public void deal_gives_five_Cards_to_Hand()
        {
            var aHand = new Hand();
            var aDeck = new Deck();

            aDeck.Deal(aHand);

            Assert.AreEqual(aHand.GetLength(), 5);
        }
Пример #4
0
        public void Check_Hands_Are_Unique()
        {
            var deck = new Deck();
            var handOne = new Hand();
            var handTwo = new Hand();

            deck.Deal(handOne);
            deck.Deal(handTwo);

            Assert.That(!handOne.GetCards().SequenceEqual(handTwo.GetCards()));
        }
        private static Hand GetFullHouseWinner(Hand handOne, Hand handTwo)
        {
            var strongerRepeatingCards = new GroupsOfCardsOfSameValueTieBreaker(handOne, handTwo);

            var highestThreeOfAKindHand = strongerRepeatingCards.DetermineStrongestHand(3);

            if (highestThreeOfAKindHand != null)
                return highestThreeOfAKindHand;

            var highestPairHand = strongerRepeatingCards.DetermineStrongestHand(2);
            return highestPairHand;
        }
        private Hand FindBestTwoPair(Hand handOne, Hand handTwo)
        {
            var repeatingCardsComparer = new GroupsOfCardsOfSameValueTieBreaker(handOne, handTwo);
            var bestPairHand = repeatingCardsComparer.DetermineStrongestHand(2);

            if (bestPairHand != null)
            {
                return bestPairHand;
            }

            return repeatingCardsComparer.DetermineStrongestHand(1);
        }
Пример #7
0
 public static Hand FlushAceHighNineLow()
 {
     var hand = new Hand();
     hand.AddCards(new List<Card>
     {
         new Card(Value.Nine, Suit.Hearts),
         new Card(Value.Jack, Suit.Hearts),
         new Card(Value.Queen, Suit.Hearts),
         new Card(Value.King, Suit.Hearts),
         new Card(Value.Ace, Suit.Hearts)
     });
     return hand;
 }
Пример #8
0
 public static Hand FiveOfAKind()
 {
     var hand = new Hand();
     hand.AddCards(new List<Card>
     {
          new Card(Value.Seven, Suit.Clubs),
          new Card(Value.Seven, Suit.Hearts),
          new Card(Value.Seven, Suit.Diamonds),
          new Card(Value.Seven, Suit.Spades),
          new Card(Value.Seven, Suit.Diamonds),
     });
     return hand;
 }
Пример #9
0
 public static Hand AceHighStraightWithoutFlush()
 {
     var hand = new Hand();
     hand .AddCards(new List<Card>
     {
         new Card(Value.Ten, Suit.Hearts),
         new Card(Value.Jack,Suit.Hearts),
         new Card(Value.Queen, Suit.Hearts),
         new Card(Value.King, Suit.Hearts),
         new Card(Value.Ace, Suit.Clubs)
     });
     return hand;
 }
        private Hand FindBestHand(Hand handTwo, Hand handOne)
        {
            var repeatingCardsComparer = new GroupsOfCardsOfSameValueTieBreaker(handOne, handTwo);

            var bestThreeOfAKindHand = repeatingCardsComparer.DetermineStrongestHand(3) ;

            if (bestThreeOfAKindHand != null)
            {
                return bestThreeOfAKindHand;
            }
            var bestKickerHand = repeatingCardsComparer.DetermineStrongestHand(1);

            return bestKickerHand;
        }
Пример #11
0
        public void Deal(Hand handToDealTo)
        {
            if (Count() <= 0) return;

            for (var i = 0; i < 5; i++)
            {
                if (Count() - i < 0)
                {
                    break;
                }
                handToDealTo.TakeCards(Cards[0]);
                Cards.Remove(Cards[0]);

            }
        }
Пример #12
0
 public static Hand FivePairsLowFifthPair()
 {
     var hand = new Hand();
     hand.AddCards(new List<Card>
     {
         new Card(Value.King, Suit.Hearts),
         new Card(Value.King, Suit.Diamonds),
         new Card(Value.Queen, Suit.Spades),
         new Card(Value.Queen, Suit.Clubs),
         new Card(Value.Jack, Suit.Diamonds),
         new Card(Value.Jack, Suit.Hearts),
         new Card(Value.Ten, Suit.Diamonds),
         new Card(Value.Ten, Suit.Spades),
         new Card(Value.Two, Suit.Clubs),
         new Card(Value.Two, Suit.Diamonds)
     });
     return hand;
 }
Пример #13
0
        public Hand CheckHighest(Hand handOne, Hand handTwo)
        {
            var handSize = handOne.GetLength();
            Hand bestHand = null;
            for (int i = 0; i < handSize; i++)
            {
                if (handOne.GetCards()[i].GetCardValue() > handTwo.GetCards()[i].GetCardValue())
                {
                    bestHand = handOne;
                }
                if (handTwo.GetCards()[i].GetCardValue() > handOne.GetCards()[i].GetCardValue())
                {
                    bestHand = handTwo;
                }
                if (bestHand != null)
                    return bestHand;

            }

            return bestHand;
        }
Пример #14
0
 public bool IsHand(Hand twoPair)
 {
     return false;
 }
Пример #15
0
 public int CompareCards(Hand playerOneHand, Hand playerTwoHand)
 {
     return 0;
 }
Пример #16
0
        public static Hand PairJacksLowKickers()
        {
            var hand = new Hand();
            hand.AddCards(new List<Card>
            {

                new Card(Value.Jack, Suit.Clubs),
                new Card(Value.Three, Suit.Hearts),
                new Card(Value.Jack, Suit.Diamonds),
                new Card(Value.Four, Suit.Clubs),
                new Card(Value.Two, Suit.Diamonds),
            });
            return hand;
        }
Пример #17
0
        public void Run()
        {
            var aDeck = new Deck();
            var playerOne = new Hand();
            var playerTwo = new Hand();

            var poker = new GameRules();
            const int numberOfPlayers = 2;
            var gameWon = false;
            var pokerEvaluator = new Evaluator(PokerHandAnalysers.FiveCardPoker());
            aDeck.Shuffle();
            aDeck.Deal(playerOne);
            aDeck.Deal(playerTwo);

            while (!gameWon)
            {

                    for (int i = 0; i < numberOfPlayers; i++)
                    {

                        Console.WriteLine("Deck Cards:" + aDeck.Count());
                        Console.Write("Whose Turn: ");
                        if (i == 0)
                        {
                            Console.WriteLine("Player One");
                        }
                        else if (i == 1)
                        {
                            Console.WriteLine("Player Two");
                        }
                        Console.WriteLine("===Player One Hand===");

                        OutputCards(playerOne.GetCards());
                        Console.WriteLine("===Player Two Hand===");
                        OutputCards(playerTwo.GetCards());

                        var listOfHands = new List<Hand> { playerOne, playerTwo };
                        var result = pokerEvaluator.DetermineWinner(listOfHands);
                        if (result == playerOne)
                        {
                            Console.WriteLine("Player One Wins");
                        }else if (result == playerTwo)
                        {
                            Console.WriteLine("Player Two Wins");
                        }
                        else
                        {
                            Console.WriteLine("Draw");
                        }

                        Console.ReadKey();

                        //else if (//poker.CompareCards(player))

                        Console.WriteLine("D: Deal to Hand");
                        Console.WriteLine("S: Shuffle Deck");
                        Console.WriteLine("X: See Deck");
                        Console.WriteLine("R: Draw Cards");
                        Console.WriteLine("Escape: Quit");

                        var input = Console.ReadKey();

                        switch (input.Key)
                        {
                            case ConsoleKey.S:
                                aDeck.Shuffle();
                                break;
                            case ConsoleKey.D:
                                if (i == 0)
                                {

                                }
                                else if (i == 1)
                                {

                                }
                                break;
                            case ConsoleKey.R:
                                int cardsToReturn;

                                Console.WriteLine("How Many Cards?");
                                try
                                {
                                    cardsToReturn = int.Parse(Console.ReadLine());
                                }
                                finally
                                {

                                }
                                for (var j = 0; j < cardsToReturn; j++)
                                {
                                    Console.WriteLine(j);
                                }
                                Console.ReadKey();
                                if (i == 0)
                                {
                                    var cards = new List<int>();
                                    playerOne.ChangeCards(aDeck, cards);

                                }
                                else if (i == 1)
                                {
                                    var cards = new List<int>();
                                    playerTwo.ChangeCards(aDeck, cards);
                                }

                                break;

                            case ConsoleKey.Escape:
                                Environment.Exit(0);
                                break;
                            case ConsoleKey.X:

                                OutputCards(aDeck.GetCards());
                                Console.ReadKey();
                                break;
                        }
                        Console.Clear();
                    }

            }
        }
Пример #18
0
 public static Hand RoyalFlush()
 {
     var hand = new Hand();
     hand.AddCards(new List<Card>
     {
          new Card(Value.Ten, Suit.Clubs),
          new Card(Value.Jack, Suit.Clubs),
          new Card(Value.Queen, Suit.Clubs),
          new Card(Value.King, Suit.Clubs),
          new Card(Value.Ace, Suit.Clubs),
     });
     return hand;
 }
Пример #19
0
 public static Hand ThreeOfAKindThreesLowKickers()
 {
     var hand = new Hand();
     hand.AddCards(new List<Card>
     {
         new Card(Value.Three, Suit.Hearts),
         new Card(Value.Three, Suit.Spades),
         new Card(Value.Three, Suit.Diamonds),
         new Card(Value.Two, Suit.Clubs),
         new Card(Value.Four, Suit.Hearts)
     });
     return hand;
 }
Пример #20
0
        public static Hand StraightFlushWithAceLow()
        {
            var hand = new Hand();
            hand.AddCards(new List<Card>
            {
                new Card(Value.Two, Suit.Clubs),
                new Card(Value.Three, Suit.Clubs),
                new Card(Value.Four, Suit.Clubs),
                new Card(Value.Five, Suit.Clubs),
                new Card(Value.Ace, Suit.Clubs)
            });

            return hand;
        }
Пример #21
0
 public static Hand StraightJackHigh()
 {
     var hand = new Hand();
     hand.AddCards(new List<Card>
     {
        new Card(Value.Seven, Suit.Clubs),
        new Card(Value.Eight, Suit.Hearts),
        new Card(Value.Nine, Suit.Diamonds),
        new Card(Value.Ten, Suit.Clubs),
        new Card(Value.Jack, Suit.Diamonds),
     });
     return hand;
 }
Пример #22
0
        public static Hand TwoPairSevensOverTwosThreeKicker()
        {
            var hand = new Hand();
            hand.AddCards(new List<Card>
            {

                new Card(Value.Three, Suit.Clubs),
                new Card(Value.Seven, Suit.Hearts),
                new Card(Value.Seven, Suit.Diamonds),
                new Card(Value.Two, Suit.Clubs),
                new Card(Value.Two, Suit.Diamonds),
            });
            return hand;
        }
Пример #23
0
 public static Hand StraightSixHigh()
 {
     var hand = new Hand();
     hand.AddCards(new List<Card>
     {
        new Card(Value.Two, Suit.Hearts),
        new Card(Value.Three, Suit.Diamonds),
        new Card(Value.Four, Suit.Clubs),
        new Card(Value.Five, Suit.Diamonds),
        new Card(Value.Six, Suit.Clubs)
     });
     return hand;
 }
Пример #24
0
        public static Hand TwoPairKingsOverSixesSevenKicker()
        {
            var hand = new Hand();
            hand.AddCards(new List<Card>
            {

                new Card(Value.Seven, Suit.Clubs),
                new Card(Value.King, Suit.Hearts),
                new Card(Value.King, Suit.Diamonds),
                new Card(Value.Six, Suit.Clubs),
                new Card(Value.Six, Suit.Diamonds),
            });
            return hand;
        }
Пример #25
0
        public static Hand PairJacksHighKickers()
        {
            var hand = new Hand();
            hand.AddCards(new List<Card>
            {

                new Card(Value.Jack, Suit.Clubs),
                new Card(Value.King, Suit.Hearts),
                new Card(Value.Jack, Suit.Diamonds),
                new Card(Value.Queen, Suit.Clubs),
                new Card(Value.Ace, Suit.Diamonds),
            });
            return hand;
        }
Пример #26
0
 public void Write_Cards()
 {
     var aHand = new Hand();
     aHand.TakeCards(new Card(Value.Ace, Suit.Spades));
 }
Пример #27
0
 private static bool IsAceLowStraight(Hand hand)
 {
     return (hand.GetCards()[0].GetCardValue() == Value.Ace
           && hand.GetCards()[1].GetCardValue() == Value.Five
           && hand.GetCards()[2].GetCardValue() == Value.Four
           && hand.GetCards()[3].GetCardValue() == Value.Three
           && hand.GetCards()[4].GetCardValue() == Value.Two);
 }
Пример #28
0
        public static Hand StraightFlushHigh()
        {
            var hand = new Hand();
            hand.AddCards(new List<Card>
            {
                new Card(Value.Nine, Suit.Clubs),
                new Card(Value.Ten, Suit.Clubs),
                new Card(Value.Jack, Suit.Clubs),
                new Card(Value.Queen, Suit.Clubs),
                new Card(Value.King, Suit.Clubs)
            });

            return hand;
        }
Пример #29
0
        public static Hand TwoPairKingsOverThreesEightKicker()
        {
            var hand = new Hand();
            hand.AddCards(new List<Card>
            {

                new Card(Value.Eight, Suit.Clubs),
                new Card(Value.King, Suit.Hearts),
                new Card(Value.King, Suit.Diamonds),
                new Card(Value.Three, Suit.Clubs),
                new Card(Value.Three, Suit.Diamonds),
            });
            return hand;
        }
Пример #30
0
 public static Hand ThreeOfAKindKingsHighKickers()
 {
     var hand = new Hand();
     hand.AddCards(new List<Card>
     {
         new Card(Value.King, Suit.Hearts),
         new Card(Value.King, Suit.Spades),
         new Card(Value.King, Suit.Diamonds),
         new Card(Value.Ace, Suit.Clubs),
         new Card(Value.Queen, Suit.Hearts)
     });
     return hand;
 }