1 00:00:01,770 --> 00:00:08,730 OK, ladies and gentlemen, let's continue working on our dice game, so what we actually now need to 2 00:00:08,730 --> 00:00:11,820 do, we already we are rolling the dice, right? 3 00:00:11,840 --> 00:00:21,440 So we now need to calculate the result and store it in one of our areas that we put it here. 4 00:00:21,450 --> 00:00:22,270 Player scores. 5 00:00:22,580 --> 00:00:28,710 Now, I'm just going to show you the where is it in this query selector. 6 00:00:29,010 --> 00:00:30,540 If I Konza log 7 00:00:32,850 --> 00:00:37,200 the live player, it will always be zero. 8 00:00:37,210 --> 00:00:37,520 Right. 9 00:00:39,060 --> 00:00:40,140 Just going to inspect it. 10 00:00:42,080 --> 00:00:49,070 And it will always be zero, so we need to change that one in order to play around who, who who will 11 00:00:49,070 --> 00:00:51,810 be active and who will be not active player. 12 00:00:51,830 --> 00:00:52,170 Right. 13 00:00:52,610 --> 00:00:54,410 So we have a couple of things here to do. 14 00:00:54,440 --> 00:00:57,560 This is one of the most important lectures and let's do it. 15 00:00:57,800 --> 00:01:05,180 OK, now I'm just going to leave that one here and I'm going to say document, not get Elliman by these. 16 00:01:05,360 --> 00:01:15,110 And I just want to target live there and I'm going to say, plus active. 17 00:01:17,780 --> 00:01:28,160 Live player right now, active player, so I'm going to say style display to block. 18 00:01:29,250 --> 00:01:38,060 OK, so what we are doing here, obviously, that I want, when it's zero, this player to go green 19 00:01:38,060 --> 00:01:42,690 and this player just like that in when it's one, I want to change it. 20 00:01:42,950 --> 00:01:45,920 This player to be green, this one to not be green. 21 00:01:45,930 --> 00:01:52,920 So if I change it right now, it will be green and it will stay green because we never we never change 22 00:01:53,060 --> 00:01:54,460 this guy here. 23 00:01:54,710 --> 00:01:56,090 So how we can achieve this. 24 00:01:57,200 --> 00:01:59,940 Remember, we can do this with evil statement. 25 00:02:00,350 --> 00:02:04,070 We can check if the live player is zero. 26 00:02:04,100 --> 00:02:05,480 And why is this happening? 27 00:02:05,860 --> 00:02:06,710 I didn't explain. 28 00:02:06,720 --> 00:02:12,590 So we get the element by the live Samus here like this. 29 00:02:12,770 --> 00:02:20,900 But instead of manually putting these dash zero dash one, I just use that live player variable that 30 00:02:20,900 --> 00:02:23,060 we set to zero at the beginning. 31 00:02:23,060 --> 00:02:25,850 This is our initial value now. 32 00:02:26,720 --> 00:02:35,150 OK, so what we can do is actually we can check in for the life player like this with the ternary operator, 33 00:02:35,150 --> 00:02:35,800 remember. 34 00:02:36,200 --> 00:02:37,870 So I'm going to say live player. 35 00:02:38,490 --> 00:02:40,180 It is equal to zero. 36 00:02:40,490 --> 00:02:42,140 I got to change a live player. 37 00:02:42,320 --> 00:02:45,830 If that is true, I'm going to change the life player to one else. 38 00:02:45,830 --> 00:02:48,460 I'm going to change the life player back to zero. 39 00:02:49,190 --> 00:02:51,110 So if it's one, it's going to be zero. 40 00:02:51,320 --> 00:02:54,250 If it's zero, it's going to become one. 41 00:02:54,680 --> 00:03:01,910 Now we can cause a lot of the live player 42 00:03:04,580 --> 00:03:06,340 and you will see their keep changing. 43 00:03:08,000 --> 00:03:08,960 So I'm going to refresh. 44 00:03:09,200 --> 00:03:12,530 So it's going to be zero, then one, then it's going to be one zero. 45 00:03:12,530 --> 00:03:16,250 Then it's going to zero in one Y because we're printing this one here. 46 00:03:16,340 --> 00:03:16,810 Right. 47 00:03:17,330 --> 00:03:27,050 So we are actually now able to change it, but we're not able is do we need to set the other one to 48 00:03:27,050 --> 00:03:28,220 display none. 49 00:03:28,220 --> 00:03:30,290 And that is what we need to do now. 50 00:03:30,590 --> 00:03:32,060 So I'm just going to grab this one. 51 00:03:34,250 --> 00:03:38,180 I'm going to put it here because now the live players change. 52 00:03:38,180 --> 00:03:40,970 If it was zero, it will be a one now. 53 00:03:41,300 --> 00:03:52,120 And I want that to become display none right here. 54 00:03:52,140 --> 00:03:53,810 Yeah, that's pretty much it. 55 00:03:54,110 --> 00:03:55,210 What I want to change. 56 00:03:55,580 --> 00:03:56,200 Let's check. 57 00:03:56,260 --> 00:03:57,050 Let's check it out. 58 00:03:58,250 --> 00:03:58,820 Nope, nope. 59 00:04:00,660 --> 00:04:06,410 One Danisco go to this one, that is to go to this one again, then it's go to this one again. 60 00:04:06,420 --> 00:04:10,530 So now I hope you understand I'm just going to close this deal. 61 00:04:10,830 --> 00:04:15,870 So what I did first is always zero because we initial when we start is going to be zero. 62 00:04:16,110 --> 00:04:17,600 And that is our goal. 63 00:04:17,610 --> 00:04:21,690 I want to start here with this guy with Blair, one, I don't want to start backwards. 64 00:04:22,410 --> 00:04:31,830 And now we set that the display block and it magically appears this guy here, right then I change it. 65 00:04:31,830 --> 00:04:36,540 I'm checking if one player is zero, then, yeah, change it to one. 66 00:04:36,810 --> 00:04:42,810 Otherwise, if next cycle when this life player will be one, then it will not be true. 67 00:04:43,140 --> 00:04:43,550 Right. 68 00:04:43,710 --> 00:04:46,020 And we go here, it will set it to zero. 69 00:04:46,230 --> 00:04:47,280 So we just swapping. 70 00:04:48,210 --> 00:04:48,620 Right. 71 00:04:48,900 --> 00:04:49,680 So you can do this. 72 00:04:49,800 --> 00:04:52,750 I challenge you to do it with if else statement. 73 00:04:53,580 --> 00:04:57,390 So again, it is this one, it's working now. 74 00:04:57,390 --> 00:05:01,800 We need to find a way how we can store these variables. 75 00:05:02,040 --> 00:05:07,940 I store these dice numbers for the player and put the other player right. 76 00:05:07,970 --> 00:05:11,680 So whenever all at once, I just everything that's here to be for this player. 77 00:05:11,680 --> 00:05:11,880 Right. 78 00:05:11,910 --> 00:05:12,900 This is the green one. 79 00:05:13,630 --> 00:05:14,730 The next one is green. 80 00:05:14,730 --> 00:05:16,310 I want this tree to go there. 81 00:05:16,770 --> 00:05:17,760 So how we can do this? 82 00:05:18,090 --> 00:05:24,660 Well, we will use that actual help say we actual 83 00:05:27,300 --> 00:05:28,740 player scores area. 84 00:05:28,770 --> 00:05:29,120 Right. 85 00:05:29,130 --> 00:05:32,700 I'm just going to copy it so I don't want to make a mistake. 86 00:05:32,700 --> 00:05:37,830 So what we will do now after this one is block. 87 00:05:37,830 --> 00:05:44,850 I'm going to check it here, play score and I'm going to say of the live player and I'm going to say 88 00:05:44,850 --> 00:05:49,470 plus equal to dice, right. 89 00:05:49,710 --> 00:05:56,340 Because dice contain that random number and actual dice is going to be this one. 90 00:05:56,850 --> 00:05:57,420 Right. 91 00:05:57,900 --> 00:06:08,400 So I can console like console lock the player scores for live player. 92 00:06:09,810 --> 00:06:18,330 Remember when I say live player it will start with zero zero player scores of zero and we will expand 93 00:06:18,810 --> 00:06:21,000 or we will add the value of dice. 94 00:06:21,240 --> 00:06:27,840 Then we're going to log in and next time it will be player scores one and we're going to pen that dice 95 00:06:27,900 --> 00:06:28,470 for him. 96 00:06:29,610 --> 00:06:31,710 I hope I'm clear about that one. 97 00:06:32,020 --> 00:06:33,660 OK, let's check. 98 00:06:33,660 --> 00:06:36,420 Check if this is working on a refresh. 99 00:06:36,870 --> 00:06:38,490 So here it is five. 100 00:06:38,490 --> 00:06:40,140 I do have five for this player. 101 00:06:40,500 --> 00:06:43,380 So when they roll it on the other player, I'm going to have two. 102 00:06:44,310 --> 00:06:44,790 Right. 103 00:06:45,150 --> 00:06:46,380 I'm going to roll it again. 104 00:06:46,620 --> 00:06:49,680 I have five plus four. 105 00:06:50,010 --> 00:06:50,770 It's nine. 106 00:06:51,000 --> 00:06:57,480 When I'm going to roll it again, it will be three plus two, OK, because this is not visibly very 107 00:06:57,480 --> 00:06:57,900 good. 108 00:06:58,290 --> 00:07:02,040 So when I'm going to do I'm just going to change it something for you guys. 109 00:07:02,940 --> 00:07:03,830 So I'm just going to change. 110 00:07:03,830 --> 00:07:12,500 This comes a lot and I'm going to say score for player and I'm going to upend the player as well. 111 00:07:12,720 --> 00:07:19,350 Live life later and I'm going to say plus. 112 00:07:20,520 --> 00:07:21,660 Plus again. 113 00:07:24,490 --> 00:07:35,290 OK, and that should do its job, this life, Blair is not correct, OK, now score for player zero 114 00:07:35,290 --> 00:07:38,200 is actually this guy here, street score four. 115 00:07:38,200 --> 00:07:40,720 Player two is actually four. 116 00:07:40,720 --> 00:07:42,340 Player one is actually two. 117 00:07:42,340 --> 00:07:42,610 Right. 118 00:07:42,820 --> 00:07:47,940 This is a play that's a little bit awkward because I name to start with zero zero, right? 119 00:07:48,460 --> 00:07:50,530 Yeah, you can change it here. 120 00:07:50,530 --> 00:07:52,480 Player zero in player one if you want. 121 00:07:53,470 --> 00:07:58,870 So player zero will be big, but it's not logical to be zero right now. 122 00:07:58,870 --> 00:08:04,180 Five before player zero was three and now plus five, it is equal eight. 123 00:08:04,300 --> 00:08:08,290 So this is actually, ladies and gentlemen, working as it shoot. 124 00:08:08,920 --> 00:08:14,830 Now, the interesting part is we see we are twenty three and we still can rule. 125 00:08:15,890 --> 00:08:19,480 Oh, this is not good because we are over our limit. 126 00:08:19,480 --> 00:08:22,300 So how we can set a limit here. 127 00:08:22,330 --> 00:08:35,050 OK, before this I just going to cut it from here and I'm going to see if players scores of zero is 128 00:08:35,050 --> 00:08:38,190 less than twenty so you can make it to 100. 129 00:08:38,470 --> 00:08:45,010 There's a man I just don't want to make it long and player scores of one is less than twenty. 130 00:08:45,010 --> 00:08:53,350 So I just want to check it both so means that must both of them player zero in player one to have scored 131 00:08:53,370 --> 00:08:54,940 less than. 132 00:08:54,940 --> 00:09:01,750 And I'm going to basted that back here to have less than twenty else pounds a lot. 133 00:09:03,700 --> 00:09:07,000 We have a winner, winner, winner. 134 00:09:07,000 --> 00:09:08,440 Chicken dinner, ladies and gentlemen. 135 00:09:09,640 --> 00:09:11,680 So I'm going to put it one five. 136 00:09:12,100 --> 00:09:14,170 OK, I'm going to roll it. 137 00:09:14,500 --> 00:09:15,160 So twenty. 138 00:09:15,280 --> 00:09:16,240 The player won. 139 00:09:16,270 --> 00:09:23,050 This player actually reached twenty and when I click next time I don't want to go here and calculate. 140 00:09:23,770 --> 00:09:24,220 Yeah. 141 00:09:24,700 --> 00:09:27,220 And plus this is working actually here. 142 00:09:27,220 --> 00:09:28,090 We need to stop it. 143 00:09:28,390 --> 00:09:29,560 But the winner is there. 144 00:09:29,560 --> 00:09:30,350 We have a winner. 145 00:09:30,350 --> 00:09:30,600 Right. 146 00:09:30,610 --> 00:09:32,410 It's not going to do anything else. 147 00:09:32,410 --> 00:09:35,320 It's not going to go inside this loop here. 148 00:09:35,320 --> 00:09:37,330 It's not going to add to the result. 149 00:09:37,600 --> 00:09:39,100 It's not going to do anything. 150 00:09:39,160 --> 00:09:41,320 No, we have to have time. 151 00:09:41,320 --> 00:09:46,960 So what we can do is actually make this little bit more spicy. 152 00:09:48,880 --> 00:09:51,400 OK, so we need to upend the result that we have. 153 00:09:51,400 --> 00:09:52,750 We already have the result, right. 154 00:09:52,960 --> 00:09:59,550 So we need to append those result to the final score, that particular player. 155 00:10:00,100 --> 00:10:10,300 So after this, after we are setting to none and again, to display block, what I'm going to say here 156 00:10:10,720 --> 00:10:18,520 is that we need to pretty much document that query selector. 157 00:10:18,820 --> 00:10:22,780 And what we need to select is I'm going to show you right now. 158 00:10:22,780 --> 00:10:26,440 So we need to find final score. 159 00:10:26,980 --> 00:10:27,570 Here it is. 160 00:10:27,880 --> 00:10:31,930 So for the both of the players, I do have final score and that was fifty. 161 00:10:32,710 --> 00:10:35,350 And I'm not going to do it manually. 162 00:10:35,350 --> 00:10:35,700 Right. 163 00:10:35,950 --> 00:10:43,270 So I'm going to say, OK, because we using the query selector and that was the idea over there. 164 00:10:43,300 --> 00:10:43,660 Right. 165 00:10:44,440 --> 00:10:50,560 So we're going to use the ID like that with the hash final score dash. 166 00:10:50,560 --> 00:10:56,620 We're going to leave a dash, but we're going to continue with the live player because the last player 167 00:10:56,740 --> 00:11:04,230 we know, it's changing and we're going to say tax content that will be equal to the player scorer Aare 168 00:11:04,540 --> 00:11:07,750 that is holding the live player value. 169 00:11:09,160 --> 00:11:10,900 Let's see if this is working or not. 170 00:11:11,560 --> 00:11:13,410 Do we have this console lock still? 171 00:11:13,420 --> 00:11:13,840 Yes. 172 00:11:14,860 --> 00:11:24,010 So I'm just going to say one, if it's not working, OK, we need to fix it. 173 00:11:25,900 --> 00:11:27,430 So we need to fix it. 174 00:11:27,430 --> 00:11:36,010 And obviously this should not be here, should be somewhere here because after that we're changing the 175 00:11:36,010 --> 00:11:38,140 player and we're doing a lot of things. 176 00:11:38,830 --> 00:11:42,940 Now, I hope when I see for the player one, I will see updated version. 177 00:11:42,940 --> 00:11:45,370 Right, two in two here. 178 00:11:45,530 --> 00:11:49,390 So when I switch it to the other one, it's going to be for how cool is this? 179 00:11:50,110 --> 00:11:55,810 The player is working seven five five. 180 00:11:56,920 --> 00:11:57,280 Yeah. 181 00:11:57,280 --> 00:12:00,790 OK, four plus one, four plus one is five. 182 00:12:00,790 --> 00:12:00,970 Yeah. 183 00:12:00,970 --> 00:12:06,040 I was thinking something is wrong but the calculation is working pretty much so I reached twenty the 184 00:12:06,040 --> 00:12:08,650 player number to reach twenty and we have a winner. 185 00:12:08,650 --> 00:12:08,890 Right. 186 00:12:08,890 --> 00:12:12,850 It's not going to go anywhere, it's not going to add it actually it's going to roll but it's not going 187 00:12:12,850 --> 00:12:14,800 to edit the values down. 188 00:12:14,950 --> 00:12:20,170 So that is pretty much it now we can safely comment this one. 189 00:12:21,100 --> 00:12:23,020 So what we have done this. 190 00:12:23,340 --> 00:12:25,320 In this lecture, we just 191 00:12:27,780 --> 00:12:34,590 change the life layer for find, which the life layer is, and we set the display block after that with 192 00:12:34,590 --> 00:12:39,900 ternary operator, we switch to the other player and the other one turned to none. 193 00:12:40,200 --> 00:12:42,720 Right after that. 194 00:12:42,720 --> 00:12:51,120 What we did is that we add to each of the players, this is the area for each of the players, for the 195 00:12:51,120 --> 00:12:58,980 zero and for the one we add that dice number from before and the beginning with. 196 00:12:59,040 --> 00:13:06,570 If else, we are checking if they do not have more than 20, because if they do, obviously some of 197 00:13:06,570 --> 00:13:07,740 them is a winner. 198 00:13:08,190 --> 00:13:14,030 So I hope you understand if you don't, because I've done it step by step, issued probably by now. 199 00:13:14,040 --> 00:13:16,920 Understand how this is the process is working, right. 200 00:13:17,220 --> 00:13:24,130 So again, six to six plus four, is that right? 201 00:13:24,150 --> 00:13:24,840 Here it is. 202 00:13:25,770 --> 00:13:27,570 And that is pretty much done. 203 00:13:27,690 --> 00:13:32,870 So this guy has twenty three and actually it's not going to allow me to go to the next guy. 204 00:13:32,880 --> 00:13:37,680 We're going to say, OK, we have a dinner winner, sorry, not dinner because it's, it's probably 205 00:13:37,680 --> 00:13:38,610 dinner time for me. 206 00:13:38,760 --> 00:13:40,230 So thank you very much. 207 00:13:40,470 --> 00:13:43,440 And I will see you in the next lecture.