TwentyOne

First Flight #29
Beginner FriendlyGameFiFoundrySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Incorrect Calculation of Dealer's Total

Summary

The dealersHand function in the Solidity contract contains a logical flaw in how the dealer's hand total is calculated, specifically regarding the handling of Ace cards (represented by a 0 value). The current implementation does not correctly treat the Ace as either 1 or 11 based on the context of the hand. This oversight can lead to incorrect dealer hand totals and impact the fairness and integrity of the game.

Impact

Incorrect calculation of the dealer's total, affecting game outcomes.

Tools Used

Manual

Recommendations

function dealersHand(address player) public view returns (uint256) {
uint256 dealerTotal = 0;
for (uint256 i = 0; i < dealersDeck[player].dealersCards.length; i++) {
uint256 cardValue = dealersDeck[player].dealersCards[i] % 13;
- if (cardValue >= 10) {
+ if (cardValue == 0 || cardValue >= 10) {
dealerTotal += 10;
} else {
dealerTotal += cardValue;
}
}
return dealerTotal;
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Asymmetric calculation of hands is rigged in the player`s favor.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.