So when you are building a game, it's always important to consider what the next step is and what you
want to people the player to be able to do.
So we're working on two core functions that are going to be used within the gameplay.
So we've got the score, which is handling and calculating out the score of whatever is being returned
back within the card array.
So let's wrap that up and we need to look through as we're looping through the cards.
We can't always assume that it's going to be no value.
So in case it might be an ace and actually it's probably better if we create another ranks.
So I'm going to comment this one out and I'm going to create one that's going to have more probability
of getting some low cards and an ace.
So we'll just duplicate that and now or we deal it out.
There's more probability of them being aces.
So this is presents an issue whenever we're calculating out what the totals could possibly be, because
it could be an ace, which has no value.
And it also could be worth one or eleven.
And then I'm also going to add in the probability of getting kings.
So I have a couple of those.
So just steal that.
So right now it is calculating property because we do have the value, but we need to take into account
the possibility that it is an ace.
And if it is an ace, then we have to possibly adjust the score.
And that's where we've got a running variable there that's counting the number of aces.
So taking the card rank and checking to see if it's equal to a and if it is, that means that it is
an ace and it's got the possibility of being a one or an eleven.
So what we're gonna do is we're going to update the value for aces.
So and as mentioned, we might have a possibility of getting multiple aces.
So then we'd have to account for that.
So if we did end up with two aces, then we would have to account for the two aces.
And we can increase that by adding more aces to the deck side, a bunch of aces to the deck.
So now the probability of getting two aces is super high and we end up with the value of 22, just as
we did.
So I had to actually do that a few times.
But now we've got the ace count going up.
And now we have to do a little bit calculation here that if we have more than one ace and if it's greater
than 21, then we have to re score the total for the Aces and recalculate it.
And if the total is still larger than 21, then it's actually game over for the player.
And it's going to be.
And we're going to let the dealer play out his hand.
So there's a few things that we have to account for.
And the total is always going to be the total value.
So let's add in that condition where we're checking to see if aces are greater than zero and the total
is greater than 21.
So in this case, the aces would be greater than zero and the total is larger than 21 because it's 22.
So typically that would mean that the game is over.
But because it's two aces, we can account for it and we can take the total and a skying a score ace
function passing in the total and sending over that count for the aces.
And what this function is going to do is it's going to allow us to calculate and account for a number
of aces and then we can loop back into this function until we get a value that's going to be less than
21 or if we run out of aces to remove values off of.
So first we check to see if the value is less than twenty one.
And if it's less than twenty one, then there's no need.
So in this case, if we had one ace and the total for whatever reason was over 21.
And if we checked over here and it's under 21, which probably can't occur because we're here, we're
over here, we're under.
But sometimes it is possible.
So we just want to account for any possibility.
And then just return the value.
So this this condition most likely will never be met because we already have the total over 21.
And that's when we're launching into the function called score ace.
So also we'll check.
Else if.
And we'll check to see if ACES is larger than zero.
And that means that the score is over 21.
And the aces are larger than zero.
So we're subtracting from the aces total.
And we're updating the value, subtracting ten off of the value because the aces by default have a value
of eleven.
And if we're over 21.
And if we do have an ace.
We want to reset the value of that ace.
To be one.
And this is where we return score ace.
And value of the number of aces.
So we do a recursive function looping back into this function.
Until these conditions are no longer met.
And we simply can just return back the value.
And in some cases, we even after we're reducing the value by 10.
That might not account for enough and we might possibly still be over 21.
And that's where we enough to end the game for the player.
So see what happens.
And I'll refresh.
And so now we've got two aces.
And our score is 12.
And we can still do a hit and a stand.
So that function where we've got the score is the one that's gonna be able to calculate out our actual
total.
And it's accounting for the aces.
So going back down to the update count or going back up to update count.
So we've checked to see if that player is less than 21.
And also, we're going to check to see if the player is greater than 21.
And if they are, then we're going to run a function called find winner.
And I'm just going to set a placeholder for this, because this means that whenever the player is over
21, then we just need to end the game.
We need to run through all of the calculations and it's going to be the same thing.
So it's going to allow the dealer to play through if they're under 21.
But if they're over 21, the players already busted.
So it just cover placeholder for that.
And we're gonna count for that in the upcoming lessons.
And if they're not over 21, we're going to take the game status and update the text content to, say,
the dealer in play.
And you can change the rules for what the dealer minimum is.
And we're going to also have a function here for the dealer play and passing in the dealer object.
So, again, setting up the place holders for those functions.
Every I create these in the later lesson.
So those are just placeholders for those.
So see what happens.
And whenever you're creating a game, you just gotta to think of what the next action that you want
the user to be able to play.
And then make tweaks and adjustments to the code accordingly.
So at this point, we still provide the player an option to hit and stand.
So coming up next, we're going to account for the actions on these buttons in order to produce the
gameplay.
So it's come up in the upcoming lessons and then we're gonna go.
Back to some of what we've been doing here, where we've been setting up this place, Holder functions
and we're going to build those out as well.
So that is all still yet to come.