4

I'm sure there are questions similar to this, but I couldn't find an example. I'm trying to recreate the apple GKTurnBasedMatchmakerViewController for my turn based game with my own custom interface for my turn based iphone game. I'm having trouble getting all the options to display correctly so I was hoping someone had a working example. My current code is this:

-(void)getCurrentGamesFromServer  {
[GKTurnBasedMatch loadMatchesWithCompletionHandler:^(NSArray *matches, NSError *error) {
    if(matches){
        for (GKTurnBasedMatch *myMatch in matches) {

            //this is, I believe, also where we need to consider invitations.  available instance methods provided by GC are: acceptInviteWithCompletionHandler and declineInviteWithCompletionHandler

            if(myMatch.status == 1){ //ongoing game
                if([myMatch.currentParticipant.playerID isEqualToString:[GKLocalPlayer localPlayer].playerID]){ //if it's my turn
                    //here we need to populate the table by adding our matches to mcurrentgamesarray.  after all the matches have been added, reload the tableview

                    NSLog(@"active game that is my turn");
                    [self.mCurrentGamesArray addObject:myMatch];

                }
                else{
                    NSLog(@"other turn or an invite from another player waiting to hear from you");
                }
            }

        }
    }
    [_mCurrentGamesTableView reloadData];
}];
}

As you can see, the only games I'm grabbing right now are games where the status is 1 (ongoing game) and the current participant ID is my ID.

to get games that were not my turn, I tried doing games where it was not my ID, but it included invites with it and I couldn't figure out how to separate them out.

Basically, I'd like to have a section of games where it is my turn, a section where it is not my turn but games are still active, a section of completed old games, and a section for invites. does anyone have a working example, or a page they can send me to that explains the best practices for what I'm trying to do? Thanks for your help.

Edward Glasser
  • 183
  • 4
  • 17

0 Answers0