How to exclude the player who has lost , in iOS Game Center TURN-BASED App

I created a game turn-based in iOS game center, the game works well, the data is properly passed from player to player.

I wanted to know:

how can you EXCLUDE a player who has lost before the other?

I find no reference anywhere How would I go?

Thanks in advance and sorry for my english

Angelo

edit:

Ok, I tried this and it worked (the excluded player can also view the match)

    //When current player is excluded

GKTurnBasedMatch *currentMatch = [[GCTurnBasedMatchHelper sharedInstance] currentMatch];
currentMatch.currentParticipant.matchOutcome == GKTurnBasedMatchOutcomeQuit




//FOR SEND TURN : 

    NSUInteger currentIndex = [currentMatch.participants indexOfObject:currentMatch.currentParticipant];

    GKTurnBasedParticipant *nextParticipant;

    NSUInteger nextIndex = (currentIndex + 1) % [currentMatch.participants count];

    nextParticipant = [currentMatch.participants objectAtIndex:nextIndex];

    for (int i = 0; i < [currentMatch.participants count]; i++) {

        nextParticipant = [currentMatch.participants objectAtIndex:((currentIndex + 1 + i) % [currentMatch.participants count ])];

        if (nextParticipant.matchOutcome != GKTurnBasedMatchOutcomeQuit) {
            ///prossimo giocatore che NON è stato escluso
            break;
        } else {
            /////Prossimo giocatore perché questo è stato escluso
        }
    }



 [currentMatch endTurnWithNextParticipant:nextParticipant matchData:data completionHandler:^(NSError *error) {

            […]

        }];

Answers


I am not a Game Center expert but, from memory, your code can choose who takes the next turn. So you can calculate who is to take the next turn and simply skip any players who have already lost. You probably should update their game data though so they can follow the game to the end.

Ray Wenderlich has a couple of example tutorials on Game Centre turn-based gaming: Beginning turn-based gaming with iOS 5

No example code to share - sorry.


Need Your Help

Limits of Protocol Extensions and defaults in swift2

swift protocols swift-protocols

So I was playing around with protocol extensions and i ran into an "interesting" problem.