1
00:00:00,680 --> 00:00:04,310
This could be our opportunity to create a brain for the dealer.

2
00:00:04,640 --> 00:00:10,130
And there really isn't a whole lot because the parameters for blackjack are fairly straightforward.

3
00:00:10,370 --> 00:00:14,460
So the dealer will take cards until he reaches 17.

4
00:00:14,780 --> 00:00:19,750
And if he's goes over or if he busts over 21.

5
00:00:20,030 --> 00:00:24,540
So if he hits 22 and up, then that means that the player wins the game.

6
00:00:25,160 --> 00:00:28,060
And that's all the logic that we have to apply.

7
00:00:28,070 --> 00:00:30,240
So relatively easy and straightforward.

8
00:00:30,590 --> 00:00:35,900
So within the dealer play, let's get the score of the dealer.

9
00:00:36,170 --> 00:00:43,520
So just as we did with the player hand, we're going to get the dealer hand value and return it back

10
00:00:43,610 --> 00:00:48,230
as a value that we can see within the console.

11
00:00:49,520 --> 00:00:55,700
And then using this value, we're going to update from the game status.

12
00:00:56,150 --> 00:01:05,840
Let's update the text content and we'll write the dealer score and then whatever value is being returned

13
00:01:05,840 --> 00:01:09,020
back within the dealer value.

14
00:01:10,250 --> 00:01:11,990
We're going to add that into the text content.

15
00:01:12,500 --> 00:01:14,600
And then there are just a few rules.

16
00:01:14,690 --> 00:01:19,570
So we have to check to see if it's greater than or equal to 17.

17
00:01:19,940 --> 00:01:24,200
And that means that we're going to stop taking cards for the dealer and we're going to have to check

18
00:01:24,200 --> 00:01:26,900
to see who has a higher hand value.

19
00:01:27,920 --> 00:01:36,440
And we'll take the game dealer score because this is final and update the text content to be whatever

20
00:01:36,440 --> 00:01:37,460
is contained for dealer.

21
00:01:37,830 --> 00:01:39,600
So we'll provide the dealer score.

22
00:01:40,580 --> 00:01:50,000
And if they're not over 17, then we're going to keep taking cards until the dealer is over 17 or over

23
00:01:50,000 --> 00:01:51,380
21 and they're busting.

24
00:01:51,650 --> 00:01:53,390
So we're gonna continue to take cards.

25
00:01:54,110 --> 00:01:59,360
And that means that we just need to run the take card and then game dealer hand.

26
00:01:59,690 --> 00:02:03,080
So the cards where they're going, which hand they're going into.

27
00:02:03,560 --> 00:02:08,660
And then also game dealer cards object.

28
00:02:08,930 --> 00:02:11,330
So this is where they're going to be placed on the screen.

29
00:02:11,810 --> 00:02:13,280
And we don't want them to be hidden.

30
00:02:13,400 --> 00:02:15,140
So we just want that as false.

31
00:02:15,740 --> 00:02:23,930
And also updating the score every time with dealer and then running back to dealer play.

32
00:02:24,260 --> 00:02:29,180
So we're gonna continue to play until that condition can no longer play through.

33
00:02:29,630 --> 00:02:30,650
So let's see what happens.

34
00:02:31,580 --> 00:02:34,400
And this is all going to be initiated when we do stand.

35
00:02:34,880 --> 00:02:36,380
So Dealer ended up with 21.

36
00:02:36,500 --> 00:02:38,750
So they stop and stand again.

37
00:02:39,050 --> 00:02:41,660
So, see, the dealer ended up taking a whole bunch of cards.

38
00:02:41,990 --> 00:02:44,690
And then when they hit 17, they stopped taking cards.

39
00:02:45,080 --> 00:02:50,540
And because we've got so many aces in the deck, it's going to be really easy to get up to these values.

40
00:02:50,930 --> 00:02:58,250
So at this point, we can actually conclude that the aces are working and we can get rid of that second

41
00:02:58,250 --> 00:03:03,380
rank so we can play with the actual card values and we can always adjust it as needed as we're doing

42
00:03:03,380 --> 00:03:03,920
our testing.

43
00:03:04,310 --> 00:03:05,170
So it's to a stand.

44
00:03:05,990 --> 00:03:07,710
And the dealer has 17.

45
00:03:08,090 --> 00:03:12,380
So also we need to show that dealer card.

46
00:03:12,650 --> 00:03:13,790
So what the hidden card.

47
00:03:14,160 --> 00:03:20,660
So need to make sure that we can select that and show it and we can do that by within the game object.

48
00:03:21,170 --> 00:03:27,140
We had card back as we created the style that cover over the card.

49
00:03:27,620 --> 00:03:33,020
And then selecting style and display it will set its display value to none.

50
00:03:33,260 --> 00:03:36,080
So that should effectively show that dealer card.

51
00:03:36,470 --> 00:03:37,190
So let's try it.

52
00:03:37,580 --> 00:03:41,240
And when since we hit stand in the dealers card, it is revealed.

53
00:03:41,390 --> 00:03:44,810
So coming up next, we've got to calculate who the winner of the game is.

54
00:03:45,050 --> 00:03:47,960
And then, of course, there's some additional tweaks that we're going to be making.

55
00:03:48,470 --> 00:03:51,350
So go ahead and add in the logic of the dealer.

56
00:03:51,380 --> 00:03:57,280
Play into your game and be ready to move on to the next lesson or recalculate the winner of the game.
