1
00:00:00,330 --> 00:00:05,190
So when you are building a game, it's always important to consider what the next step is and what you

2
00:00:05,190 --> 00:00:07,260
want to people the player to be able to do.

3
00:00:07,590 --> 00:00:12,320
So we're working on two core functions that are going to be used within the gameplay.

4
00:00:12,690 --> 00:00:19,440
So we've got the score, which is handling and calculating out the score of whatever is being returned

5
00:00:19,440 --> 00:00:20,820
back within the card array.

6
00:00:21,210 --> 00:00:25,890
So let's wrap that up and we need to look through as we're looping through the cards.

7
00:00:26,220 --> 00:00:28,890
We can't always assume that it's going to be no value.

8
00:00:29,160 --> 00:00:34,530
So in case it might be an ace and actually it's probably better if we create another ranks.

9
00:00:34,950 --> 00:00:41,040
So I'm going to comment this one out and I'm going to create one that's going to have more probability

10
00:00:41,100 --> 00:00:43,620
of getting some low cards and an ace.

11
00:00:44,160 --> 00:00:46,560
So we'll just duplicate that and now or we deal it out.

12
00:00:46,860 --> 00:00:49,080
There's more probability of them being aces.

13
00:00:49,710 --> 00:00:56,400
So this is presents an issue whenever we're calculating out what the totals could possibly be, because

14
00:00:56,730 --> 00:00:59,710
it could be an ace, which has no value.

15
00:01:00,090 --> 00:01:03,750
And it also could be worth one or eleven.

16
00:01:04,130 --> 00:01:07,460
And then I'm also going to add in the probability of getting kings.

17
00:01:08,100 --> 00:01:09,330
So I have a couple of those.

18
00:01:09,480 --> 00:01:10,350
So just steal that.

19
00:01:10,950 --> 00:01:16,530
So right now it is calculating property because we do have the value, but we need to take into account

20
00:01:16,800 --> 00:01:19,200
the possibility that it is an ace.

21
00:01:19,470 --> 00:01:23,760
And if it is an ace, then we have to possibly adjust the score.

22
00:01:24,150 --> 00:01:27,960
And that's where we've got a running variable there that's counting the number of aces.

23
00:01:28,440 --> 00:01:36,630
So taking the card rank and checking to see if it's equal to a and if it is, that means that it is

24
00:01:36,630 --> 00:01:42,030
an ace and it's got the possibility of being a one or an eleven.

25
00:01:42,570 --> 00:01:46,070
So what we're gonna do is we're going to update the value for aces.

26
00:01:46,470 --> 00:01:51,120
So and as mentioned, we might have a possibility of getting multiple aces.

27
00:01:51,420 --> 00:01:52,890
So then we'd have to account for that.

28
00:01:52,920 --> 00:01:58,830
So if we did end up with two aces, then we would have to account for the two aces.

29
00:01:59,220 --> 00:02:04,890
And we can increase that by adding more aces to the deck side, a bunch of aces to the deck.

30
00:02:05,440 --> 00:02:11,130
So now the probability of getting two aces is super high and we end up with the value of 22, just as

31
00:02:11,130 --> 00:02:11,430
we did.

32
00:02:11,790 --> 00:02:13,590
So I had to actually do that a few times.

33
00:02:13,830 --> 00:02:17,070
But now we've got the ace count going up.

34
00:02:17,370 --> 00:02:25,470
And now we have to do a little bit calculation here that if we have more than one ace and if it's greater

35
00:02:25,530 --> 00:02:32,290
than 21, then we have to re score the total for the Aces and recalculate it.

36
00:02:32,940 --> 00:02:39,060
And if the total is still larger than 21, then it's actually game over for the player.

37
00:02:39,330 --> 00:02:40,260
And it's going to be.

38
00:02:41,390 --> 00:02:44,090
And we're going to let the dealer play out his hand.

39
00:02:44,330 --> 00:02:46,280
So there's a few things that we have to account for.

40
00:02:46,550 --> 00:02:49,310
And the total is always going to be the total value.

41
00:02:49,730 --> 00:02:57,560
So let's add in that condition where we're checking to see if aces are greater than zero and the total

42
00:02:57,860 --> 00:02:59,640
is greater than 21.

43
00:02:59,990 --> 00:03:06,580
So in this case, the aces would be greater than zero and the total is larger than 21 because it's 22.

44
00:03:06,980 --> 00:03:09,710
So typically that would mean that the game is over.

45
00:03:10,040 --> 00:03:20,060
But because it's two aces, we can account for it and we can take the total and a skying a score ace

46
00:03:20,150 --> 00:03:26,300
function passing in the total and sending over that count for the aces.

47
00:03:26,750 --> 00:03:32,900
And what this function is going to do is it's going to allow us to calculate and account for a number

48
00:03:32,900 --> 00:03:42,620
of aces and then we can loop back into this function until we get a value that's going to be less than

49
00:03:42,730 --> 00:03:47,230
21 or if we run out of aces to remove values off of.

50
00:03:48,260 --> 00:03:53,210
So first we check to see if the value is less than twenty one.

51
00:03:54,110 --> 00:03:56,840
And if it's less than twenty one, then there's no need.

52
00:03:57,320 --> 00:04:03,520
So in this case, if we had one ace and the total for whatever reason was over 21.

53
00:04:03,980 --> 00:04:09,830
And if we checked over here and it's under 21, which probably can't occur because we're here, we're

54
00:04:09,830 --> 00:04:10,940
over here, we're under.

55
00:04:11,600 --> 00:04:13,790
But sometimes it is possible.

56
00:04:13,790 --> 00:04:16,880
So we just want to account for any possibility.

57
00:04:17,300 --> 00:04:18,890
And then just return the value.

58
00:04:19,310 --> 00:04:25,410
So this this condition most likely will never be met because we already have the total over 21.

59
00:04:25,820 --> 00:04:29,120
And that's when we're launching into the function called score ace.

60
00:04:30,320 --> 00:04:31,610
So also we'll check.

61
00:04:31,700 --> 00:04:32,440
Else if.

62
00:04:33,140 --> 00:04:37,340
And we'll check to see if ACES is larger than zero.

63
00:04:38,150 --> 00:04:40,400
And that means that the score is over 21.

64
00:04:40,460 --> 00:04:42,470
And the aces are larger than zero.

65
00:04:42,830 --> 00:04:45,500
So we're subtracting from the aces total.

66
00:04:46,010 --> 00:04:53,330
And we're updating the value, subtracting ten off of the value because the aces by default have a value

67
00:04:53,330 --> 00:04:54,050
of eleven.

68
00:04:54,320 --> 00:04:56,190
And if we're over 21.

69
00:04:56,510 --> 00:04:57,860
And if we do have an ace.

70
00:04:58,040 --> 00:05:00,200
We want to reset the value of that ace.

71
00:05:00,320 --> 00:05:01,160
To be one.

72
00:05:01,790 --> 00:05:05,850
And this is where we return score ace.

73
00:05:06,890 --> 00:05:09,500
And value of the number of aces.

74
00:05:10,220 --> 00:05:14,240
So we do a recursive function looping back into this function.

75
00:05:14,540 --> 00:05:16,910
Until these conditions are no longer met.

76
00:05:17,210 --> 00:05:20,270
And we simply can just return back the value.

77
00:05:20,810 --> 00:05:25,610
And in some cases, we even after we're reducing the value by 10.

78
00:05:25,970 --> 00:05:31,480
That might not account for enough and we might possibly still be over 21.

79
00:05:31,760 --> 00:05:33,770
And that's where we enough to end the game for the player.

80
00:05:34,280 --> 00:05:35,420
So see what happens.

81
00:05:35,480 --> 00:05:36,470
And I'll refresh.

82
00:05:36,950 --> 00:05:38,510
And so now we've got two aces.

83
00:05:38,750 --> 00:05:40,000
And our score is 12.

84
00:05:40,100 --> 00:05:41,960
And we can still do a hit and a stand.

85
00:05:42,440 --> 00:05:48,350
So that function where we've got the score is the one that's gonna be able to calculate out our actual

86
00:05:48,350 --> 00:05:48,920
total.

87
00:05:49,190 --> 00:05:50,930
And it's accounting for the aces.

88
00:05:51,320 --> 00:05:57,140
So going back down to the update count or going back up to update count.

89
00:05:57,680 --> 00:06:02,020
So we've checked to see if that player is less than 21.

90
00:06:03,110 --> 00:06:08,540
And also, we're going to check to see if the player is greater than 21.

91
00:06:09,920 --> 00:06:14,190
And if they are, then we're going to run a function called find winner.

92
00:06:15,440 --> 00:06:22,040
And I'm just going to set a placeholder for this, because this means that whenever the player is over

93
00:06:22,050 --> 00:06:25,070
21, then we just need to end the game.

94
00:06:25,250 --> 00:06:29,990
We need to run through all of the calculations and it's going to be the same thing.

95
00:06:30,050 --> 00:06:33,140
So it's going to allow the dealer to play through if they're under 21.

96
00:06:33,350 --> 00:06:35,720
But if they're over 21, the players already busted.

97
00:06:36,470 --> 00:06:38,330
So it just cover placeholder for that.

98
00:06:38,360 --> 00:06:41,240
And we're gonna count for that in the upcoming lessons.

99
00:06:42,110 --> 00:06:50,930
And if they're not over 21, we're going to take the game status and update the text content to, say,

100
00:06:50,960 --> 00:06:53,600
the dealer in play.

101
00:06:54,850 --> 00:06:59,660
And you can change the rules for what the dealer minimum is.

102
00:07:00,510 --> 00:07:05,840
And we're going to also have a function here for the dealer play and passing in the dealer object.

103
00:07:06,380 --> 00:07:09,770
So, again, setting up the place holders for those functions.

104
00:07:10,500 --> 00:07:12,730
Every I create these in the later lesson.

105
00:07:12,740 --> 00:07:14,720
So those are just placeholders for those.

106
00:07:14,840 --> 00:07:15,930
So see what happens.

107
00:07:16,380 --> 00:07:20,390
And whenever you're creating a game, you just gotta to think of what the next action that you want

108
00:07:20,540 --> 00:07:21,950
the user to be able to play.

109
00:07:22,340 --> 00:07:24,890
And then make tweaks and adjustments to the code accordingly.

110
00:07:25,310 --> 00:07:30,260
So at this point, we still provide the player an option to hit and stand.

111
00:07:30,650 --> 00:07:36,140
So coming up next, we're going to account for the actions on these buttons in order to produce the

112
00:07:36,140 --> 00:07:36,590
gameplay.

113
00:07:36,770 --> 00:07:40,160
So it's come up in the upcoming lessons and then we're gonna go.

114
00:07:40,220 --> 00:07:45,050
Back to some of what we've been doing here, where we've been setting up this place, Holder functions

115
00:07:45,320 --> 00:07:47,030
and we're going to build those out as well.

116
00:07:47,810 --> 00:07:49,360
So that is all still yet to come.
