1 00:00:00,000 --> 00:00:01,845 Let's talk about the token object. 2 00:00:01,845 --> 00:00:07,401 If you haven't yet, go ahead and open up the token.js file that you created. 3 00:00:07,401 --> 00:00:11,601 Check the syntax of your token class declaration against mine here. 4 00:00:11,601 --> 00:00:16,958 Okay, now, let's go ahead and add in our empty constructor method. 5 00:00:16,958 --> 00:00:20,896 Okay, so after developing the properties for the player object, 6 00:00:20,896 --> 00:00:25,548 you might have found it easier to think about how to organize the token object. 7 00:00:25,548 --> 00:00:30,412 That's because a lot of the properties of a token are dependent on the player 8 00:00:30,412 --> 00:00:31,328 that owns it. 9 00:00:31,328 --> 00:00:35,150 With that in mind, the first property of the token object should be owner. 10 00:00:35,150 --> 00:00:39,997 This property will hold a reference to the player object that owns the token. 11 00:00:39,997 --> 00:00:43,378 This is useful because now each token will have access to the ID and 12 00:00:43,378 --> 00:00:45,293 the color of the player that owns it. 13 00:00:45,293 --> 00:00:49,657 Setting it up this way means fewer properties for us to manage later. 14 00:00:49,657 --> 00:00:53,455 The reference to the player object is passed in when the player token object 15 00:00:53,455 --> 00:00:54,125 is created. 16 00:00:54,125 --> 00:00:56,695 Don’t worry about that too much now. 17 00:00:56,695 --> 00:00:58,920 You'll be writing that method in the next step. 18 00:00:58,920 --> 00:01:02,453 Next, the token object needs an ID property. 19 00:01:02,453 --> 00:01:07,073 The main reason a token needs an ID property is because eventually 20 00:01:07,073 --> 00:01:11,194 there will be many token objects represented in our HTML. 21 00:01:11,194 --> 00:01:15,848 And we'll need to be able to reference each HTML representation 22 00:01:15,848 --> 00:01:20,510 individually with an ID for CSS and DOM manipulation purposes. 23 00:01:20,510 --> 00:01:22,046 For now, I'll set the ID to token. 24 00:01:22,046 --> 00:01:27,399 But this won't work in the long run because each token ID needs to be unique. 25 00:01:27,399 --> 00:01:28,150 So how can we do that? 26 00:01:28,150 --> 00:01:33,415 When we write the method to create the token objects inside the player class, 27 00:01:33,415 --> 00:01:39,006 you'll see that the token objects are all going to be created inside the for loop. 28 00:01:39,006 --> 00:01:41,548 On each iteration, a new token will be created. 29 00:01:41,548 --> 00:01:46,668 And one way to give each token a unique ID is to pass in the loop index. 30 00:01:46,668 --> 00:01:50,268 I can concatenate this index with the string token and 31 00:01:50,268 --> 00:01:54,677 then each token object of a given player will now have a unique ID. 32 00:01:54,677 --> 00:01:57,485 I'm using template literals to do this. 33 00:01:57,485 --> 00:02:00,358 For a refresher on how to use template literals, 34 00:02:00,358 --> 00:02:02,885 check the teacher's notes on this video. 35 00:02:02,885 --> 00:02:08,088 Now I'm also going to concat the value of the owning player's ID property so 36 00:02:08,088 --> 00:02:11,107 we can tell the tokens of each player apart. 37 00:02:11,107 --> 00:02:12,869 The final property will be dropped. 38 00:02:12,869 --> 00:02:16,167 This will hold a true or false, or Boolean value, 39 00:02:16,167 --> 00:02:20,030 that indicates whether or not that token has been played. 40 00:02:20,030 --> 00:02:24,503 To start, it will be set to false because none of the tokens have been dropped yet. 41 00:02:24,503 --> 00:02:28,590 Okay, now that the token constructor method has been created, 42 00:02:28,590 --> 00:02:33,748 move to the next step, where we'll write the method to create all of the tokens.