Come back we need a system in place to tell you is there when they win the game.
Essentially if they manage to find every pair of the numbers on every pair of the tiles the system should
tell them that you want the game and to do that.
I'm actually having a particular strategy in mind that I'm going to write that down for you Scott as
as comments so you can see what's going on.
So here's my strategy.
I'm going to go ahead and remember how many times I have already found.
So let's go ahead and find one.
This is 2006 not the right ones.
Five on one.
Not the right ones.
Four six and six.
These are the right ones.
So by the end of this comparison I'm well remember the number of the sound ones.
So I'm going to say remember the number of foundlings.
So right now it has to let me add one more.
So this is a more descriptive seven and two and three and zero zero.
So now that number becomes four.
So I have found four of them.
Then each time I find a pair and I do them I compare the total number against the entire number of the
times.
So compare found against total games total.
So if I have four found ones and there are 16 total ones obviously I haven't won the game but if I have
16 found ones under 16 total times it means I have won the game and let's go ahead and put this strategy
into court to make sure that you know we get it.
I want to come to my real control and say I have a new variable and they call this one found the levels
array which is going to be an array of my label my label and it's going to be an optional one at the
very beginning and I don't need any of these comments.
So we have this one and then this one we have to at some point we have to reset it.
What is it.
Now I could make it an empty array and that's all.
Well what we have to remember to reset it again in the Reset auction to I'm going to go to my reset
auction which is here and say right at the beginning every time that you reset and the game time becomes
zero.
Also say founda times are also empty and then when do we add to this Fountain's we add to them every
time that we do a compare and compare results in success.
So here when we turn them into a smiley faces I'm going to go ahead and say fountain is the way that
I spend first time.
And then times range not append second time.
So it means every time you found the right ones add them to this found array.
And the last the step of the work was to compare the number of the elements in here against the number
in the total.
So it's go ahead and do that in a separate function.
I'm actually going to go ahead and make a new file called this one view controller plus warn the state
and I have the same things as before.
You can't.
This is an extension extension to view controller.
It has only one function called Did we win.
And it even does this.
It says Let's find out how many of these values are there.
If found tied is the rate that counts.
If that is equivalent to what it would it be equivalent to.
It can be written in several different ways.
One of them is we have to get our game mode which is for instance a game mode multiplied by gameboard
because that produces four by four 16.
There also another place that we have that and that is the actual tiles.
So I would say if these guys are equivalent to tiles array that counts.
It means the number of the times we have found is the same number of the total tiles.
And then when it gets rid of that say in that case we have gone and I'm going to show that in a very
particular way.
I have to do several things.
I'm going to invalidate the timer say game timer that invalidate and then I'm going to write in here
in this little game vorn that you've worn in a certain number of seconds.
So I'm going to go ahead and say let's produce a little text.
I'm going to say let sixty two be you want to in and then I'm going to have to add a little formatting
in here for nothing.
Is this the same thing we had done for the game time or before.
So it's a bit of a long record but bear with me as I write it.
It becomes game time.
Not that.
Game time divided by 60.
That becomes our seconds then becomes a space and we put a column.
Then we're going to go ahead and write another one.
That other format is going to be game time modulus 60 and that's going to have a seconds sign and that's
how we're going to see how much how much time it takes you to win.
You could of course format it if you want to count for the leading zeros.
I'm not going to really worry about that just now.
So the T X is going to show up in that label down there which we haven't talked about in a very very
long time.
Let me go ahead and find it.
It's actually called Game Move-On label and here's what I'm going to do with it.
I'm going to go to my reset.
I remember I said the reset function is something that we keep coming back to it.
And there's still a lot of code left that I have to write and it's going to come up in the next few
lessons.
But for now I'm going to say Game 1 label that he's done.
Is that true.
So by default everything there he said it's hidden because we haven't won the game yet.
By the end of all honesty I'm going to say game on his label.
Is he then becomes false so it's not hidden anymore and came Warner-Levin dot text it becomes Stevy
just produced.
So it becomes the value that says you own in certain number of minutes and seconds.
And finally I have to use that even Sumburgh and that is VTM they compare.
So we tend to compare.
I have to say every time you found the right ones and you added them to the found ones go ahead and
say get to them.
And that's about that.
So let me go on the.
And now let's see how we will do.
I got zero on five and six countries 0 5 6 3 7 3 0 5 6 7 0 0 0 5 7 now I have and then 2 1 1 0 5 7 and
I've got 5 and then 0 and then I've got one I think was there two is here and then this should be the
last one.
And then I tap on it this time I should pause and we should see that we move on.
I press there.
Yes you've on in zero minutes and 44 seconds and the timer is paused in there.
That's it.
We managed to make the game.
That shows us how long it took us to win the game.
And we have found every one in here.
So let's move on to our next thing then.