The usual backjack game can result in a draw if the player's hand value = dealer's hand value. but `TwentyOne.sol::call()` does not have the case handling of the issue, rather if the player's hand's value= dealer's hand value it would make the dealer winner because of no case of Draw making it unfair to player
adding a case if the dealer' value = player's value that can handle the case and changing the TwentyOne.sol::call()
function call() public {
require(
playersDeck[msg.sender].playersCards.length > 0,
"Game not started"
);
uint256 playerHand = playersHand(msg.sender);
uint256 standThreshold = (uint256(
keccak256(
abi.encodePacked(block.timestamp, msg.sender, block.prevrandao)
)
) % 5) + 17;
while (dealersHand(msg.sender) < standThreshold) {
uint256 newCard = drawCard(msg.sender);
addCardForDealer(msg.sender, newCard);
}
uint256 dealerHand = dealersHand(msg.sender);
if (dealerHand > 21) {
emit PlayerWonTheGame(
"Dealer went bust, players winning hand: ",
playerHand
);
endGame(msg.sender, true);
} else if (playerHand > dealerHand) {
emit PlayerWonTheGame(
"Dealer's hand is lower, players winning hand: ",
playerHand
);
endGame(msg.sender, true);
}
else if (playerHand == dealerHand) {
emit PlayerLostTheGame(
"It's a tie, dealer's hand: ",
dealerHand
)else {
emit PlayerLostTheGame(
"Dealer's hand is higher, dealers winning hand: ",
dealerHand
);
endGame(msg.sender, false);
}
}