Public Member Functions | Static Public Member Functions | Properties

OFChallengeToUser Class Reference

#import <OFChallengeToUser.h>

List of all members.

Public Member Functions

(OFRequestHandle *) - completeWithResult:
(OFRequestHandle *) - reject
(void) - displayCompletionWithData:reChallengeDescription:
(void) - writeToFile:

Static Public Member Functions

(void) + setDelegate:
(OFChallengeToUser *) + readFromFile:
(NSString *) + getChallengeResultIconName:
(NSString *) + getResourceName

Properties

OFChallengechallenge
OFUserrecipient
OFChallengeResult result
NSString * resultDescription
NSString * formattedResultDescription
BOOL hasBeenViewed
NSUInteger attempts
BOOL hasDecrementedChallengeCount
BOOL isCompleted

Detailed Description

A OFChallengeToUser is received when another user has challenged this user. The public interface for OFChallengeToUser allows you to see the details of that challenge, as well as commit a result for that challenge (win/lose/tie) and also send a rechallenge.


Member Function Documentation

- (OFRequestHandle*) completeWithResult: (OFChallengeResult challengeResult

Send when the challenge is complete.

Parameters:
challengeResultOFChallengeResult enum with either win, lose or tie
Note:
This should be called before you call displayChallengeCompletedModal
You can not call this with a result of value kChallengeIncomplete.
If you would like a description, please set the resultDescription property on the OFChallenengeToUser before calling this.
Returns:
OFRequestHandle for the server request. Use this to cancel the request
Note:
Invokes - (void)didCompleteChallenge:(OFChallengeToUser*)challengeToUser on success and
  • (void)didFailCompleteChallenge:(OFChallengeToUser*)challengeToUser on failure
- (void) displayCompletionWithData: (NSData *)  resultData
reChallengeDescription: (NSString *)  reChallengeDescription 

Displays the default OpenFeint View for completing Challenges. If the user submits this view the challenger will be sent a message about the challenge result.

Parameters:
resultDataOnly used for multiAttempt challenges. The data needed to send the challenge result out as a new challenge
reChallengeDescriptionIf the challenge result is sent out as a new challenge (multi attempt only), this will be the description for the new challenge. Should be formatted the same way as challengeText in sendChallenge
Note:
Call completeWithResult before calling this. It stores nessiary data for this view If the user turns off the game during the challenge you must serialize the OFChallengeToUser as its used to display the completion modal. Serialize it to and from disc by calling writeChallengeToUserToFile or readChallengeToUserFromFile.
+ (NSString*) getChallengeResultIconName: (OFChallengeResult result
+ (NSString*) getResourceName
+ (OFChallengeToUser*) readFromFile: (NSString *)  fileName

Read the ChallengeToUser data from a file

Parameters:
fileNameThe name of the file to read the data from
Returns:
OFChallengeToUser The OFChallengeToUser deserialized from the file
- (OFRequestHandle*) reject

Reject a challenge

Note:
A rejected challenge will no longer appear in the pending challenges list
Returns:
OFRequestHandle for the server request. Use this to cancel the request
Note:
Invokes - (void)didRejectChallenge:(OFChallengeToUser*)challengeToUser; on success and
  • (void)didFailRejectChallenge:(OFChallengeToUser*)challengeToUser; on failure
+ (void) setDelegate: (id< OFChallengeToUserDelegate >)  delegate

Set a delegate for all OFChallengeToUser related actions. Must adopt the OFChallengeToUserDelegate protocol.

Note:
Defaults to nil. Weak reference
- (void) writeToFile: (NSString *)  fileName

Write the OFChallengeToUser data to a file

Parameters:
fileNameThe name of the file to write the data to
challengeToUserThe OFChallengeToUser to serialize to the file

Property Documentation

- (NSUInteger) attempts [read, assign]

Number of challenge attempts by this user.

- (OFChallenge *) challenge [read, assign]

The challenge which was sent.

- (NSString*) formattedResultDescription [read, assign]

The descprtion of the result defined by resultDescription with You or the user name appended to the front.

- (BOOL) hasBeenViewed [read, assign]

Wether or not the challenge has be viewed by the challengee

- (BOOL) hasDecrementedChallengeCount [read, write, assign]
- (BOOL) isCompleted [read, write, assign]
- (OFUser *) recipient [read, assign]

the user taht started this challenge

- (OFChallengeResult) result [read, write, assign]

The result of the challenge

- (NSString *) resultDescription [read, write, retain]

Description of the result. This is set well calling sendChallengeComplete

The result description will be prefixed by either the recipients name or You if it's the local player whenever displayed. The result description should not state if the recipient won or lost but contain the statistics of his attempt. Example: "beat 30 monsters" will turn into "You beat 30 monsters" and will be display next to a icon for win or lose


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations Enumerator Properties