So as we set up the lock wager, we also want to make sure that the wager is locked when we're dealing
the cards.
So when we initiate the deal of the cards, let's run that and toggle it to be true.
So no matter what, as long as we're dealing out cards.
If the player presses the deal button that we're going to not enable any more adjustments to whatever
the bet is.
So whenever the game is in play, we're not updating any of the bets.
So we hit a deal.
We don't want to be able to enable the bet amount.
So this should actually be disabled and we should color the bet button to be great out as well as the
disabled area.
And if you look to inspect the code, you can see that this input style has been disabled.
So so a condition if Torg.
And that means that if Torg is true, then we're going to set the game.
That button style and background color to be a great out color.
And we'll also gray out the input bet style also.
And if it's not, then we're going to reset them back to being black and white.
So see how that works.
So we had a deal.
This is all great.
Out deal.
Stand.
Dealer busted.
And then we need to also enable the ability for the wager.
So this is something else that we need to run as the game is enabled once again.
So whenever we complete the calculations of the set winner, we'll set the lock wager to be false.
And of course, we also have to update the amount of money that's being set and available.
So refresh deal stand.
And now the bet amount is once again enabled.
It's disabled.
Deal.
And you do have to sometimes play through it a few times just to make sure you catch everything within
the set winner where we're determining the winner.
We also need to update the cash for the winner.
So if the player wins, then they're going to their game.
Cash is going to equal whatever their game cash value is.
Plus the game that and this is for a draw.
So it's essentially returning back the money to the player.
If the player wins, then they get twice whatever the game that is multiplied by to return back to their
cash.
So they'll get their original debt back.
Plus they get what their winnings were.
And we also need to have a condition to check for the game cash if it's less than one.
So that means that the player essentially is broke and we need to set the game cash to equal to zero
and game.
Bet is also equal to zero.
So let's try that and we're going to just bet the full amount.
Deal.
Stand Dealer, score 20.
So the dealer wins.
So player has zero cash.
And the players betting zero because you're not able to bet anymore.
So even whatever they deal, whatever money they've got here, it doesn't matter because it's still
working off of what their their cash value is.
And going into the score function.
So if any one of the totals that we're checking, the value, if it's over 21, that means that the
game is over.
And we're simply going to return back whatever the value of the total is.
So this is just another failsafe just to make sure that in case we do detect that the game is over,
that we take the appropriate action to serve other function, that we can run whatever we want to shut
the game, play off.
We just go to game over and let's create that function and game.
And and what game will and will do is it will turn off the ability to hit the buttons and turn off the
game button stand and also will log into the console that it's ended.
So that means that somebody's got 21.
And then also we're we're updating the count.
Want to check to see if the dealer got a blackjack right off the bat.
And if they did, then we know that we need to find the winner right away.
So there's no use continuing the gameplay.
If the dealer has a blackjack and this is commonly done within blackjack games.
So if the dealer is equal to 21 and game dealer hand length.
Remember, this is the array that contains all of the cards is equal to two.
That means that the dealer is holding a blackjack.
So here we can check the game status and output the text content to the user that the dealer got blackjack.
And we actually want to end the game.
And we want to game end.
Function, we're just run that, and that's going to turn off the button, hit the button stand, and
then we also need to make sure that we run the find winner function because that means the game is over,
essentially.
Let's go back up to our code.
And we know that we can update and we can trigger some blackjacks.
So let's just make sure that everything is working.
And you also might want to update some of your code so it works differently just to make sure that sometimes
there is a case that you do need to update and tweak it and test it.
So it's easy.
You can just simply adjust the different card values that are going to be presented to the player as
a great way to test it.
So see that we've got two different blackjacks there.
Draw no winners, 21.
And in this case, we got dealer score 20.
You win 21 Beal.
So whenever it's hitting 21, it's just showing all of the cards.
If either one of them are hitting 21, you've got to take or stand or take another card.
So this probably means that the dealer is 20 and we have 20 as well.
So just stand.
And that's correct that the dealer did have 20.
So all the gameplay is working as expected.
So a draw once again.
And sometimes that is worthwhile.
You got to play through a bunch of times just to make sure everything is working properly.
So coming up next, we'll do a few final tweaks and adjustments just to make sure that everything is
working as expected.
And then we'll do a quick run-Through of all of the code.
That's still to come.