1
00:00:00,240 --> 00:00:01,480
This lesson we're going to be taking.

2
00:00:01,500 --> 00:00:07,740
Cards from the deck that's already been randomized, so taking them off the top of the deck array and

3
00:00:07,740 --> 00:00:10,980
then outputting them visually for the player to be able to see.

4
00:00:11,550 --> 00:00:17,670
So we're gonna create a function that called that take card, and it's going to require some parameters

5
00:00:17,670 --> 00:00:23,340
to be passed in so that we know what card we're taking and where we're placing the card.

6
00:00:23,640 --> 00:00:25,380
So it's visually being able to see.

7
00:00:25,680 --> 00:00:35,940
So it's going into the game dealer hand and then into the game dealer cards element.

8
00:00:36,300 --> 00:00:40,410
And that's the same one that we constructed when we initiated the gameplay.

9
00:00:40,650 --> 00:00:46,120
So it's going to be able to show the content in the dealer card area and I'll show you how this is going

10
00:00:46,120 --> 00:00:46,380
to work.

11
00:00:46,710 --> 00:00:49,420
And also, I want to have one last parameter.

12
00:00:49,680 --> 00:00:52,590
And this is going to be whether it's visible or not.

13
00:00:53,400 --> 00:00:55,380
So right now, it just be false.

14
00:00:55,440 --> 00:01:01,260
So we'll make it visible because when we play blackjack, the dealers, one of the cards is going to

15
00:01:01,260 --> 00:01:01,800
be hidden.

16
00:01:02,040 --> 00:01:06,390
So we need to have that option as we're constructing the card in the visible area.

17
00:01:06,990 --> 00:01:10,020
So the first parameter that we pass in was the hand.

18
00:01:10,530 --> 00:01:13,080
The second one is the element where it's going to go.

19
00:01:13,470 --> 00:01:16,650
And then the last one is going to be whether it's hidden or not.

20
00:01:16,680 --> 00:01:18,170
So this could be a boolean value.

21
00:01:19,270 --> 00:01:21,790
And creating a temporary elements.

22
00:01:22,420 --> 00:01:25,450
So we're taking the first card off the deck.

23
00:01:25,900 --> 00:01:27,570
So doing shift.

24
00:01:28,300 --> 00:01:33,370
And this is built in into arrays and then console log.

25
00:01:34,470 --> 00:01:39,930
Whatever the value of Tempus, and don't forget to add in the take card function, so the function name,

26
00:01:40,020 --> 00:01:45,420
so it's automatically taking a card and slugging it down to the console when we press the deal.

27
00:01:45,570 --> 00:01:46,380
So let's see what happens.

28
00:01:46,980 --> 00:01:51,030
So we've got the diamonds, the five of diamonds being passed in.

29
00:01:51,630 --> 00:01:57,360
And when we refresh, you can see that the first card in the deck is the queen of spades.

30
00:01:57,750 --> 00:01:59,010
So I press deal.

31
00:01:59,550 --> 00:02:03,450
And if I go down here, I just took the queen of spades off the deck.

32
00:02:03,810 --> 00:02:09,600
So, I mean, sir, what I want to do is I want to add it in to whatever the hand is in the hand.

33
00:02:09,720 --> 00:02:13,020
Again, remember, it's going to be the player's hand or the dealer's hand.

34
00:02:13,320 --> 00:02:17,580
So this is the game, whatever that array object is gonna be associated with.

35
00:02:17,940 --> 00:02:20,760
And we're passing that in to the take card.

36
00:02:20,970 --> 00:02:29,520
So taking hand and using push, we're gonna push this new card into whatever hand it is.

37
00:02:29,760 --> 00:02:31,620
So in this case, it's gonna go into the dealers.

38
00:02:31,950 --> 00:02:36,750
And then we can console log out the contents of game.

39
00:02:36,990 --> 00:02:38,970
The game object to see what's happening.

40
00:02:39,360 --> 00:02:41,910
So it's clear that and deal.

41
00:02:42,480 --> 00:02:45,720
And so within the dealer hand.

42
00:02:46,290 --> 00:02:48,760
So if we go all the way down here, we see that.

43
00:02:48,780 --> 00:02:51,240
Now we've got that first item is sitting in there.

44
00:02:51,570 --> 00:02:56,100
And that's how we're going to be able to tell what contents are in each one of the hands.

45
00:02:56,130 --> 00:02:57,900
So the dealers hand the player's hand.

46
00:02:58,230 --> 00:03:00,720
And that's where we're going to be able to compare them.

47
00:03:00,960 --> 00:03:05,730
When we check to see if we have a winner and we check to see what their score is.

48
00:03:06,150 --> 00:03:11,220
So we need a way to show the card contents into the element.

49
00:03:12,280 --> 00:03:14,570
And we need to know what card we're showing.

50
00:03:14,930 --> 00:03:20,030
So let's create another function and pass in that value from temp.

51
00:03:20,570 --> 00:03:21,620
So that will be the card.

52
00:03:22,250 --> 00:03:26,710
And then we're also going to specify which element we want to show the card within.

53
00:03:27,920 --> 00:03:31,250
And then let's create a function to handle the show card.

54
00:03:31,910 --> 00:03:36,200
And we'll take care of actually visually showing the card in the upcoming lesson.

55
00:03:36,530 --> 00:03:43,580
So go ahead and add in the ability to take a card and automatically take the card and have that output

56
00:03:43,610 --> 00:03:44,660
into the console.

57
00:03:45,050 --> 00:03:46,610
Be ready to move on to the next step.

58
00:03:47,000 --> 00:03:52,700
And we're also going to add in a bunch of take cards because the dealer is going to get two cards.

59
00:03:52,730 --> 00:03:55,580
The player is going to get two cards right off the top.

60
00:03:55,970 --> 00:03:57,860
And that one is going to be visible.

61
00:03:57,870 --> 00:04:02,810
And we'll take will handle all of the tweaking of the application later on.
