public void Bet(decimal amount) { if (this.Game == null) { throw new Exception("Player cannot bet if they are not part of a game."); } if (this.User.Bankroll < amount) { throw new Exception("Player cannot bet more than they have."); } // take bet amount from players bankroll. this.User.Bankroll -= amount; // deal hand to player BlackjackHand hand = new BlackjackHand(amount); Card firstCard = this.Game.Dealer.Deal(); hand.Hit(firstCard); Card secondCard = this.Game.Dealer.Deal(); hand.Hit(secondCard); // assign that hand to the player. this.Hand = hand; }
public BlackjackDealer(int deck_count = 6) { try { this.Deck = new Deck(deck_count); this.Deck.Shuffle(); BlackjackHand newHand = new BlackjackHand(0); Card shownCard = this.Deal(); newHand.Hit(shownCard); Card hiddenCard = this.Deal(true); newHand.Hit(hiddenCard); this.Hand = newHand; } catch (Exception ex) { throw new Exception("Could not create dealer: " + ex); } }