1
00:00:01,480 --> 00:00:07,920
So as we set up the lock wager, we also want to make sure that the wager is locked when we're dealing

2
00:00:07,920 --> 00:00:08,520
the cards.

3
00:00:08,880 --> 00:00:15,390
So when we initiate the deal of the cards, let's run that and toggle it to be true.

4
00:00:15,750 --> 00:00:19,620
So no matter what, as long as we're dealing out cards.

5
00:00:19,890 --> 00:00:27,060
If the player presses the deal button that we're going to not enable any more adjustments to whatever

6
00:00:27,060 --> 00:00:27,660
the bet is.

7
00:00:27,690 --> 00:00:31,230
So whenever the game is in play, we're not updating any of the bets.

8
00:00:31,680 --> 00:00:32,730
So we hit a deal.

9
00:00:33,510 --> 00:00:35,970
We don't want to be able to enable the bet amount.

10
00:00:36,450 --> 00:00:44,640
So this should actually be disabled and we should color the bet button to be great out as well as the

11
00:00:44,640 --> 00:00:45,720
disabled area.

12
00:00:45,960 --> 00:00:53,100
And if you look to inspect the code, you can see that this input style has been disabled.

13
00:00:53,140 --> 00:00:55,050
So so a condition if Torg.

14
00:00:55,680 --> 00:01:00,420
And that means that if Torg is true, then we're going to set the game.

15
00:01:00,780 --> 00:01:06,770
That button style and background color to be a great out color.

16
00:01:06,990 --> 00:01:11,820
And we'll also gray out the input bet style also.

17
00:01:11,970 --> 00:01:17,790
And if it's not, then we're going to reset them back to being black and white.

18
00:01:17,940 --> 00:01:19,050
So see how that works.

19
00:01:19,140 --> 00:01:19,950
So we had a deal.

20
00:01:20,130 --> 00:01:21,090
This is all great.

21
00:01:21,090 --> 00:01:22,140
Out deal.

22
00:01:22,280 --> 00:01:22,810
Stand.

23
00:01:23,250 --> 00:01:24,110
Dealer busted.

24
00:01:24,510 --> 00:01:29,250
And then we need to also enable the ability for the wager.

25
00:01:29,340 --> 00:01:35,610
So this is something else that we need to run as the game is enabled once again.

26
00:01:35,700 --> 00:01:42,810
So whenever we complete the calculations of the set winner, we'll set the lock wager to be false.

27
00:01:42,900 --> 00:01:48,450
And of course, we also have to update the amount of money that's being set and available.

28
00:01:48,600 --> 00:01:50,740
So refresh deal stand.

29
00:01:51,390 --> 00:01:53,810
And now the bet amount is once again enabled.

30
00:01:54,180 --> 00:01:55,020
It's disabled.

31
00:01:55,170 --> 00:01:55,660
Deal.

32
00:01:56,100 --> 00:02:01,140
And you do have to sometimes play through it a few times just to make sure you catch everything within

33
00:02:01,140 --> 00:02:03,930
the set winner where we're determining the winner.

34
00:02:04,170 --> 00:02:07,170
We also need to update the cash for the winner.

35
00:02:07,560 --> 00:02:11,340
So if the player wins, then they're going to their game.

36
00:02:11,790 --> 00:02:15,870
Cash is going to equal whatever their game cash value is.

37
00:02:15,930 --> 00:02:19,020
Plus the game that and this is for a draw.

38
00:02:19,200 --> 00:02:22,050
So it's essentially returning back the money to the player.

39
00:02:22,680 --> 00:02:30,630
If the player wins, then they get twice whatever the game that is multiplied by to return back to their

40
00:02:30,630 --> 00:02:30,980
cash.

41
00:02:31,380 --> 00:02:33,210
So they'll get their original debt back.

42
00:02:33,450 --> 00:02:35,640
Plus they get what their winnings were.

43
00:02:35,750 --> 00:02:41,790
And we also need to have a condition to check for the game cash if it's less than one.

44
00:02:42,240 --> 00:02:48,390
So that means that the player essentially is broke and we need to set the game cash to equal to zero

45
00:02:48,960 --> 00:02:49,760
and game.

46
00:02:49,860 --> 00:02:52,050
Bet is also equal to zero.

47
00:02:52,140 --> 00:02:55,080
So let's try that and we're going to just bet the full amount.

48
00:02:55,470 --> 00:02:55,980
Deal.

49
00:02:56,230 --> 00:02:58,280
Stand Dealer, score 20.

50
00:02:58,350 --> 00:02:59,340
So the dealer wins.

51
00:02:59,520 --> 00:03:01,140
So player has zero cash.

52
00:03:01,890 --> 00:03:05,430
And the players betting zero because you're not able to bet anymore.

53
00:03:05,790 --> 00:03:10,680
So even whatever they deal, whatever money they've got here, it doesn't matter because it's still

54
00:03:10,680 --> 00:03:13,590
working off of what their their cash value is.

55
00:03:13,980 --> 00:03:15,890
And going into the score function.

56
00:03:16,260 --> 00:03:24,120
So if any one of the totals that we're checking, the value, if it's over 21, that means that the

57
00:03:24,150 --> 00:03:25,350
game is over.

58
00:03:25,470 --> 00:03:30,450
And we're simply going to return back whatever the value of the total is.

59
00:03:30,540 --> 00:03:37,080
So this is just another failsafe just to make sure that in case we do detect that the game is over,

60
00:03:37,380 --> 00:03:43,110
that we take the appropriate action to serve other function, that we can run whatever we want to shut

61
00:03:43,110 --> 00:03:44,430
the game, play off.

62
00:03:44,930 --> 00:03:49,020
We just go to game over and let's create that function and game.

63
00:03:49,210 --> 00:03:58,470
And and what game will and will do is it will turn off the ability to hit the buttons and turn off the

64
00:03:58,530 --> 00:04:04,170
game button stand and also will log into the console that it's ended.

65
00:04:04,650 --> 00:04:06,160
So that means that somebody's got 21.

66
00:04:06,600 --> 00:04:09,270
And then also we're we're updating the count.

67
00:04:09,750 --> 00:04:14,820
Want to check to see if the dealer got a blackjack right off the bat.

68
00:04:15,180 --> 00:04:19,860
And if they did, then we know that we need to find the winner right away.

69
00:04:20,760 --> 00:04:23,460
So there's no use continuing the gameplay.

70
00:04:23,760 --> 00:04:29,850
If the dealer has a blackjack and this is commonly done within blackjack games.

71
00:04:29,880 --> 00:04:37,590
So if the dealer is equal to 21 and game dealer hand length.

72
00:04:37,770 --> 00:04:42,690
Remember, this is the array that contains all of the cards is equal to two.

73
00:04:42,960 --> 00:04:45,720
That means that the dealer is holding a blackjack.

74
00:04:46,560 --> 00:04:56,310
So here we can check the game status and output the text content to the user that the dealer got blackjack.

75
00:04:56,770 --> 00:04:58,470
And we actually want to end the game.

76
00:04:58,830 --> 00:05:00,780
And we want to game end.

77
00:05:01,010 --> 00:05:06,020
Function, we're just run that, and that's going to turn off the button, hit the button stand, and

78
00:05:06,020 --> 00:05:11,360
then we also need to make sure that we run the find winner function because that means the game is over,

79
00:05:11,430 --> 00:05:11,810
essentially.

80
00:05:12,080 --> 00:05:14,270
Let's go back up to our code.

81
00:05:14,570 --> 00:05:19,810
And we know that we can update and we can trigger some blackjacks.

82
00:05:20,390 --> 00:05:22,610
So let's just make sure that everything is working.

83
00:05:23,200 --> 00:05:30,980
And you also might want to update some of your code so it works differently just to make sure that sometimes

84
00:05:30,980 --> 00:05:34,850
there is a case that you do need to update and tweak it and test it.

85
00:05:35,150 --> 00:05:35,810
So it's easy.

86
00:05:36,110 --> 00:05:42,520
You can just simply adjust the different card values that are going to be presented to the player as

87
00:05:42,560 --> 00:05:43,700
a great way to test it.

88
00:05:44,030 --> 00:05:46,800
So see that we've got two different blackjacks there.

89
00:05:47,130 --> 00:05:49,220
Draw no winners, 21.

90
00:05:50,030 --> 00:05:52,870
And in this case, we got dealer score 20.

91
00:05:53,030 --> 00:05:54,540
You win 21 Beal.

92
00:05:55,340 --> 00:05:58,490
So whenever it's hitting 21, it's just showing all of the cards.

93
00:05:58,550 --> 00:06:03,950
If either one of them are hitting 21, you've got to take or stand or take another card.

94
00:06:04,580 --> 00:06:08,540
So this probably means that the dealer is 20 and we have 20 as well.

95
00:06:09,140 --> 00:06:10,250
So just stand.

96
00:06:10,490 --> 00:06:12,650
And that's correct that the dealer did have 20.

97
00:06:12,830 --> 00:06:15,320
So all the gameplay is working as expected.

98
00:06:15,410 --> 00:06:16,850
So a draw once again.

99
00:06:16,940 --> 00:06:18,290
And sometimes that is worthwhile.

100
00:06:18,320 --> 00:06:22,130
You got to play through a bunch of times just to make sure everything is working properly.

101
00:06:22,250 --> 00:06:27,620
So coming up next, we'll do a few final tweaks and adjustments just to make sure that everything is

102
00:06:27,830 --> 00:06:29,180
working as expected.

103
00:06:29,540 --> 00:06:31,630
And then we'll do a quick run-Through of all of the code.

104
00:06:32,030 --> 00:06:32,750
That's still to come.
