both having blackjack should be a tie
This commit is contained in:
parent
673dc50ec6
commit
bf5f289720
1 changed files with 7 additions and 7 deletions
14
src/game.rs
14
src/game.rs
|
|
@ -228,12 +228,12 @@ impl Table {
|
||||||
returns: 0,
|
returns: 0,
|
||||||
};
|
};
|
||||||
#[allow(clippy::if_same_then_else)]
|
#[allow(clippy::if_same_then_else)]
|
||||||
if self.dealer_hand.is_blackjack() {
|
if turn.hand.is_blackjack() && !self.dealer_hand.is_blackjack() {
|
||||||
end_state.result = PlayResult::DealerBlackjack;
|
|
||||||
} else if turn.hand.is_blackjack() {
|
|
||||||
end_state.result = PlayResult::Blackjack;
|
end_state.result = PlayResult::Blackjack;
|
||||||
let bj_winnings = (turn.bet as f32 * self.blackjack_returns) as u32;
|
let winnings = (turn.bet as f32 * self.blackjack_returns) as u32;
|
||||||
end_state.returns = turn.bet + bj_winnings;
|
end_state.returns = turn.bet + winnings;
|
||||||
|
} else if !turn.hand.is_blackjack() && self.dealer_hand.is_blackjack() {
|
||||||
|
end_state.result = PlayResult::DealerBlackjack;
|
||||||
} else if turn.hand.value() > 21 {
|
} else if turn.hand.value() > 21 {
|
||||||
end_state.result = PlayResult::Bust;
|
end_state.result = PlayResult::Bust;
|
||||||
} else if self.dealer_hand.value() > 21 {
|
} else if self.dealer_hand.value() > 21 {
|
||||||
|
|
@ -494,8 +494,8 @@ mod tests {
|
||||||
Vec::from([("♣", "A"), ("♣", "10")]),
|
Vec::from([("♣", "A"), ("♣", "10")]),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(result.result, PlayResult::DealerBlackjack);
|
assert_eq!(result.result, PlayResult::Push);
|
||||||
assert_eq!(result.returns, 0);
|
assert_eq!(result.returns, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue