Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Game game = new Game();
            HandEvaluatorWrapper handEvaluator = new HandEvaluatorWrapper();
            Dealer dealer = new Dealer(game, new Deck());
            PokerPlayer rob = new PokerPlayer("RobA2345");
            PokerPlayer dave = new PokerPlayer("mintaspiss");

            dealer.ShuffleDeck();
            dealer.Deal(rob);
            dealer.Deal(dave);
            dealer.Deal(rob);
            dealer.Deal(dave);

            string robsHand = rob.ShowHand().Aggregate(string.Empty, (current, card) => current + " " + card.ToString("s"));
            string davesHand = dave.ShowHand().Aggregate(string.Empty, (current, card) => current + " " + card.ToString("s"));
            Console.WriteLine(string.Format("{0} holds {1}", rob, robsHand));
            Console.WriteLine(string.Format("{0} holds {1}", dave, davesHand));

            Console.WriteLine("Dealing Flop...");
            dealer.DealFlop(game);

            string boardCards = game.CommunityCards.Aggregate(
                string.Empty, (current, card) => current + " " + card.ToString("s"));

            Console.WriteLine(boardCards);

            Console.WriteLine("Dealing Turn...");
            dealer.DealTurn(game);

            boardCards = game.CommunityCards.Aggregate(
                string.Empty, (current, card) => current + " " + card.ToString("s"));

            Console.WriteLine(boardCards);

            Console.WriteLine("Dealing River...");
            dealer.DealRiver(game);

            boardCards = game.CommunityCards.Aggregate(
                string.Empty, (current, card) => current + " " + card.ToString("s"));

            Console.WriteLine(boardCards);

            string robsHandDescription = handEvaluator.GetHandDescription(rob.ShowHand(), game.CommunityCards);
            string davesHandDescription = handEvaluator.GetHandDescription(dave.ShowHand(), game.CommunityCards);
            uint robsHandValue = handEvaluator.EvaluateHandValue(rob.ShowHand(), game.CommunityCards);
            uint davesHandValue = handEvaluator.EvaluateHandValue(dave.ShowHand(), game.CommunityCards);

            Console.WriteLine(string.Format("{0} shows {1}", dave, davesHandDescription));
            Console.WriteLine(string.Format("{0} shows {1}", rob, robsHandDescription));

            string result;
            if (robsHandValue == davesHandValue)
                result = "Pot is split";
            else
            {
                result = robsHandValue > davesHandValue
                    ? string.Format("{0} wins with {1}", rob, robsHandDescription)
                    : string.Format("{0} wins wth {1}", dave, davesHandDescription);
            }

            Console.WriteLine(result);

            Console.Read();
        }