Don't deal cards to dealer if player has busted

This commit is contained in:
Nick Pegg 2025-07-11 16:54:10 -07:00
parent 2e31a68de3
commit 673dc50ec6
2 changed files with 22 additions and 12 deletions

View file

@ -49,7 +49,11 @@ fn interactive_play(args: Args) -> anyhow::Result<()> {
println!("\nMoney in the bank: ${bank}");
// TODO: show normalized card count
if args.show_count {
println!("Card count: {}", table.count());
println!(
"Card count: {} ({})",
table.count(),
table.count() / args.decks as i16
);
println!("Cards in shoe: {}", table.shoe_count());
}
@ -88,10 +92,10 @@ fn interactive_play(args: Args) -> anyhow::Result<()> {
println!();
let mut turn = table.deal_hand(bet);
let split_turn = interactive_play_turn(&mut turn, &mut table, args.show_count)?;
let split_turn = interactive_play_turn(&mut turn, &mut table, &args)?;
let split_result = match split_turn {
Some(mut st) => {
interactive_play_turn(&mut st, &mut table, args.show_count)?;
interactive_play_turn(&mut st, &mut table, &args)?;
Some(table.results(st)?)
}
None => None,
@ -122,7 +126,7 @@ fn interactive_play(args: Args) -> anyhow::Result<()> {
fn interactive_play_turn(
turn: &mut PlayerTurn,
table: &mut Table,
show_count: bool,
args: &Args,
) -> anyhow::Result<Option<PlayerTurn>> {
let mut initial_play = !turn.was_split;
let mut other_turn = None;
@ -135,8 +139,12 @@ fn interactive_play_turn(
if turn.shuffled {
println!("Deck was shuffled");
}
if show_count {
println!("Card count: {}", table.count());
if args.show_count {
println!(
"Card count: {} ({})",
table.count(),
table.count() / args.decks as i16
);
}
println!("Your bet: ${}", turn.bet);
println!("Dealer showing: {}", table.dealer_showing());