Skip to content

Instantly share code, notes, and snippets.

@gilday
Created December 1, 2012 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilday/4180271 to your computer and use it in GitHub Desktop.
Save gilday/4180271 to your computer and use it in GitHub Desktop.
Tim: this is how i assigned characters to everyone playing
-(ClueGameService*) initNewGameWithPlayers:(NSArray *)gkTurnBasedParticipants
{
self = [super init];
NSMutableArray *playersList = [[NSMutableArray alloc] initWithCapacity:[gkTurnBasedParticipants count]];
// The first player is always ms scarlet. don't care about the rest
NSArray *allCharacters = [[NSArray alloc] initWithObjects:[ClueCharacterFactory msScarlet], [ClueCharacterFactory colMustard], [ClueCharacterFactory mrsWhite], [ClueCharacterFactory profPlum] , nil];
for (int i = 0; i < [gkTurnBasedParticipants count]; i++) {
Player *player = [[Player alloc] init];
player.participant = [gkTurnBasedParticipants objectAtIndex:i];
player.character = [allCharacters objectAtIndex:i];
player.location = [player.character name];
[playersList addObject:player];
}
players = playersList;
currentPlayer = [playersList objectAtIndex:0];
return self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment