Incorrect use of msg.sender led to the player's hand being added again, causing an error in the stand calculation.
https://github.com/Cyfrin/2024-11-TwentyOne/blob/a4429168302722d14a5e5996d25d6fc5be22a899/src/TwentyOne.sol#L128-L140
As we can see above, msg.sender is used, but this call function is invoked by the player. This means that at this point, msg.sender is the player, so using it to perform actions for the dealer is a logical error
The standThreshold will be set incorrectly.
uint256 newCard = drawCard(msg.sender);
— The player is mistakenly added a card.
uint256 dealerHand = dealersHand(msg.sender);
— At this point, the dealer's hand is incorrectly calculated as the player's hand value.
manual inspection
Add a function dealerTurn(dealer) to automatically handle the dealer's actions, separating the logic for the player's call and the dealer's card drawing, ensuring that msg.sender is not misused.
Directly use the dealer instead of msg.sender
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.