From 1639ae0f9b8ba234198e742f72cf6f605358b0d2 Mon Sep 17 00:00:00 2001 From: Nick Pegg Date: Sun, 13 Jul 2025 17:55:04 -0700 Subject: [PATCH] only allow doubling if we have enough money --- src/main.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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; }