Пример #1
0
 /// <summary>
 /// Buys the in to game.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <param name="seatNumber">The seat number.</param>
 /// <param name="amount">The amount.</param>
 public void BuyInToGame(Game game, int seatNumber, decimal amount)
 {
     if (game.AddPlayerToGame(this, seatNumber, amount))
     {
         State = new WaitingState();
     }
 }
Пример #2
0
        public Dealer(Game game, Deck deck)
        {
            _game = game;
            _deck = deck;

            _game.PlayerAdded += GameOnPlayerAdded;
            _game.PlayerRemoved += GameOnPlayerRemoved;
        }
Пример #3
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();
        }
Пример #4
0
 private void DealSingleCardToGame(Game game)
 {
     game.AddCommunityCard(_deck.Pop());
 }
Пример #5
0
 public void DealTurn(Game game)
 {
     DealSingleCardToGame(game);
 }
Пример #6
0
 public void DealRiver(Game game)
 {
     DealSingleCardToGame(game);
 }
Пример #7
0
 public void DealFlop(Game game)
 {
     for (int i = 0; i < 3; i++)
         DealSingleCardToGame(game);
 }
Пример #8
0
 public void CollectCards(Game game)
 {
     IEnumerable<Card> returnedCards = game.ReturnCards();
     foreach (Card card in returnedCards)
         _deck.Push(card);
 }