When you are developing a game, it's always good to try the game out and just get a feel for it, see
how it works.
I want to bring it back up to 100 percent.
We're going to hit start game.
And our first instruction is to select a case.
So this is the case that the user is going to store and then they're going to be able to select additional
cases until the next offer and an offer, an offer and so on, until they run out of offers and then
they eventually get the their selected case.
So the objective now is to make a selection of the case and we don't have a whole lot happening.
So this is our next step where we're picking up the case value that's been sitting in there, but we're
not doing anything with that value.
So that's what we want to accomplish in this lesson, is apply that check case function and do something
more with one.
We're doing the checking of the case.
So right now, we're just getting the target value.
So let's go ahead and add in a brand new class.
This is going to be the muted class.
And what this is the one that we're going to apply to the elements as they get clicked.
I also want to make sure that the game is in place.
So where we set that game object in play, make sure that this is true before we continue before try
to do anything within this function.
So save and let's start the game.
So everything is still working as expected.
And now we can make a selection and we've got it in place.
So with the target that's been selected, this is where we want to apply the muted class to.
So class list add and the class that we're adding is muted.
So how the game is so far so select one.
And you can see that as I click them, they get great out.
So what else should happen at this point is that it should grow out or it should disappear off the side
bar menus.
So we need to make sure that we can select that from the existing array that we constructed.
And we also need to make sure that we're counting these and we're removing them from the holding array
where we've got all of the objects being held.
So there's a few things that we need to accomplish within this check case function in order to continue
with the gameplay.
So the objective is to find out and determine what the value in games array is.
So we had that game holding array.
So if you console log out the game and holding array, you can see all of the content that's contained
within that game holding array.
So let's close that click one of the cases and we don't have anything right now within the game holding
array.
So we've got to go back up to where we set the tempo and we got to push that value into the game holding
array.
So game holding array and push the value of temp into it.
So save that and we'll try that one more time.
So now when I select a case, I should have an array of all of the values that are being set in there.
So this is our temporary holding or we're going to select elements and we're going to remove them from
that array.
And we're also going to check the valid the number of items that are currently sitting within that array.
So that's all of the cases that we have.
And as we select them, we want to remove them out.
So that means that we need to determine what the index value is.
So let's get the index value of that element.
So using the game holding array and we're going to check to find index of which is going to return back
the index value if it's available and we can use this value or e target value.
So maybe just to be consistent, we're going to use the E target value and console, logout the value
of Ayanda so that we can see that and close.
So we see that that was first, that's five and it's corresponding with the values that we have here.
So it's going to be six, that one, seven eleven and so on, because it's finding those values within
the array and its output in those array values.
And we know that we did put them within that that order as well.
Let's also find another index value.
And in this case, we're going to select from the Vowles array.
So this is the one that we never touched and using index of where we're going to select the value and
see where this is located within this array.
And this is going to also provide us some information and details that we can make use of.
So really, at the end of the day, we don't have to change.
We don't really have to actually get this value because the indie value is going to be the same as we've
got already contained.
And we know that we've been adding that value as we're building the the game board.
We're adding in the index the entire value.
So when we make a selection, we can get the iron D value and that should be the same plus one on one
of the index cards.
So let's press for and we see we get three for the index.
Value and then we get four for the value that's contained within where it's located, within the array.
So that was number four and it's actually within the array itself.
It's number three and four holds the value of one.
We look in the holding game holding array.
So for the item with index value number three, because we know that it's the third one and because
arrays are zero based.
So one, two, three, four.
And that's returning the value of one.
So that's where we can get that value from that index array.
And we can also see when we're checking to see that index value, we're returning back three.
And we also know that this value of one is the first one in the values index.
So now that we've got all of this information, we can make use of it and we don't actually even need
to check indeed, because we already have it contained within the target.
So that's a double there.
And if you're looking to pass those values, that's one of the ways that you can do that.
We should also, as we're removing the option, I don't want to be able to keep continuously clicking
it.
So let's go ahead and we're going to add or remove our target.
So are selecting the element once again.
And as we remove out the target, we're also going to remove out the event listener.
And then that listener is going to be the click event and it's listening for the check case.
So it's invoking the Chuck case function.
So that means that once we click something, we can't keep pressing it.
It's not it's only going to allow us to press it once.
And that's ideally what we want to do.
Also, let's check and get the length of the items within the game holding array.
So we want to know that there's how many items are left in there.
So game holding, array length.
And we're going to check to see if its length is equal to the vals length.
And if it is, then we know that this is the first instance.
So this is the case that the user actually selected.
And if it's not, then we're just going to go through the regular gameplay and allow the user to make
the selection of those.
So let's create another variable, and that's the game selection.
So this is going to be the user selection game, FCL and using the game holding array, we're going
to splice the value out of it.
So taking that one value and we need to have a starting point.
So that's the end.
So we could have used as well the easy target, indie value.
And we're taking the value and we're only taking one item out of the array.
And we also want to base.
And because we're going to be returning back, just as we saw before, that we're selecting it within
an array base.
So we only want to return back the value without being within wrapped in an array.
So that's where we're breaking out of and we're getting that first entry back and let's type in temp.
So we need a variable that's going to hold the next value.
So temp case next is going to be the game and subtracting the game offers.
And this is where the game offers are going to come into play and we're going through and moving over
to the next game offer so we can use the offer made value in order to accomplish that.
So we're getting that value out of the array.
So I it's getting fairly complex, but I will run through it one more time because we need to know how
many what how many cases the user has to select next.
And we're going to send that into the pop up message.
So that's what all of this was really calculating out how many cases and for the message that we can
provide the user.
So we're providing them, which case they select it.
And again, it can be this or easy target.
So either one is fine.
So the target.
And so that's the case that they selected the case number.
Always think about it from the player's perspective.
When they're playing the game, they need to know what's coming next.
And they also need to know what's happening within the game.
So we tell them that they've selected the case that they've selected.
And also within the pop up, we're going to tell them how many cases they have until they receive an
offer.
So they need to select this number of cases before the offer.
I'm also going to update this to do a word drop so we can see the content better.
Values that were writing, so I know it's a long statement there, so now when we make a selection,
we can go through an essay Selecta case, click any of the cases below.
So make our selection select a number for now, select one case, and then we need to select more cases.
This is where the statement comes in.
What's going to happen when we're not selecting the first case?
And also we need to be able to trigger offers as well.
So all of that is still yet to come.
So go ahead and add this into your project that we've got the ability to check the first case.
And again, it is following through as you play the game, you got to think of what's next.
What action do you want to happen next?
And that guides you to what you need to do within the code.
So we're selecting case we selected case number five.
So that's stored.
And then now we need to select one more case and we select one more case and that we should be triggering
an offer at this.
So coming up next, let's add that in.