This could be our opportunity to create a brain for the dealer.
And there really isn't a whole lot because the parameters for blackjack are fairly straightforward.
So the dealer will take cards until he reaches 17.
And if he's goes over or if he busts over 21.
So if he hits 22 and up, then that means that the player wins the game.
And that's all the logic that we have to apply.
So relatively easy and straightforward.
So within the dealer play, let's get the score of the dealer.
So just as we did with the player hand, we're going to get the dealer hand value and return it back
as a value that we can see within the console.
And then using this value, we're going to update from the game status.
Let's update the text content and we'll write the dealer score and then whatever value is being returned
back within the dealer value.
We're going to add that into the text content.
And then there are just a few rules.
So we have to check to see if it's greater than or equal to 17.
And that means that we're going to stop taking cards for the dealer and we're going to have to check
to see who has a higher hand value.
And we'll take the game dealer score because this is final and update the text content to be whatever
is contained for dealer.
So we'll provide the dealer score.
And if they're not over 17, then we're going to keep taking cards until the dealer is over 17 or over
21 and they're busting.
So we're gonna continue to take cards.
And that means that we just need to run the take card and then game dealer hand.
So the cards where they're going, which hand they're going into.
And then also game dealer cards object.
So this is where they're going to be placed on the screen.
And we don't want them to be hidden.
So we just want that as false.
And also updating the score every time with dealer and then running back to dealer play.
So we're gonna continue to play until that condition can no longer play through.
So let's see what happens.
And this is all going to be initiated when we do stand.
So Dealer ended up with 21.
So they stop and stand again.
So, see, the dealer ended up taking a whole bunch of cards.
And then when they hit 17, they stopped taking cards.
And because we've got so many aces in the deck, it's going to be really easy to get up to these values.
So at this point, we can actually conclude that the aces are working and we can get rid of that second
rank so we can play with the actual card values and we can always adjust it as needed as we're doing
our testing.
So it's to a stand.
And the dealer has 17.
So also we need to show that dealer card.
So what the hidden card.
So need to make sure that we can select that and show it and we can do that by within the game object.
We had card back as we created the style that cover over the card.
And then selecting style and display it will set its display value to none.
So that should effectively show that dealer card.
So let's try it.
And when since we hit stand in the dealers card, it is revealed.
So coming up next, we've got to calculate who the winner of the game is.
And then, of course, there's some additional tweaks that we're going to be making.
So go ahead and add in the logic of the dealer.
Play into your game and be ready to move on to the next lesson or recalculate the winner of the game.