If the game is modeled the Twenty, both player & dealer should have the same condition. However, when cardValue == 0 for the dealer, it doesn't return the value 10.
Cards are computed as cardValue = card % 13, which can result in 0 for certain cards (13, 26, 39, 52).
When the first call & second call for dealerHand have values of cardValue returns zero, dealerTotal will be zero, which is unfair for players.
POC
Add this test to the TwentyOne.t.sol file.
Run forge test --match-test testInconsistent_DealerCardValue -vvv on your terminal.
Result:
With this design choice, the Player will have a higher chance of losing to the dealer as cardValue == 0 will lower the chance of a high dealerTotal.
The cardValue == 0 is not an ideal model for the game of TwentyOne.
Foundry 0.2.0 and the console functionality.
Replace the TwentyOne::dealersHand with the following.
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.