In this post, I describe the "Level Manager". Expanding on my previous post which saw the implementation of a basic score counter, this implementation goes further by tracking respective scores against the objectives of a level. When all conditions are met, the player wins, but if these are not met within a set number of turns, the player loses.
Let's explore the most important part: the function which updates the current progress state. This function is called by the board manager, which stores a reference to the level manager game object.
The function takes a list containing the elements which have been matched. It begins by iterating through each element of the list, and determining if it is currently being tracked. If not, it is added to the dictionary of tracked elements. If it is already in this dictionary, the value is incremented, increasing the tracked count of the element.
Secondly, the text is updated to reflect any changes in progress, so the player can see results from their actions.
Thirdly, it is determined whether or not this update in progress should result in a win state being reached. This is achieved through counting each win condition that has been reached. It checks if all of these conditions have been met- if they have then a win state is initiated.
Finally, the overall basic score is incremented.
Comments