iphone - How to find filled seats in iOS Gamecenter match.participants? -
i'm writing turn based ios game using gamecenter , having issues finding seated in partially filled game. how should walk through match's participants array , pull out seated players? there between [1,8] players in game @ 1 time , trying populate lobby filled.
here 2 convenience methods wrote 'gkturnbasedmatch' category:
@implementation gkturnbasedmatch (convenience) - (nsarray *) remainingplayingparticipants; { nsmutablearray *participants = [nsmutablearray array]; // start searching @ current player nsuinteger currentindex = [self.participants indexofobject:self.currentparticipant]; (int = 0; < [self.participants count]; i++) { gkturnbasedparticipant *part = [self.participants objectatindex:(currentindex + 1 + i) % self.participants.count]; if (part.matchoutcome == gkturnbasedmatchoutcomenone) { [participants addobject:part]; } } return [nsarray arraywitharray:participants]; } - (nsarray *) remainingplayingandmatchedopponents; { nsmutablearray *participants = [nsmutablearray array]; gkturnbasedparticipant *localparticipant = [self localparticipant]; // start searching @ current player nsuinteger currentindex = [self.participants indexofobject:self.currentparticipant]; (int = 0; < [self.participants count]; i++) { gkturnbasedparticipant *part = [self.participants objectatindex:(currentindex + 1 + i) % self.participants.count]; if (part.matchoutcome == gkturnbasedmatchoutcomenone && part.status == gkturnbasedparticipantstatusactive && part != localparticipant) { [participants addobject:part]; } } return [nsarray arraywitharray:participants]; } @end
Comments
Post a Comment