I am working on a turn-based GameCenter game. A GKTurnBasedMatch
is created with a GKMatchRequest
, with minPlayers
and maxPlayers
set to 2. I get an NSInvalidArgumentException
while trying to end the game with endMatchInTurnWithMatchData
, telling me that I didn't set matchOutcome
on all participants. Logs for the match object right before this point reveal that my match looks like this:
<GKTurnBasedMatch 0x1c1f2af0 - matchID:c9de6e47-0e9a-4dbe-944b-d2fd4ecd3044 bundleID:com.mybundle.wd status:GKTurnBasedMatchStatusEnded message:'Game Over' creationDate:2013-10-08 01:26:12 +0000 currentParticipant:(null) participants:
<GKTurnBasedParticipant 0x1c184820 - playerID:G:128458444 (local player) status:Done matchOutcome:Lost lastTurnDate:2013-10-10 21:54:22 +0000 timeoutDate:(null)>,
<GKTurnBasedParticipant 0x1c1b0a80 - playerID:G:220673962 status:Done matchOutcome:Lost lastTurnDate:2013-10-10 18:26:16 +0000 timeoutDate:(null)>,
<GKTurnBasedParticipant 0x16ef1610 - playerID:G:128458444 (local player) status:Active matchOutcome:None lastTurnDate:(null) timeoutDate:(null)>,
<GKTurnBasedParticipant 0x16ec64f0 - playerID:(null) status:Matching matchOutcome:None lastTurnDate:(null) timeoutDate:(null)> matchData.length:871 matchDataMaximumSize:65536 exchanges:(null)>
I have more than 2 GKTurnBasedParticipants
here, and two of them are the same player! I don't do anything extraordinary in the game, except calling the following each turn:
[match endTurnWithNextParticipants:@[nextParticipant] turnTimeout:GKTurnTimeoutDefault matchData:data completionHandler:^(NSError *error){...}]
Does anyone have any idea what's going on here? It's a two-player game, so how am I ending up with a messed-up match object, and how can I prevent this?