Exemple #1
0
        public void Start()
        {
            view.PrintWelcome();

            balance = view.ReadBalance();

            while (balance > 0)
            {
                dealer.dealtCards = new Card[5];

                betSize  = view.ReadBetSize(balance);
                balance -= betSize;

                view.PrintNewGame();

                dealer.ShuffleDeck();

                dealer.DealCards();

                view.DisplayCards(dealer.dealtCards);

                List <int> inputOfCardsIndexesToKeep = view.ReadIndexesToKeep();

                dealer.DiscardCards(inputOfCardsIndexesToKeep);

                view.DisplayCardsAfterChange(dealer.dealtCards);

                HandCombinations handCombination = handEvaluator.EvaluateHand(dealer.dealtCards);

                result   = betSize * (int)handCombination;
                balance += result;

                view.PrintGameResult(handCombination, balance, result);
            }
        }
Exemple #2
0
        public void PrintGameResult(HandCombinations handCombination, int balance, int result)
        {
            Console.WriteLine("\n" + handCombination + "\n");
            if (result == 0)
            {
                Console.WriteLine("You have lost, your balance now is: " + balance);
            }
            else
            {
                Console.WriteLine("You have won: " + result + ", your balance now is: " + balance);
            }

            if (balance == 0)
            {
                Console.WriteLine("\nYou lost all your balance\n");
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();

                return;
            }

            Console.WriteLine("\nPress any key to play again");
            Console.ReadKey();

            Console.Clear();
        }
        public HandCombinations EvaluateHand(Card[] cardsInput)
        {
            // Sorts cards in ascending order
            cards = cardsInput.OrderBy(i => i.Rank).ToArray();

            HandCombinations handCombination = CheckStraightAndFlushCombinations();

            if (handCombination == HandCombinations.AllOther)
            {
                handCombination = CheckPairsCombinations();
            }

            return(handCombination);
        }