Skip to main content
1 of 2
sha
  • 439
  • 3
  • 10

SOGame.m class

Validation logic can be improved:

// Use shorter syntax to access array elements
SOSimon *simon = _sequence[_selectionNumber];

// Remove duplicated code
NSUInteger correctChoice = simon.opposite ? [self opposititePosition:simon.simonSays] : simon.simonSays;

if (playerChoice == correctChoice) {
    [self doSuccessfulChoice];
} else {
    _state = GameStateFailure;
}
sha
  • 439
  • 3
  • 10