Beispiel #1
0
        static void Main(string[] args)
        {
            Deck   deck   = new Deck();
            Table  table  = new Table();
            Player player = new Player();
            AI     ai     = new AI();

            Random random = new Random();


            string[] hiddenCards = new string[5];
            for (int i = 0; i <= 1; i++)
            {
                hiddenCards[0] += "+-----+  ";
                hiddenCards[1] += "|     |  ";
                hiddenCards[2] += "|     |  ";
                hiddenCards[3] += "|     |  ";
                hiddenCards[4] += "+-----+  ";
            }


            // GAME LOOP
            while (true)
            {
                deck.getNewCards();
                deck.shuffleDeck();

                ai.getCardFromDeck(deck.getRandomCard());
                ai.getCardFromDeck(deck.getRandomCard());

                player.getCardFromDeck(deck.getRandomCard());
                player.getCardFromDeck(deck.getRandomCard());

                printUI(table, player.returnCardsAsAscii(), hiddenCards);
                Console.ReadLine();
                Console.Clear();

                table.getCardFromDeck(deck.getRandomCard());
                table.getCardFromDeck(deck.getRandomCard());
                table.getCardFromDeck(deck.getRandomCard());
                printUI(table, player.returnCardsAsAscii(), hiddenCards);
                Console.ReadLine();
                Console.Clear();

                table.getCardFromDeck(deck.getRandomCard());
                printUI(table, player.returnCardsAsAscii(), hiddenCards);
                Console.ReadLine();
                Console.Clear();

                table.getCardFromDeck(deck.getRandomCard());
                printUI(table, player.returnCardsAsAscii(), hiddenCards);
                Console.ReadLine();
                Console.Clear();

                printUI(table, player.returnCardsAsAscii(), ai.returnCardsAsAscii());

                player.getEvaluator().addCardList(player.getCurrentCards());
                player.getEvaluator().addCardList(table.getCurrentCards());

                player.getStringEvaluator().addCardList(player.getCurrentCards());
                player.getStringEvaluator().addCardList(table.getCurrentCards());

                ai.getEvaluator().addCardList(ai.getCurrentCards());
                ai.getEvaluator().addCardList(table.getCurrentCards());

                ai.getStringEvaluator().addCardList(ai.getCurrentCards());
                ai.getStringEvaluator().addCardList(table.getCurrentCards());

                int score = compareHands(player.getEvaluator(), ai.getEvaluator());

                Console.WriteLine("Player has " + player.getStringEvaluator().returnResultAsString() + "\n" + player.getStringEvaluator().getHighCardAsString() + " high card.");
                Console.WriteLine();
                Console.WriteLine("AI has " + ai.getStringEvaluator().returnResultAsString() + "\n" + ai.getStringEvaluator().getHighCardAsString() + " high card.");

                Console.WriteLine();
                if (score == 1)
                {
                    Console.WriteLine("The Player has won.");
                }
                else if (score == 2)
                {
                    Console.WriteLine("The AI has won.");
                }
                else if (score == 3)
                {
                    Console.WriteLine("The Player splits the pot with the AI.");
                }
                Console.ReadLine();
                Console.Clear();

                table = new Table();
                ai.resetState();
                player.resetState();

                Console.Clear();
            }
        }