So come back again resetting the game means doing a lot of different things means resetting the randomization
of the time it means resetting the time means making sure if game estate is in the vorn estate resetting
that and so many other things.
In fact this recent action is perhaps the only function that's going to stay with us until the end of
his development and every step of the development as we add new features to the code.
We end up adding some stuff for it in the Reset action as well.
But for now let's go ahead to X school.
And in the recent action I'm actually going to list the things we currently have to do.
First of all we have to set the game time to zero and then we have to read randomize everyone randomize
every time.
So let's see how we're going to do all of these things.
The first thing I'm going to do is I'm going to say game time.
That has to be Cong's zero.
That's something that we said right off the beginning.
The next thing is randomizing the tiles means several different things.
Above all means that we have to remake the tiles.
Now here is the problem we'll be facing if we remake the tiles and we add them to our game view.
It simply means that we have two sets of tires in there.
So because of that I have to first remove every one that is currently there.
So let me show you how I'm going to do that.
I'm going to go ahead and save for any and I'm going to see any in the tiles array.
Remember this is the array that holds on to all four tiles.
I'm going to say in the Remove from superb view so I'm going to remove every one that is currently in
the toilet from the view that is called The Game view.
So the one sided that I'm going to go ahead and say well now make on the tiles once again.
And if you made the tiles then randomize them.
Now that's a part of what we have to do in the reset and something that is going to come to my mind
right now is it seems like at the very beginning of the app when the app loads for the first time we
are also resetting everything.
And that's something that's happening in the view that lot.
So a lot of this is actually repetitious code and I could actually get three of them so to do that I'm
going to go ahead and say gets me all of these.
I'm going to cut all of them out go to reset and place them all in here.
So right now in my reset action gets rid of all of that so I can show you all the code in one go.
So that is getting rid of everyone that is currently in the game view.
Then I'm going to make the toys.
Randomize them then if they use a game timer running on when it invalidate them.
Sure the correct time which is 0 0 and rerun the game timer and that's all perfect except that right
at the beginning of the app nobody is calling the reset action.
So to fix that I'm going to go back to my view of that lot which crankily has nothing left in it.
I'm going to say of the reset action.
And he says you have to give me some bonus and I'm going to say self because it doesn't really matter
what we give it's of any value.
Essentially here in the reset it says it's any it is not an optional any.
So I have to feed it something you can say nil but you can't give it anything.
I'm going to say stuff because we are not doing anything with descender It's not like are checking for
ascender value and do things with it.
So with that just go ahead and see what we get in here.
If it all works the way we are hoping it's going to work.
We should see a reset game in a randomized game at the very beginning and a timer that is counting.
And every time I hit the reset I should get a brand new set and a brand new timer.
Again one two.
The timer is working and we got a brand new group of tiles on our reset is now working the way we're
hoping is going to do.
So let's keep it up to here on this one to our next lesson.