TwentyOne

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

Ace modification

Summary:
In blackjack Ace can play both as 1 and 11. It can change It's value depends on the situation.

Vulnerability Details:
In this example Ace would be considered only as 1

Impact:
If we draw 1 (Ace) and 7 our total will be 8, but if we count Ace as 11 It will be 18 which closer to 21 and in the end the main point in the game is to be as close as possible or eqeual to 21.

Tools Used:
Manuel review.

Recommendations:
I suggest to refactor both dealersHand and playersHand. If you add a check that is: if(cardValue ==1) if it's true declare a variable to store Ace as 11 and continue to the next card withoud modifing totalValue. After the for loop is over add another check that calculates Ace + totalValue and if it over 21, Ace will be added to totalValue as 1, but if it less then will be added as 11.

Updates

Lead Judging Commences

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

Wrong ace value

Support

FAQs

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