Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        /// <param name="gameSize">Size of the game.</param>
        /// <param name="smallBlind">The small blind.</param>
        /// <param name="bigBlind">The big blind.</param>
        /// <param name="minmiumBuyIn">The minmium buy in.</param>
        /// <param name="maximumBuyIn">The maximum buy in.</param>
        public Game(
            int gameSize = 9, 
            decimal smallBlind = 0.25M, 
            decimal bigBlind = 0.50M, 
            decimal minmiumBuyIn = 1000M, 
            decimal maximumBuyIn = 2500M)
        {
            _dealer = new Dealer(this, new Deck());

            _smallBlind = smallBlind;
            _bigBlind = bigBlind;
            _minmiumBuyIn = minmiumBuyIn;
            _maximumBuyIn = maximumBuyIn;

            for (int i = 0; i < gameSize; i++)
                _playerSeats.Add(new Seat(i));
        }
Esempio n. 2
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();
        }