only allow doubling if we have enough money
This commit is contained in:
parent
1306c9d208
commit
1639ae0f9b
1 changed files with 8 additions and 6 deletions
12
src/main.rs
12
src/main.rs
|
|
@ -132,6 +132,8 @@ fn interactive_play_turn(
|
||||||
loop {
|
loop {
|
||||||
term.clear_screen()?;
|
term.clear_screen()?;
|
||||||
let hand = turn.player_hand();
|
let hand = turn.player_hand();
|
||||||
|
let can_double = initial_play && table.player_chips() > turn.bet;
|
||||||
|
let can_split = initial_play && hand.is_pair();
|
||||||
|
|
||||||
if turn.shuffled {
|
if turn.shuffled {
|
||||||
println!("Deck was shuffled");
|
println!("Deck was shuffled");
|
||||||
|
|
@ -159,11 +161,11 @@ fn interactive_play_turn(
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut msg = String::from("(h)it, (s)tand");
|
let mut msg = String::from("(h)it, (s)tand");
|
||||||
if initial_play {
|
if can_double {
|
||||||
msg += ", (d)ouble-down";
|
msg += ", (d)ouble-down";
|
||||||
if hand.is_pair() {
|
|
||||||
msg += ", s(p)lit";
|
|
||||||
}
|
}
|
||||||
|
if can_split {
|
||||||
|
msg += ", s(p)lit";
|
||||||
}
|
}
|
||||||
msg += "? ";
|
msg += "? ";
|
||||||
io::stdout().write_all(msg.as_bytes())?;
|
io::stdout().write_all(msg.as_bytes())?;
|
||||||
|
|
@ -180,12 +182,12 @@ fn interactive_play_turn(
|
||||||
stop = true;
|
stop = true;
|
||||||
initial_play = false;
|
initial_play = false;
|
||||||
}
|
}
|
||||||
'd' if initial_play => {
|
'd' if can_double => {
|
||||||
table.double_down(turn)?;
|
table.double_down(turn)?;
|
||||||
stop = true;
|
stop = true;
|
||||||
initial_play = false;
|
initial_play = false;
|
||||||
}
|
}
|
||||||
'p' if initial_play && turn.player_hand().is_pair() => {
|
'p' if can_split => {
|
||||||
other_turn = Some(table.split(turn)?);
|
other_turn = Some(table.split(turn)?);
|
||||||
initial_play = false;
|
initial_play = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue