1
00:00:00,060 --> 00:00:01,650
Hey, are you ready to make a deal?

2
00:00:01,680 --> 00:00:07,950
So that's where we need to go next, is we need to be able to hook up and make these buttons actually

3
00:00:07,950 --> 00:00:08,310
work.

4
00:00:08,310 --> 00:00:14,490
And going into all of our game logic, we can set that up in the beginning where we're in it function

5
00:00:14,490 --> 00:00:16,620
is sitting and add in the event.

6
00:00:16,960 --> 00:00:20,360
So we've got some other event listeners, so we've got that close event listener.

7
00:00:20,370 --> 00:00:25,380
So let's how about we add the event listeners for the deal and no deal elements.

8
00:00:25,380 --> 00:00:27,800
So going back into our HTML.

9
00:00:27,810 --> 00:00:32,520
So now it's been a while since we looked at this and we know that we've got accept and decline.

10
00:00:32,670 --> 00:00:35,670
So we've got a deal, we've got a no deal class.

11
00:00:35,850 --> 00:00:43,770
So let's use those and add them into our query selector to make a selection of those elements and we

12
00:00:43,770 --> 00:00:44,490
can make a deal.

13
00:00:44,500 --> 00:00:46,470
So we're going to send them actually to the same place.

14
00:00:46,800 --> 00:00:52,650
And using the document query selector, we don't need to list these elements because we're not going

15
00:00:52,650 --> 00:00:54,380
to be making any real changes to them.

16
00:00:54,690 --> 00:01:00,900
So, deal, all we need to do is make sure that we're setting up the ADD event listener, so add event

17
00:01:00,900 --> 00:01:06,960
listener and adding the event listener of a click and send them over to a function that we're going

18
00:01:06,960 --> 00:01:08,200
to call make a deal.

19
00:01:08,220 --> 00:01:08,670
So that's it.

20
00:01:08,960 --> 00:01:10,220
So let's do one more.

21
00:01:10,260 --> 00:01:14,400
And also for no deal, we're going to do the same thing.

22
00:01:14,520 --> 00:01:19,410
We're going to send them both over and I'm going to also update when we get the first deal.

23
00:01:19,420 --> 00:01:22,830
So that will be AR 15 and we'll have one at 14.

24
00:01:22,830 --> 00:01:26,400
So we're going to have the deals right away being offered to us.

25
00:01:26,700 --> 00:01:32,160
And that means that we also need to make the function in order to handle the making of the deal because

26
00:01:32,160 --> 00:01:37,440
we're sending them both over to the function, making the deal, and we're going to pick up what the

27
00:01:37,440 --> 00:01:41,940
content of the element says in order to distinguish between the two.

28
00:01:42,480 --> 00:01:48,210
So I know we're sending it over to the same function, but we can pick up content that's contained on

29
00:01:48,210 --> 00:01:53,580
the button and that's how we can differentiate between the two so we can actually know what was hit.

30
00:01:54,150 --> 00:01:57,120
So within the console, taking the easy target.

31
00:01:57,120 --> 00:02:03,480
So the event target and text content that's contained on there, that target and that will tell us either

32
00:02:03,480 --> 00:02:06,960
that they've accepted it or they've declined the deal.

33
00:02:07,080 --> 00:02:14,820
Also, what we want to do is take the page model and page model two, because this is a new action and

34
00:02:14,820 --> 00:02:15,810
we want to hide that.

35
00:02:15,810 --> 00:02:17,310
So do a display.

36
00:02:17,340 --> 00:02:21,180
We're going to hide the model and then we do some type of action.

37
00:02:21,180 --> 00:02:25,590
So we're going to check to see if this content says accept.

38
00:02:25,980 --> 00:02:29,580
And if it does, then we have an excerpt of the game.

39
00:02:29,580 --> 00:02:34,800
And actually, at this point, the game is pretty much over because they've accepted their case.

40
00:02:34,980 --> 00:02:41,720
And we can also have another option to see if it's so.

41
00:02:41,730 --> 00:02:46,560
If they don't accept it, we're just going to move on to the gameplay because then they can just select

42
00:02:46,560 --> 00:02:46,890
more.

43
00:02:47,220 --> 00:02:54,750
And the other thing that we need to look for is that else if and if this was the game last offer.

44
00:02:54,750 --> 00:03:01,060
So if game last if our game last offer is true, that actually means that it's game over.

45
00:03:01,470 --> 00:03:06,510
So either one of these conditions, we need to run a function called end game.

46
00:03:06,510 --> 00:03:09,300
So let's add that function in as well.

47
00:03:09,720 --> 00:03:13,770
And it's going to put it on top and we'll have a placeholder for that because we're going to take care

48
00:03:13,770 --> 00:03:15,510
of that in another lesson.

49
00:03:15,810 --> 00:03:16,860
So end game.

50
00:03:17,250 --> 00:03:20,310
And this is just what we do to kind of reset the game.

51
00:03:20,670 --> 00:03:23,980
And this at this point, the game is over.

52
00:03:24,000 --> 00:03:30,510
So either way, if they're on their last offer, it's game over or if they accept it's game over.

53
00:03:30,540 --> 00:03:36,570
So we want to do is we want to run the end of the game and show what's remaining.

54
00:03:36,570 --> 00:03:38,340
So that's one of the things that we want to do.

55
00:03:38,460 --> 00:03:42,300
And we can run the show the remaining within the end game.

56
00:03:42,630 --> 00:03:43,770
So we can do that in there.

57
00:03:43,920 --> 00:03:46,970
And also we're going to update the game in play.

58
00:03:47,130 --> 00:03:50,190
So both of those we can put an end to both of those.

59
00:03:50,190 --> 00:03:56,130
And the only thing that is different is that I want to have a different pop up message contained in

60
00:03:56,130 --> 00:03:56,370
there.

61
00:03:56,550 --> 00:03:58,350
So I have a different pop up message.

62
00:03:58,500 --> 00:04:06,480
So, again, using the pop up message pop up model that we had and in this case, let's do a div and

63
00:04:06,480 --> 00:04:07,850
you earned.

64
00:04:07,860 --> 00:04:09,940
So we tell that player how much they've earned.

65
00:04:09,960 --> 00:04:16,830
So within the game offer, this is because they accepted the offer.

66
00:04:16,980 --> 00:04:20,460
So whatever was offered was made or the last offer was made.

67
00:04:20,670 --> 00:04:22,680
That's actually what the player's going to end up with.

68
00:04:22,950 --> 00:04:29,010
So we're going to have that value so it can be tickets or dollars or however you're set up and whatever

69
00:04:29,010 --> 00:04:29,880
you're playing for.

70
00:04:30,120 --> 00:04:36,030
So this is going to have a pop up that's going to have whatever tickets within this game and then within

71
00:04:36,030 --> 00:04:39,780
the end game is going to be false because it's no longer true.

72
00:04:40,020 --> 00:04:41,330
So that's going to stop the game.

73
00:04:41,340 --> 00:04:42,930
It's going to halt the game from playing.

74
00:04:43,050 --> 00:04:46,500
And then we also want to show the show the remaining ones.

75
00:04:46,770 --> 00:04:53,190
So we want to basically open up the additional cases that are visible so we can do that as well.

76
00:04:53,790 --> 00:04:57,030
And also the other one, if that's the last offer.

77
00:04:57,030 --> 00:04:59,640
So we might as well do that because we're setting up.

78
00:04:59,850 --> 00:05:06,960
All of the content there, so we've got the pop up was contained within your case, so you declined

79
00:05:06,960 --> 00:05:12,060
the offer, which means that you took what whoever was remaining in the case.

80
00:05:12,360 --> 00:05:19,380
So your case has and this is the case that you selected tickets and you can also customize that message.

81
00:05:19,500 --> 00:05:21,150
And either way, the game is over.

82
00:05:21,180 --> 00:05:25,490
So either one of these the game is over and we need to still show the remaining.

83
00:05:25,500 --> 00:05:28,100
So we'll take care of that function in the next lesson.

84
00:05:28,320 --> 00:05:31,300
So let's try this game and see how it works.

85
00:05:31,650 --> 00:05:36,390
So, again, you always need to play through it quite a few times, usually in order to get a good feel

86
00:05:36,390 --> 00:05:36,730
for it.

87
00:05:37,560 --> 00:05:41,730
So select a case, so select number one now select zero cases.

88
00:05:41,740 --> 00:05:46,450
So right away it's going to give me an offer because I did set it to at 15.

89
00:05:46,470 --> 00:05:48,750
So we start with 60 and I select one.

90
00:05:48,760 --> 00:05:52,700
So let's hope we get an offer right away because we selected the one case already.

91
00:05:53,250 --> 00:05:58,530
So if I accept it, you earn thirty four tickets in the scheme and we should have the start button popping

92
00:05:58,530 --> 00:06:02,100
up again in order to start everything all over again.

93
00:06:02,520 --> 00:06:07,380
So page to display block so that we'll have the start button pop up again.

94
00:06:07,650 --> 00:06:12,660
So if I accept the offer you and thirty four start select a case.

95
00:06:13,110 --> 00:06:17,400
So select zero cases and so far so good.

96
00:06:17,400 --> 00:06:18,240
Looks pretty good.

97
00:06:18,750 --> 00:06:23,580
Select a case and this time I'm going to decline the offer, select ten more cases.

98
00:06:23,580 --> 00:06:28,110
So remember this is calculating this and I'm just trying to click through really quickly and I got the

99
00:06:28,110 --> 00:06:28,830
big one there.

100
00:06:28,860 --> 00:06:30,600
So right now the offer is eight.

101
00:06:30,600 --> 00:06:36,090
So it's based on what the values are remaining or I can select two more cases, so I'm going to just

102
00:06:36,090 --> 00:06:36,990
decline that.

103
00:06:36,990 --> 00:06:42,360
And offer is four, offer no force five or select one more case.

104
00:06:42,600 --> 00:06:45,120
So I decline it and I got great job.

105
00:06:45,130 --> 00:06:46,650
So this is the last offer.

106
00:06:46,650 --> 00:06:49,740
So this is the testing of the last offer.

107
00:06:49,980 --> 00:06:53,820
So either we accept it and we're going to get four or we declined it.

108
00:06:53,820 --> 00:06:58,110
And we find out your case has won tickets and we start again.

109
00:06:58,110 --> 00:06:58,920
We can start again.

110
00:06:59,280 --> 00:07:01,380
So all of the game functionality is there.

111
00:07:01,530 --> 00:07:06,390
We need to make a few minor tweaks and adjustments to make the gameplay a little bit more interesting.

112
00:07:06,870 --> 00:07:09,690
But for the most part, all of our gameplay is there.

113
00:07:09,870 --> 00:07:13,560
We need to just also make sure that the end of game is working properly.

114
00:07:13,860 --> 00:07:15,970
So a few minor tweaks to Justman.

115
00:07:15,970 --> 00:07:17,040
It's still to come.

116
00:07:17,250 --> 00:07:22,290
Go ahead and conclude the game and play through it a few times, make sure that everything is working

117
00:07:22,290 --> 00:07:26,800
as expected and you to be ready to move on to the next lesson where we're going to make some tweaks

118
00:07:26,800 --> 00:07:28,170
to adjust to the gameplay.
