1
00:00:01,530 --> 00:00:06,360
Let's do a quick walk through of the current functionality of the game so the player comes in, select

2
00:00:06,360 --> 00:00:12,540
the number of players they hit, start and immediately the cards are dealt and we turn over the first

3
00:00:12,540 --> 00:00:19,530
card and each one of the players hands and we'll also compare them to find the winner that's available

4
00:00:19,530 --> 00:00:19,790
there.

5
00:00:20,160 --> 00:00:24,920
So we want to have the ability to launch multiple attacks and to launch another attack.

6
00:00:25,110 --> 00:00:31,200
So let's set that up within this round where we are listening for the button click.

7
00:00:31,200 --> 00:00:39,330
And if the value of the button is attack, that means that we want to run another make cards.

8
00:00:39,720 --> 00:00:41,880
So try that out and we hit start.

9
00:00:41,880 --> 00:00:44,910
And if we do that again, we see that we remake the card.

10
00:00:44,930 --> 00:00:49,080
So there's a few things that we do need to do in order to accommodate this.

11
00:00:49,330 --> 00:00:55,470
And one of them is we need to clear out the current existing card when we come in to make the next round.

12
00:00:55,800 --> 00:00:59,570
That's one of the things that we need to handle when we are making the cards.

13
00:01:00,630 --> 00:01:06,720
So going into the make cards function, we need to clear out the existing content from each one of the

14
00:01:06,720 --> 00:01:11,600
players as we iterate through so we can do that here as we start the loop.

15
00:01:11,820 --> 00:01:19,920
So taking the players object, indicating the index value and setting the inner HTML and we can just

16
00:01:19,920 --> 00:01:20,660
clear that out.

17
00:01:20,670 --> 00:01:22,500
So just have a blank our HTML.

18
00:01:22,680 --> 00:01:29,850
So start attack and we can see that now we're able to play the game and as we continuously press attack,

19
00:01:30,030 --> 00:01:36,960
then we get the next round and all of the winners then get the cards added to their hand and we can

20
00:01:36,960 --> 00:01:39,730
continuously play through and have multiple attacks.

21
00:01:40,140 --> 00:01:45,030
So what if we also want to launch multiple attacks and eventually some of these players are going to

22
00:01:45,030 --> 00:01:48,570
run out of cards and then we can set them as lost?

23
00:01:48,900 --> 00:01:50,480
So we need to handle that as well.

24
00:01:50,490 --> 00:01:56,020
And this is one of the game win conditions that we're going to do near the end of the lessons.

25
00:01:57,420 --> 00:02:03,810
So in this case, we want to get the value that's contained within the input and use that value in order

26
00:02:03,810 --> 00:02:10,830
to calculate how many runs we have so we can call this temp runs and using the document.

27
00:02:12,660 --> 00:02:20,670
Query selector lets select the value of the input, and this is going to tell us how many rounds we

28
00:02:20,670 --> 00:02:21,480
want to play.

29
00:02:21,900 --> 00:02:24,270
Let's also update our RSS.

30
00:02:25,810 --> 00:02:30,910
Inner turmoil, so this is where we were outputting who won and all of the round information.

31
00:02:30,910 --> 00:02:32,270
So let's sit in down there below.

32
00:02:32,410 --> 00:02:34,450
So we want to clear that out each time as well.

33
00:02:34,690 --> 00:02:41,410
And let's set our round to equal to zero, I guess, set a few different variables here.

34
00:02:41,620 --> 00:02:47,830
So one of the variables that we need as a global variable is we need to set up a variable for round

35
00:02:47,860 --> 00:02:48,730
so we can update.

36
00:02:48,730 --> 00:02:54,070
And we know how many rounds have been played as well as another variable four in play.

37
00:02:54,880 --> 00:02:59,080
And we can use this variable to control the gameplay so we can stop it.

38
00:02:59,080 --> 00:03:02,550
And started by checking the inplay value.

39
00:03:03,250 --> 00:03:08,390
So going into our card listing where we're making the cart.

40
00:03:09,220 --> 00:03:13,990
So first let's check to see if inplay is true.

41
00:03:14,890 --> 00:03:18,280
And if it is, then that's that's where we're going to launch the make cards.

42
00:03:18,640 --> 00:03:25,330
And we're also going to loop it multiple times so we can use just a regular for loop setting X to zero

43
00:03:25,510 --> 00:03:29,920
and looping while temp runs is less than.

44
00:03:31,470 --> 00:03:38,760
While X is less than temperance, and then what we'll do is will decrease the value of temperance as

45
00:03:38,760 --> 00:03:43,260
we iterate through certain dentist content so it's easier to read.

46
00:03:44,240 --> 00:03:50,090
So we're checking to see if the value of inplay is true, so this gives us the ability to control it

47
00:03:50,390 --> 00:03:52,440
and also in the message area.

48
00:03:52,460 --> 00:03:54,140
Let's update the inner turmoil.

49
00:03:54,410 --> 00:03:59,270
So we've got new content there and we know how many rounds that we've actually gone through.

50
00:03:59,600 --> 00:04:02,470
So do the round and X plus one.

51
00:04:03,320 --> 00:04:07,960
And as we loop through here, this round value will continuously increase as well.

52
00:04:09,030 --> 00:04:12,130
But what we'll do is we'll just make the cards each time, so let's try that.

53
00:04:12,510 --> 00:04:18,360
So now we start the game and we've got the one attack and we can update this to two attacks.

54
00:04:18,690 --> 00:04:23,520
And also we want to make sure that we're setting that in play to be true when we start the game.

55
00:04:23,640 --> 00:04:25,800
So in start game function.

56
00:04:26,920 --> 00:04:34,120
I want to set this value to be true so that we have our game functionality and our game control boolean

57
00:04:34,120 --> 00:04:34,450
value.

58
00:04:35,200 --> 00:04:36,210
Try that one more time.

59
00:04:36,790 --> 00:04:37,750
So we attack.

60
00:04:37,750 --> 00:04:38,950
We attack again.

61
00:04:38,950 --> 00:04:40,030
We attack again.

62
00:04:40,180 --> 00:04:44,590
Let's try three rounds and you can see that we've got the three rounds played.

63
00:04:44,590 --> 00:04:44,830
So.

64
00:04:44,830 --> 00:04:46,510
Player three one three cards.

65
00:04:46,510 --> 00:04:47,980
Player two, one, three cards.

66
00:04:48,130 --> 00:04:49,720
Player three, one, three cards.

67
00:04:49,840 --> 00:04:52,570
So we see that the count of the cards is changing.

68
00:04:53,020 --> 00:04:58,660
Let's try doing five rounds and we can see at the end of the five rounds, player two has twenty, player

69
00:04:58,660 --> 00:05:01,180
three has twenty and player one has twelve.

70
00:05:01,360 --> 00:05:06,520
And also noticed as well that we've got player two winning even though this is a tie.

71
00:05:06,640 --> 00:05:10,960
So that's one thing that we do need to handle and we need to handle that in one of the upcoming lessons.

72
00:05:12,280 --> 00:05:17,680
In order to handle what were happening here and how we can break the tie, so what we have to do is

73
00:05:17,890 --> 00:05:25,480
keep flipping cards until either one runs out of cards or one of them gets a higher card than the other.

74
00:05:26,080 --> 00:05:28,560
So that's the next thing that we do in the next lesson.

75
00:05:28,810 --> 00:05:34,660
So go ahead and add in the boolean controller for running the game, also listening for the talk button

76
00:05:34,660 --> 00:05:39,580
to be clicked and then giving us an option to run multiple rounds of the game.
