offer to show count to user

This commit is contained in:
Nick Pegg 2025-07-13 19:07:41 -07:00
parent 1639ae0f9b
commit 2ae9da9b36

View file

@ -47,7 +47,6 @@ fn interactive_play(args: Args) -> anyhow::Result<()> {
loop {
println!("\nMoney in the bank: ${bank}");
// TODO: show normalized card count
if args.show_count {
println!(
"Card count: {} ({})",
@ -127,6 +126,7 @@ fn interactive_play_turn(
) -> anyhow::Result<Option<PlayerTurn>> {
let mut initial_play = !turn.was_split;
let mut other_turn = None;
let mut show_count = args.show_count;
let term = Term::stdout();
loop {
@ -138,12 +138,15 @@ fn interactive_play_turn(
if turn.shuffled {
println!("Deck was shuffled");
}
if args.show_count {
if show_count {
println!(
"Card count: {} ({})",
table.count(),
table.count() / args.decks as i16
);
// Reset to CLI arg value until user asks again
show_count = args.show_count;
}
println!("Your bet: ${}", turn.bet);
println!("Dealer showing: {}", table.dealer_showing());
@ -167,6 +170,10 @@ fn interactive_play_turn(
if can_split {
msg += ", s(p)lit";
}
if !args.show_count {
// Not given via CLI args, so ask user
msg += ", show (c)ount";
}
msg += "? ";
io::stdout().write_all(msg.as_bytes())?;
io::stdout().flush()?;
@ -191,6 +198,7 @@ fn interactive_play_turn(
other_turn = Some(table.split(turn)?);
initial_play = false;
}
'c' => show_count = true,
_ => {}
};
if stop {