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(); } }
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(); }
public BlackjackHandSettlement SettleHand(BlackjackGamePlayer player) { var roundplayer = RoundInProgress.GetRoundPlayer(player); if (roundplayer == null) { throw new ArgumentException("'player' is null or invalid"); } return(settleHand(roundplayer)); }
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(); }