Skip to content

Instantly share code, notes, and snippets.

@morganwilde
Last active August 29, 2015 14:03
Show Gist options
  • Save morganwilde/49d400dddda470f600da to your computer and use it in GitHub Desktop.
Save morganwilde/49d400dddda470f600da to your computer and use it in GitHub Desktop.
finder.m
- (Activity *)initiateActivityForPerson
{
Activity *activity = [[Activity alloc] init];
/* Set all the prerequisites */
activity.user = [self.sdk currentUser];
activity.name = [NSString stringWithFormat:@"Play %@", self.level.name];
activity.activityType = 1;
activity.multiplayer = YES;
activity.level = self.level.level + 1;
// Questions for this activity
NSArray * cards = [self cardsForToday:YES andLevel:self.level];
Deck * deck = [[Deck alloc] initWithCards:cards];
activity.questions = [deck questions];
return activity;
}
- (void)actPlayFriend:(NSString *)friendCode
{
/* Use this if you have a friend code */
GameVC *parentVC = (GameVC *)self.parentViewController;
parentVC.activity = [self initiateActivityForPerson];
parentVC.activity.friendCode = friendCode;
[self.sdk startActivity:parentVC.activity];
[parentVC actFindOpponent];
}
- (void)actPlayOpponent:(int)opponentId
{
/* Use this if you have an opponent ID */
GameVC *parentVC = (GameVC *)self.parentViewController;
parentVC.activity = [self initiateActivityForPerson];
parentVC.activity.opponentID = opponentId;
[self.sdk startActivity:parentVC.activity];
[parentVC actFindOpponent];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment