We are nearing the end of our journey through the pool hall. There is still one gaping hole in our game: the logic of the rules engine and how we use it. Earlier, we saw how we load the rules into our OPRulesBase
class, and we have done a little in the
OPPlayfieldLayer
class with using the player goals to update the player's display. We will dig into the rules engine with the smaller, simpler methods first.
Filename: OPRulesBase.mm
-(GameMode) getCurrentPlayerGoal { if (currentPlayer == 1) { return player1Goal; } else { return player2Goal; } }
Because every rule in the game of pool will depend on which player is taking their turn (especially in the case of Eight Ball), this is our helper method to determine what the current player's goal really is. This will be used by several of the other methods in this class.
Filename: OPRulesBase.mm
-(BOOL) didSinkLastBall:(NSArray*)ballArray { for (OPBall *aBall in ballArray) { if (aBall.tag...