offer to show count to user
This commit is contained in:
parent
1639ae0f9b
commit
2ae9da9b36
1 changed files with 10 additions and 2 deletions
12
src/main.rs
12
src/main.rs
|
|
@ -47,7 +47,6 @@ fn interactive_play(args: Args) -> anyhow::Result<()> {
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
println!("\nMoney in the bank: ${bank}");
|
println!("\nMoney in the bank: ${bank}");
|
||||||
// TODO: show normalized card count
|
|
||||||
if args.show_count {
|
if args.show_count {
|
||||||
println!(
|
println!(
|
||||||
"Card count: {} ({})",
|
"Card count: {} ({})",
|
||||||
|
|
@ -127,6 +126,7 @@ fn interactive_play_turn(
|
||||||
) -> anyhow::Result<Option<PlayerTurn>> {
|
) -> anyhow::Result<Option<PlayerTurn>> {
|
||||||
let mut initial_play = !turn.was_split;
|
let mut initial_play = !turn.was_split;
|
||||||
let mut other_turn = None;
|
let mut other_turn = None;
|
||||||
|
let mut show_count = args.show_count;
|
||||||
|
|
||||||
let term = Term::stdout();
|
let term = Term::stdout();
|
||||||
loop {
|
loop {
|
||||||
|
|
@ -138,12 +138,15 @@ fn interactive_play_turn(
|
||||||
if turn.shuffled {
|
if turn.shuffled {
|
||||||
println!("Deck was shuffled");
|
println!("Deck was shuffled");
|
||||||
}
|
}
|
||||||
if args.show_count {
|
if show_count {
|
||||||
println!(
|
println!(
|
||||||
"Card count: {} ({})",
|
"Card count: {} ({})",
|
||||||
table.count(),
|
table.count(),
|
||||||
table.count() / args.decks as i16
|
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!("Your bet: ${}", turn.bet);
|
||||||
println!("Dealer showing: {}", table.dealer_showing());
|
println!("Dealer showing: {}", table.dealer_showing());
|
||||||
|
|
@ -167,6 +170,10 @@ fn interactive_play_turn(
|
||||||
if can_split {
|
if can_split {
|
||||||
msg += ", s(p)lit";
|
msg += ", s(p)lit";
|
||||||
}
|
}
|
||||||
|
if !args.show_count {
|
||||||
|
// Not given via CLI args, so ask user
|
||||||
|
msg += ", show (c)ount";
|
||||||
|
}
|
||||||
msg += "? ";
|
msg += "? ";
|
||||||
io::stdout().write_all(msg.as_bytes())?;
|
io::stdout().write_all(msg.as_bytes())?;
|
||||||
io::stdout().flush()?;
|
io::stdout().flush()?;
|
||||||
|
|
@ -191,6 +198,7 @@ fn interactive_play_turn(
|
||||||
other_turn = Some(table.split(turn)?);
|
other_turn = Some(table.split(turn)?);
|
||||||
initial_play = false;
|
initial_play = false;
|
||||||
}
|
}
|
||||||
|
'c' => show_count = true,
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
if stop {
|
if stop {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue