1
00:00:00,090 --> 00:00:03,480
There's going to be a fun lesson where we're gonna get into the game place, we're going to do some

2
00:00:03,480 --> 00:00:10,170
calculations and conditions to check and ensure that there's progress within the game and allow the

3
00:00:10,170 --> 00:00:11,820
player to move on to the next steps.

4
00:00:12,030 --> 00:00:15,270
So once they deal, we want to enable the hit and stand.

5
00:00:15,420 --> 00:00:22,230
But this is also dependent on what the card values are and what actions the player needs to be able

6
00:00:22,230 --> 00:00:22,710
to take.

7
00:00:23,040 --> 00:00:24,810
So we're going to add in a new function.

8
00:00:24,930 --> 00:00:25,530
So under.

9
00:00:25,560 --> 00:00:26,040
Deal.

10
00:00:26,780 --> 00:00:28,860
And we can just call this update count.

11
00:00:29,070 --> 00:00:30,840
We're not passing any parameters in there.

12
00:00:31,650 --> 00:00:37,680
And this is where we're going to do the check and update of where the game progress is.

13
00:00:38,280 --> 00:00:39,510
So update count.

14
00:00:40,410 --> 00:00:46,470
And this function will run every time it's dealt and also serve as a way to kind of move things along.

15
00:00:47,010 --> 00:00:52,300
So we want to actually pick up the score value that's available.

16
00:00:53,580 --> 00:00:55,560
Within the player and the dealer.

17
00:00:55,830 --> 00:01:00,320
So it's going to be an important part that we want to be able to track the score.

18
00:01:00,990 --> 00:01:04,680
So let's create another function that will calculate the score.

19
00:01:04,980 --> 00:01:06,960
So just call this function score.

20
00:01:07,350 --> 00:01:08,420
We'll call it score.

21
00:01:09,600 --> 00:01:20,970
And coming into update count, we want to be able to pick up the players, score and pass the game player

22
00:01:21,030 --> 00:01:23,280
hand into the score.

23
00:01:23,310 --> 00:01:26,670
So it's going to do a calculation of that array object.

24
00:01:27,150 --> 00:01:34,350
And then also we want a value for dealer and using the same function that we're passing in the dealer

25
00:01:34,830 --> 00:01:38,040
hand array values into there.

26
00:01:38,760 --> 00:01:43,110
And then within score, we're going to pick up those values and then make use of them.

27
00:01:43,410 --> 00:01:46,620
So essentially, this can be a hand that's being passed in.

28
00:01:46,970 --> 00:01:52,770
We need to calculate out the value that's contained within the hand and then return back a number of

29
00:01:52,770 --> 00:01:54,600
value for the user.

30
00:01:55,140 --> 00:02:00,550
And I'll output the values of player and dealer.

31
00:02:00,930 --> 00:02:05,010
So have to do some calculations here and return back the response.

32
00:02:05,640 --> 00:02:11,550
So let's set up some default values and set them to zero.

33
00:02:12,600 --> 00:02:17,400
And if it's an ace, because we're gonna have to account for possibility of multiple aces.

34
00:02:17,680 --> 00:02:22,920
So depending on what the score and what the value is and loop through the hand array.

35
00:02:23,220 --> 00:02:27,240
So for now, what we can do is console log out the value of hand.

36
00:02:27,720 --> 00:02:29,640
So this is whatever is being passed in.

37
00:02:30,080 --> 00:02:32,910
And then right now, we'll just return back.

38
00:02:34,230 --> 00:02:35,010
A value of one.

39
00:02:35,640 --> 00:02:36,700
So it's price deal.

40
00:02:36,810 --> 00:02:38,780
And see what happens, a clear deal.

41
00:02:39,510 --> 00:02:42,390
And we'll see that both of those hands get passed in.

42
00:02:42,720 --> 00:02:44,190
And as you can see, it is an array.

43
00:02:44,640 --> 00:02:49,860
So this particular one has Spade's rank value and as well.

44
00:02:49,890 --> 00:02:51,570
King value.

45
00:02:52,620 --> 00:02:55,240
And then we also get the other hand that gets Pastan.

46
00:02:55,740 --> 00:03:00,240
So we see that this is going to be the dealer's hand.

47
00:03:00,510 --> 00:03:04,530
And that's the player's hand surpassing in player's hand first.

48
00:03:04,830 --> 00:03:06,470
And then the dealer's hand second.

49
00:03:06,900 --> 00:03:10,590
And also, it compares to what we see on the screen as well.

50
00:03:10,710 --> 00:03:15,960
So taking the hand array the loop through each one of the items that are contained within the hand.

51
00:03:16,370 --> 00:03:18,290
And we can output it as card.

52
00:03:19,530 --> 00:03:23,970
And then just console log out the value of whatever is contained within card.

53
00:03:24,690 --> 00:03:25,620
So we have a deal.

54
00:03:26,520 --> 00:03:28,830
We get each one of the cards as output there.

55
00:03:29,070 --> 00:03:30,390
And that's going to loop through.

56
00:03:30,780 --> 00:03:33,210
And this way we can update the total.

57
00:03:33,780 --> 00:03:40,770
So we've got a running total of whatever's available within the particular hand that's been passed him.

58
00:03:41,490 --> 00:03:42,960
And make sure that it is a number.

59
00:03:43,020 --> 00:03:43,950
So we're going to use them.

60
00:03:44,060 --> 00:03:47,550
No method to force it to be a numeric value.

61
00:03:47,970 --> 00:03:50,370
And then we can also return back the total of one.

62
00:03:51,250 --> 00:03:53,640
And also forcing total to be a number.

63
00:03:54,210 --> 00:03:56,870
So we're turning back the counted values.

64
00:03:57,390 --> 00:04:00,850
So the dealer has eleven.

65
00:04:01,200 --> 00:04:03,090
And the player has 20.

66
00:04:03,180 --> 00:04:04,670
So we're turning those back in.

67
00:04:05,450 --> 00:04:07,470
There's a little bit more we're gonna have to do with score.

68
00:04:07,590 --> 00:04:09,770
But for now, let's go back to the update count.

69
00:04:10,260 --> 00:04:11,830
And we can update the count.

70
00:04:11,850 --> 00:04:14,430
Values that are contained for each one of those.

71
00:04:14,820 --> 00:04:19,020
So we can apply various conditions depending on what's being returned back.

72
00:04:19,980 --> 00:04:22,800
So first, let's add in the count for the player.

73
00:04:23,310 --> 00:04:26,610
So under the game player score.

74
00:04:28,230 --> 00:04:29,670
Set the tax content.

75
00:04:29,880 --> 00:04:31,740
So that's where we've got that Dasch there.

76
00:04:32,070 --> 00:04:35,730
We're going to update it to whatever the value that's being returned back from.

77
00:04:36,570 --> 00:04:38,730
And so we got a value of 13 there.

78
00:04:39,630 --> 00:04:44,700
It looks like we have to apply a little bit of styling as well to going into our stylesheet.

79
00:04:45,120 --> 00:04:52,710
I'm going to update a value for score, do display block and make the font size bigger.

80
00:04:53,040 --> 00:04:58,350
And then also adjust the margin of 15 picks at the top and then zero at the bottom.

81
00:04:59,100 --> 00:05:00,930
And that moved our default card.

82
00:05:01,470 --> 00:05:03,810
So we need to make an adjustment for that as well.

83
00:05:04,200 --> 00:05:11,100
So it looks but right now we're taking up a default spot there for score and we're outputting the players

84
00:05:11,160 --> 00:05:11,610
score.

85
00:05:11,970 --> 00:05:14,600
So we have to also go back and we have to enable the button.

86
00:05:15,010 --> 00:05:18,150
And this is going to allow the player to have an additional action.

87
00:05:18,480 --> 00:05:28,880
So if the player is under 21, then using that turn on and selecting the game button hit, we're going

88
00:05:28,880 --> 00:05:29,730
to enable that.

89
00:05:30,390 --> 00:05:39,450
And then we also want to turn on the game button stand so that the user has an option for moving the

90
00:05:39,450 --> 00:05:39,980
game along.

91
00:05:41,250 --> 00:05:43,860
And that's only if it's under 21.

92
00:05:44,910 --> 00:05:55,980
And then also under game status, let's update the text content and say stand or take another card.

93
00:05:56,100 --> 00:06:01,020
So it provides some instructions for the user on what their next course of action can be.

94
00:06:01,440 --> 00:06:05,350
And there's more that we're going to have to do, more conditions we're gonna have to add in and we'll

95
00:06:05,370 --> 00:06:06,840
do that in the upcoming lesson.

96
00:06:07,230 --> 00:06:09,810
So now we've got the option to hit and stand.

97
00:06:10,020 --> 00:06:14,340
So we've enabled those buttons and we can continue with the gameplay for the player.

98
00:06:14,970 --> 00:06:20,730
So coming up, the second part of building the update count, as well as updating the score in order

99
00:06:20,730 --> 00:06:22,530
to handle the game functionality.
