Ejemplo n.º 1
0
        public bool Fold(string name)
        {
            var player = GetPlayer(name);

            VerifyIsPlayersTurn(player);
            BetQueue.RemoveFirst();
            player.Folded  = true;
            player.Hand[0] = null;
            player.Hand[1] = null;
            Pots.ForEach(x => x.RemovePlayer(player));

            if (GetPlayersStillInGame().Count() == 1)
            {
                BetQueue.Clear();
                State = State.DeterminingWinner;
                NextStage();
                return(false);
            }
            else
            {
                if (BetQueue.Count == 0)
                {
                    NextStage();
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
Ejemplo n.º 2
0
        public bool Bet(string name, double wager)
        {
            var player = GetPlayer(name);

            VerifyIsPlayersTurn(player);

            if (player.Folded)
            {
                throw new Exception($"{player.Name} cannot bet after folding");
            }

            if (wager + player.CurrentBet < MinBet && wager != player.Chips)
            {
                throw new Exception($"{player.Name} attempted to bet below min bet of {MinBet}");
            }

            if (player.Chips < wager)
            {
                throw new Exception($"{player.Name} attempt to bet {wager} and only has {player.Chips}");
            }

            // Remove the player from queue.
            BetQueue.RemoveFirst();

            if (wager + player.CurrentBet > MinBet)
            {
                // Need to requeue other players.
                var startAt = PlayerAfterRecursive(player);

                if (BetQueue.Count > 0)
                {
                    startAt = PlayerAfterRecursive(BetQueue.Last.Value);
                }

                while (startAt.Position != player.Position)
                {
                    BetQueue.AddLast(startAt);
                    startAt = PlayerAfterRecursive(startAt);
                }
            }

            // Add the players bet to pot.
            AdjustPotPlayerChips(player, wager);

            if (BetQueue.Count == 0)
            {
                NextStage();
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 3
0
        public bool ShowCards(string name)
        {
            var player = GetPlayer(name);

            VerifyIsPlayersTurn(player);
            BetQueue.RemoveFirst();
            Pots.ForEach(x => x.RemovePlayer(player));
            ShowPlayerCards.Add(player);
            if (BetQueue.Count == 0)
            {
                NextStage();
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 4
0
        public bool HideCards(string name)
        {
            var player = GetPlayer(name);

            VerifyIsPlayersTurn(player);
            BetQueue.RemoveFirst();
            player.Hand[0] = null;
            player.Hand[1] = null;
            Pots.ForEach(x => x.RemovePlayer(player));
            if (BetQueue.Count == 0)
            {
                NextStage();
                return(false);
            }
            else
            {
                return(true);
            }
        }