Skip to main content
added 169 characters in body
Source Link
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;
}

SOSimonSays.h

Putting SimonSaysNumChoices inside your enum will confuse auto-complete and warnings system down the road. Create a separate constant for it.

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;
}

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;
}

SOSimonSays.h

Putting SimonSaysNumChoices inside your enum will confuse auto-complete and warnings system down the road. Create a separate constant for it.

Source Link
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;
}