コード例 #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));
        }