HTML and CSS Reference
In-Depth Information
if (
Objective complete - mini debriefing
The comparison requires us to create a mulilayered patern composiion from the selecion
sequence. Then, we compare the player's one with that of the quest level.
Composiion is a two-dimensional array that we need to compare between the quest and
the player's selecion. However, the player's selecion is a sequence that does not relect our
layer's structure. This is the reason why we need a conversion between the composiion and
the sequence. Moreover, we need to keep a copy of the player's sequence because we need
that informaion for the undo feature.
Comparing players and compositions of the quest
In our createFromSequence method, we created two helper funcions to manipulate
mulilayered paterns. The allowPatternsInSameLevel funcion checks whether the
given two paterns can be overlapped together by looking up the non-overlapped patern
table. The layerAllowsPattern funcion makes use of the previous funcion and checks
whether the given patern its all other paterns inside the given layer, which is an array of
all non-overlapped paterns put together.
The createFromSequence method makes use of the funcion to scan the selecion array
in a sequence and then put each patern into either the same layer (without overlapping)
or a new layer.
Finally, we have the isEqualToComposition method in the quest instance to compare
the player's selecion composiion with the quest level's one. This method sorts all the
layers in both the composiions into the same order and then converts the composiion
back to a one-dimension array using the toSequence method.
This ensures the player's selecion can match our deined level of data on non-overlapping
paterns, regardless of the order of selecion.
Classified intel
We atach the relaionship of non-overlapping paterns directly to the composiion object
because they are the same, regardless of each instance. Ataching it to the composiion instead
of the instance's prototype prevents this block of data from being copied to each instance.
Search WWH ::

Custom Search