In BlackJack, the Ace can have a value of either 11 or 1, depending on the current hand value of the player. If the current player's hand value plus 11 is less than or equal to 21, then the Ace should be counted as 11; otherwise, it is counted as 1. This rule is not honored in the TwentyOne::dealersHand function, which adds the Ace as 10 in all cases.
Inside TwentyOne::dealersHand the current card value is calculated with:
where the card value could be between 0 and 12. When the card value is 0 (representing the Ace as it is the 13th card), the following code adds 10 to the dealer's total:
This does not follow BlackJack rules, as the Ace should be added as either 11 or 1, depending on the dealer's current hand total.
High Impact: This bug occurs 100% of the time. The TwentyOne::playersHand calculation is incorrect, which may result in players losing when they should have won, or winning when they should have lost.
Manual Review
Foundry (PoC unit tests can be provided upon request)
ChatGPT
Update the logic to properly handle the cardValue for an Ace.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.