require explicit dealer play again, because it is needed when we did a split
This commit is contained in:
parent
bf5f289720
commit
1306c9d208
2 changed files with 16 additions and 18 deletions
|
|
@ -201,7 +201,9 @@ impl Table {
|
|||
return Err(BlackjackError::IncorrectAction(self.phase));
|
||||
}
|
||||
|
||||
if turn.hand.value() <= 21 {
|
||||
// TODO: Instead of checking pending results, we should probably check to see if there are
|
||||
// any unbusted hands out. Might require us to hold on to turns locally.
|
||||
if turn.hand.value() <= 21 || self.pending_results > 1 {
|
||||
while self.dealer_hand.value() < 17 {
|
||||
let dealer_card = self.deal_card();
|
||||
self.dealer_hand.push(dealer_card);
|
||||
|
|
@ -213,10 +215,6 @@ impl Table {
|
|||
|
||||
/// Get the results
|
||||
pub fn results(&mut self, turn: PlayerTurn) -> Result<EndState, BlackjackError> {
|
||||
if self.phase == Phase::DealerTurn {
|
||||
self.dealers_turn(&turn)?;
|
||||
}
|
||||
|
||||
if self.phase != Phase::Results {
|
||||
return Err(BlackjackError::IncorrectAction(self.phase));
|
||||
}
|
||||
|
|
|
|||
24
src/main.rs
24
src/main.rs
|
|
@ -92,21 +92,18 @@ fn interactive_play(args: Args) -> anyhow::Result<()> {
|
|||
println!();
|
||||
|
||||
let mut turn = table.deal_hand(bet);
|
||||
let split_turn = interactive_play_turn(&mut turn, &mut table, &args)?;
|
||||
let split_result = match split_turn {
|
||||
Some(mut st) => {
|
||||
interactive_play_turn(&mut st, &mut table, &args)?;
|
||||
Some(table.results(st)?)
|
||||
let mut split_turn = interactive_play_turn(&mut turn, &mut table, &args)?;
|
||||
if let Some(st) = &mut split_turn {
|
||||
interactive_play_turn(st, &mut table, &args)?;
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
table.dealers_turn(&turn)?;
|
||||
|
||||
term.clear_screen()?;
|
||||
let result = table.results(turn)?;
|
||||
print_result(&result);
|
||||
if let Some(r) = split_result {
|
||||
if let Some(st) = split_turn {
|
||||
println!();
|
||||
print_result(&r);
|
||||
print_result(&table.results(st)?);
|
||||
}
|
||||
|
||||
table.end_game()?;
|
||||
|
|
@ -387,9 +384,12 @@ fn old_man(args: Args) -> anyhow::Result<()> {
|
|||
&& table.player_chips() > (PER_DAY - MAX_LOSS)
|
||||
{
|
||||
let mut turn = table.deal_hand(MIN_BET);
|
||||
let split_turn = basic_strategy_play_turn(&mut turn, &mut table)?;
|
||||
if let Some(mut st) = split_turn {
|
||||
basic_strategy_play_turn(&mut st, &mut table)?;
|
||||
let mut split_turn = basic_strategy_play_turn(&mut turn, &mut table)?;
|
||||
if let Some(st) = &mut split_turn {
|
||||
basic_strategy_play_turn(st, &mut table)?;
|
||||
}
|
||||
table.dealers_turn(&turn)?;
|
||||
if let Some(st) = split_turn {
|
||||
table.results(st)?;
|
||||
}
|
||||
table.results(turn)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue