1
00:00:00,450 --> 00:00:03,600
We've almost come to the conclusion of the gameplay part.

2
00:00:03,690 --> 00:00:06,630
And, of course, we need to make some tweaks or adjustments afterwards.

3
00:00:07,130 --> 00:00:09,900
And in this case, we need to find the winner of the game.

4
00:00:10,320 --> 00:00:14,130
And we already have a placeholder there that's just called find winner.

5
00:00:14,520 --> 00:00:16,050
So let's make some updates to it.

6
00:00:16,300 --> 00:00:17,570
Select Player.

7
00:00:17,940 --> 00:00:22,710
And we're going to get the calculations once again because we need to always know the score.

8
00:00:22,980 --> 00:00:27,780
So we're using that score function to get the score from the player hand.

9
00:00:28,110 --> 00:00:30,960
So once again, within the game, player hand object.

10
00:00:31,530 --> 00:00:39,450
And also, let's get the dealer score as this way we can have a numeric score and we can do a comparison

11
00:00:39,540 --> 00:00:40,230
of the score.

12
00:00:40,740 --> 00:00:47,910
So the dealer of player and dealer will apply the logic for that.

13
00:00:48,390 --> 00:00:53,280
So going through and let's take a hit, hit and stand.

14
00:00:53,770 --> 00:00:58,860
And we do need to add in the find winner check in the dealer play function.

15
00:00:59,430 --> 00:01:01,050
So when the dealer plays through.

16
00:01:01,440 --> 00:01:04,890
If the dealer is greater than 17, that means the game's over.

17
00:01:04,920 --> 00:01:06,450
And we need to determine the winner.

18
00:01:06,810 --> 00:01:10,990
And then also down here where we're checking to see if the players over 20 won.

19
00:01:11,250 --> 00:01:14,370
That means that we need to determine and find the winner as well.

20
00:01:14,610 --> 00:01:16,010
And let's play through the game.

21
00:01:16,080 --> 00:01:19,300
You're going to find that often times as you're building out a game.

22
00:01:19,380 --> 00:01:23,440
You need to play through it many times just to make sure you are encountering the bugs or tweaks.

23
00:01:23,440 --> 00:01:25,230
And it is working as expected.

24
00:01:25,530 --> 00:01:26,520
So let's hit stand.

25
00:01:26,820 --> 00:01:30,470
And we see that we run through and the dealer scores twenty.

26
00:01:30,930 --> 00:01:32,540
The player's score is 18.

27
00:01:32,940 --> 00:01:35,580
So we need to be able to determine the winner.

28
00:01:35,820 --> 00:01:38,910
And we see the values of 18 and 23 in the console.

29
00:01:39,180 --> 00:01:41,370
So it means that find winner is running.

30
00:01:41,610 --> 00:01:49,410
So let's add in the additional logic into find a winner and checking to see if a player is greater than

31
00:01:49,440 --> 00:01:50,080
21.

32
00:01:50,650 --> 00:01:58,320
If the player is greater than 21, that means that the game status, tax content is going to be that

33
00:01:58,650 --> 00:02:05,640
you busted or the player busted with and then will output the score so that the player can see what

34
00:02:05,640 --> 00:02:07,920
score it was that they busted with.

35
00:02:08,760 --> 00:02:13,110
And also, we'll do a check to see if dealer is greater than 21.

36
00:02:13,620 --> 00:02:19,710
And if the dealer is greater than 21, then we're going to output that the dealer busted and we can

37
00:02:19,710 --> 00:02:19,980
rate.

38
00:02:20,010 --> 00:02:24,060
Dealer busted with whatever the score of dealer is.

39
00:02:24,840 --> 00:02:29,340
And this is where we're going to actually do the check the winner conditions.

40
00:02:29,400 --> 00:02:35,340
So we check the value of player and see if it's equal to the value of dealer.

41
00:02:35,640 --> 00:02:37,200
So that means that there was a draw.

42
00:02:37,320 --> 00:02:43,830
So there was no winners and update the text content so that the user knows what happens.

43
00:02:44,100 --> 00:02:46,140
And then we can also output the value.

44
00:02:46,350 --> 00:02:49,610
So it can be either one because they're actually going to be both the same.

45
00:02:49,620 --> 00:02:50,640
So they're both equal.

46
00:02:51,240 --> 00:02:54,340
So that means that this was a draw and then else.

47
00:02:54,420 --> 00:02:57,510
If so, this is another alternative that could happen.

48
00:02:57,930 --> 00:03:05,310
So checking to see if the value of player or we're going to wrap this in conditions here in the rounded

49
00:03:05,310 --> 00:03:05,850
brackets.

50
00:03:06,300 --> 00:03:09,190
So player is less than twenty two.

51
00:03:10,530 --> 00:03:15,990
And we check to see if player is greater than dealer.

52
00:03:16,000 --> 00:03:20,580
So we need to check to make sure it is less than twenty two because otherwise the player is busted.

53
00:03:20,880 --> 00:03:23,760
And up here we're just out putting a message if it's busted.

54
00:03:23,950 --> 00:03:25,200
So not taking the action.

55
00:03:25,230 --> 00:03:30,030
So here we've got the actual conditions checking to see if player is less than 22.

56
00:03:30,480 --> 00:03:35,040
And if player is greater than dealer that means that the player is the winner.

57
00:03:35,760 --> 00:03:40,000
Another condition is if dealer is greater than 21.

58
00:03:40,350 --> 00:03:42,700
That also means that the player is the winner.

59
00:03:42,730 --> 00:03:48,510
So that means that the dealer busted and that would mean that this statement was true as well.

60
00:03:49,140 --> 00:03:58,290
So let's update the game status text so that we output the results to the to the player and we're going

61
00:03:58,290 --> 00:04:05,790
to concatenate the text so we'll rate you win and then whatever the value of the player total is.

62
00:04:06,270 --> 00:04:08,120
And then lastly else.

63
00:04:08,370 --> 00:04:14,580
So if that's not true, if the player's not the winner, if it's not a draw, then that means that the

64
00:04:14,670 --> 00:04:15,600
dealer is the winner.

65
00:04:17,190 --> 00:04:23,330
So let's update the message accordingly, that the dealer is the winner and we'll rate.

66
00:04:23,370 --> 00:04:27,030
Dealer wins and whatever the value of the dealer.

67
00:04:27,750 --> 00:04:32,070
So that should mean that we check and we know who the winner is.

68
00:04:33,110 --> 00:04:34,220
So just do a stand.

69
00:04:34,760 --> 00:04:36,540
Dealer busted with 26.

70
00:04:36,670 --> 00:04:37,910
You win with 13.

71
00:04:38,250 --> 00:04:40,490
So that's right that the dealer went all the way.

72
00:04:40,490 --> 00:04:41,960
So he pulled seven.

73
00:04:41,960 --> 00:04:43,120
Plus five, 12.

74
00:04:43,340 --> 00:04:44,710
Plus four, 16.

75
00:04:44,780 --> 00:04:46,010
Plus a queen.

76
00:04:46,070 --> 00:04:47,150
So that's 26.

77
00:04:47,240 --> 00:04:49,090
So the dealer busted with 26.

78
00:04:49,460 --> 00:04:53,850
And that means that you were able to win with the 13.

79
00:04:54,910 --> 00:05:02,000
And so now it should actually Reeth set back to the default where we can play the next round of the

80
00:05:02,000 --> 00:05:02,270
game.

81
00:05:02,480 --> 00:05:11,630
So whatever the result was, we can run the turn on function and enable the game button deal once again,

82
00:05:12,550 --> 00:05:17,150
and that should trigger the ability to play the game throughout.

83
00:05:17,420 --> 00:05:23,150
So even though that we've concluded this round, we're going to allow the player to play another round.

84
00:05:23,750 --> 00:05:24,730
So just stand.

85
00:05:25,220 --> 00:05:28,880
And in this case, the dealer wins and we can deal again.

86
00:05:29,060 --> 00:05:31,730
So we deal another round of cards.

87
00:05:32,090 --> 00:05:34,970
And this time the dealer wins with 17.

88
00:05:36,260 --> 00:05:37,760
And try that one more time.

89
00:05:37,970 --> 00:05:39,200
So, again, the dealer wins.

90
00:05:39,500 --> 00:05:44,870
So we still need to set to update the score and then obviously add in the cash, which is going to make

91
00:05:44,870 --> 00:05:48,530
the betting of the game and the gameplay a little bit more interesting.

92
00:05:48,800 --> 00:05:51,470
So that's still all to come in the upcoming lessons.
