I'm struggling with design patterns and would like to follow best practices while rewriting my current app from Objective-C to Swift.
I have a game where a player gets extra scores/or special prizes for, let's say, solving a certain amount of levels. There are several milestones to be reached (such as 10 levels completed/50 levels completed). I have different game modes, so I have several subclasses of a Gameplay class. After each player's turn -checkSolution
is being invoked to check whether the player solved the level. In case of success I increment the player's games score and send him to a new level . And here I also call -checkForMilestone
of ScoreManager class to check whether any of the milestones has been reached.
I'm not sure whether it is ok to call -checkForMilestone
inside -checkSolution
. Or it might be better to create a callback using blocks or use KVO to observe (from ScoreManager class) whether the player's score was changed and then react appropriately.