1
00:00:00,780 --> 00:00:01,750
Hey, welcome back.

2
00:00:01,830 --> 00:00:05,880
This lesson we're going to check to see who the winner is of the dice roll.

3
00:00:06,300 --> 00:00:13,140
So creating another method within our constructor object using the method and we're going to create

4
00:00:13,260 --> 00:00:14,840
a brandnew function.

5
00:00:15,000 --> 00:00:18,020
And in this function, we're going to take in a few parameters.

6
00:00:18,030 --> 00:00:20,250
We need role one and rule two.

7
00:00:20,370 --> 00:00:24,110
So we have something, some values that we can use to make the comparison.

8
00:00:24,570 --> 00:00:29,550
So checking to see if role one is greater than role two.

9
00:00:29,760 --> 00:00:36,390
We know that the winner of this is going to be being returned back player wins, assuming that the first

10
00:00:36,390 --> 00:00:38,280
one is the player that's being Pastan.

11
00:00:38,910 --> 00:00:46,220
And then also we'll do another check to see if role two is greater than roll one.

12
00:00:46,230 --> 00:00:49,350
So there can only really be three possibilities return.

13
00:00:49,590 --> 00:00:51,870
And this means that the computer wins.

14
00:00:51,870 --> 00:00:55,050
And again, we're hoping that rule one is for the player.

15
00:00:55,050 --> 00:00:56,520
Role two is for the computer.

16
00:00:56,640 --> 00:01:00,210
And if that changes, then, of course, you do need to change and adjust your messaging.

17
00:01:00,510 --> 00:01:06,090
And if we don't have one winning over the other, then this is just simply a tie.

18
00:01:06,630 --> 00:01:07,740
So we're turned back a tie.

19
00:01:07,890 --> 00:01:11,700
So now we've got a way to check and we're not going to see anything quite different yet.

20
00:01:11,940 --> 00:01:14,480
And that means that we need to check to see who the winner is.

21
00:01:14,490 --> 00:01:21,420
So let's use that game object and the brand new checker method that we just created and taking in the

22
00:01:21,420 --> 00:01:25,020
player role and then also the computer roll.

23
00:01:25,290 --> 00:01:31,530
And remember, it does have to be in that order and I'll log out whatever is being returned from winner.

24
00:01:31,530 --> 00:01:32,700
So let's see what happens.

25
00:01:32,710 --> 00:01:38,070
So role here, player wins role again, computer wins and we should also output those values.

26
00:01:38,370 --> 00:01:45,030
So let's take dice and we're going to update that message so that, again, for those of for those of

27
00:01:45,030 --> 00:01:50,900
us that are sharing the game or don't like to look into the console to see what the values are, let's

28
00:01:51,030 --> 00:01:58,380
output that and say player and we'll get the value of the player role versus and then this is the computer

29
00:01:58,380 --> 00:01:58,850
role.

30
00:01:58,860 --> 00:02:04,520
And that means that whatever the value of winner is, we'll just have put that message.

31
00:02:04,830 --> 00:02:06,360
It's a very simple message here.

32
00:02:06,690 --> 00:02:09,930
And we see player six versus one.

33
00:02:09,930 --> 00:02:11,400
So the computer got a one.

34
00:02:11,880 --> 00:02:14,010
We could also output as well computer.

35
00:02:14,280 --> 00:02:15,150
So let's try that again.

36
00:02:15,150 --> 00:02:17,640
So player five versus computer five.

37
00:02:17,640 --> 00:02:18,570
So that's a tie game.

38
00:02:19,050 --> 00:02:21,540
Player five versus computer three.

39
00:02:21,540 --> 00:02:28,140
So that means the player wins another tie and this time player got a four versus computer five.

40
00:02:28,230 --> 00:02:29,610
So that means the computer wins.

41
00:02:29,760 --> 00:02:32,100
So now we've got a quick little function in game.

42
00:02:32,280 --> 00:02:33,210
Have some fun with it.

43
00:02:33,330 --> 00:02:33,990
Try it out.
