diff --git a/src/main.rs b/src/main.rs index 4fd7dfb..3f783d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -132,6 +132,8 @@ fn interactive_play_turn( loop { term.clear_screen()?; 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 { println!("Deck was shuffled"); @@ -159,11 +161,11 @@ fn interactive_play_turn( } let mut msg = String::from("(h)it, (s)tand"); - if initial_play { + if can_double { msg += ", (d)ouble-down"; - if hand.is_pair() { - msg += ", s(p)lit"; - } + } + if can_split { + msg += ", s(p)lit"; } msg += "? "; io::stdout().write_all(msg.as_bytes())?; @@ -180,12 +182,12 @@ fn interactive_play_turn( stop = true; initial_play = false; } - 'd' if initial_play => { + 'd' if can_double => { table.double_down(turn)?; stop = true; initial_play = false; } - 'p' if initial_play && turn.player_hand().is_pair() => { + 'p' if can_split => { other_turn = Some(table.split(turn)?); initial_play = false; }