예제 #1
0
        public void HandleRequestToHit(BlackjackGamePlayer player)
        {
            if (RoundInProgress == null)
            {
                throw new InvalidOperationException("No round in play");
            }

            var roundplayer = RoundInProgress.GetRoundPlayer(player);

            if (roundplayer == null)
            {
                throw new ArgumentException("'player' is null or invalid");
            }

            if (!roundplayer.HasAction || roundplayer.Hand == null)
            {
                throw new InvalidOperationException("Out of turn");
            }

            if (roundplayer.Hand.IsBusted)
            {
                throw new InvalidOperationException("Cannot hit busted hand");
            }

            roundplayer.AddCardToHand(_shoe.DealCard());

            if (roundplayer.Hand.IsBusted)
            {
                moveToNextAction();
            }
        }
예제 #2
0
        public void HandleRequestToDoubleDown(BlackjackGamePlayer player, double amount)
        {
            if (RoundInProgress == null)
            {
                throw new InvalidOperationException("No round in play");
            }

            var roundplayer = RoundInProgress.GetRoundPlayer(player);

            if (roundplayer == null)
            {
                throw new ArgumentException("'player' is null or invalid");
            }

            if (!roundplayer.HasAction || roundplayer.Hand == null)
            {
                throw new InvalidOperationException("Out of turn");
            }

            if (roundplayer.Hand.Cards.Count() != 2)
            {
                throw new InvalidOperationException("Must have 2 cards to double");
            }

            if (amount > roundplayer.Wager)
            {
                throw new InvalidOperationException("Amounts exceeds current wager");
            }

            roundplayer.AddCardToHand(_shoe.DealCard());
            roundplayer.Wager += amount;
            roundplayer.Player.Account.Debit(amount);

            moveToNextAction();
        }
예제 #3
0
        public BlackjackHandSettlement SettleHand(BlackjackGamePlayer player)
        {
            var roundplayer = RoundInProgress.GetRoundPlayer(player);

            if (roundplayer == null)
            {
                throw new ArgumentException("'player' is null or invalid");
            }

            return(settleHand(roundplayer));
        }
예제 #4
0
        public void HandleRequestToStand(BlackjackGamePlayer player)
        {
            if (RoundInProgress == null)
            {
                throw new InvalidOperationException("No round in play");
            }

            var roundplayer = RoundInProgress.GetRoundPlayer(player);

            if (roundplayer == null)
            {
                throw new ArgumentException("'player' is null or invalid");
            }

            if (!roundplayer.HasAction || roundplayer.Hand == null)
            {
                throw new InvalidOperationException("Out of turn");
            }

            moveToNextAction();
        }