コード例 #1
0
        internal void PlaceWager(BlackjackGamePlayer player, double amount)
        {
            if (!Players.Contains(player))
            {
                throw new InvalidOperationException("'player' is null or invalid");
            }

            if (player.IsLive)
            {
                throw new InvalidOperationException("Player is in live round");
            }

            if (RoundPlayersQueuedForNextRound.Any(a => a.Player.Id == player.Id))
            {
                throw new InvalidOperationException();
            }

            if (amount > player.Account.Balance)
            {
                throw new InvalidOperationException("Insufficient funds");
            }

            if (amount < MinWager || amount > MaxWager)
            {
                throw new InvalidOperationException("Player wager is out of range");
            }

            player.Account.Debit(amount);
            RoundPlayersQueuedForNextRound.Add(new BlackjackGameRoundPlayer(player, amount));
        }
コード例 #2
0
        public virtual void StartRound()
        {
            RoundClosedBecauseOfDealer21 = false;
            if (IsRoundInProgress)
            {
                throw new InvalidOperationException("Live round in progress");
            }

            if (!RoundPlayersQueuedForNextRound.Any())
            {
                throw new InvalidOperationException("No players have wagered");
            }

            var roundInProgress = new BlackjackGameRound(RoundPlayersQueuedForNextRound);

            RoundPlayersQueuedForNextRound.Clear();

            Dealer.Deal(roundInProgress);

            if (DealerHas21)
            {
                EndRound();
                RoundClosedBecauseOfDealer21 = true;
            }
        }