Functions - Challenges¶
Related Oculus Platform documentation:
Functions¶
challenges_get¶
challenges_get(challenge_id : String)
Returns information about a single challenge.
Returns: A GDOculusPlatformPromise that will contain a Dictionary with information about the challenge with the given challenge_id if fulfilled. The promise will error if the request couldn't be completed.
Example response:
Notes
Take a look at the example response and the note from the user_get_blocked_users function to know more details about the invited_users and participants keys.
The visibility field can be PUBLIC, PRIVATE, INVITE_ONLY or UNKNOWN.
The type field can be USER_CREATED, DEVELOPER_CREATED or UNKNOWN.
The leaderboard field can be an empty Dictionary.
The destination field of leaderboard can be an empty Dictionary.
challenges_get_list¶
challenges_get_list(limit : int, challenge_options : Dictionary)
Requests a list of challenges. You can pass various filters to narrow down the response - see bellow. The limit is the maximum number of challenges that this function can return.
Returns: A GDOculusPlatformPromise that will contain a Dictionary with information about a block of challenges if fulfilled. The promise will error if the request couldn't be completed.
Example response:
More info about previous_page_url and next_page_url.
The total_count key is not necessarily the total count of challenges in this block, but the total count of challenges that satisfy this query.
Default values:
limit defaults to 10.
By default challenge_options is:
challenge_options can have the following optional keys/fields:
| Key | Type | Example |
|---|---|---|
| leaderboard_name | String | MY_AWESOME_LEADERBOARD_API_NAME |
| title | String | Coin Challenge |
| description | String | Collect as many coins as you can! |
| start_date | int | 1784034738 |
| end_date | int | 1791012840 |
| viewer_filter | ChallengeVisibilityViewerFilter | GDOculusPlatform.CHALLENGE_VISIBILITY_VIEWER_ALL_VISIBLE |
| visibility | ChallengeVisibility | GDOculusPlatform.CHALLENGE_VISIBILITY_PUBLIC |
| include_active_challenges | bool | true |
| include_future_challenges | bool | false |
| include_past_challenges | bool | true |
Enums:
ChallengeVisibilityViewerFilter
| Name | Value | Description |
|---|---|---|
| CHALLENGE_VISIBILITY_VIEWER_ALL_VISIBLE | 1 | Will return all challenges visible to the user. |
| CHALLENGE_VISIBILITY_VIEWER_PARTICIPATING | 2 | Will return only challenges where the viewer is participating. |
| CHALLENGE_VISIBILITY_VIEWER_INVITED | 3 | Will return only challenges where the viewer is invited. |
| CHALLENGE_VISIBILITY_VIEWER_PARTICIPATING_OR_INVITED | 4 | Will return only challenges where the viewer is participating or invited. |
ChallengeVisibility
| Name | Value | Description |
|---|---|---|
| CHALLENGE_VISIBILITY_INVITE_ONLY | 1 | Will return all challenges that are invite only. |
| CHALLENGE_VISIBILITY_PUBLIC | 2 | Will return all public challenges. |
| CHALLENGE_VISIBILITY_PRIVATE | 3 | Will return all private challenges. |
Example
challenges_get_entries¶
challenges_get_entries(challenge_id : String, limit : int, filter : LeaderboardFilterType, start_at : LeaderboardStartAt)
Requests the entries of the challenge with the given challenge_id. The limit argument defines the number of entries to return and must be more than 0. If you set the filter to GDOculusPlatform.LEADERBOARD_FILTER_TYPE_FRIENDS you can restrict the result to bidirectional followers, for example.
Returns: A GDOculusPlatformPromise that will contain a Dictionary with information about a block of entries from the challenge. The promise will error if the request couldn't be fulfilled.
You can check the enums from leaderboard_get_entries to know what values you are allowed to use.
More info about previous_page_url and next_page_url.
Note
The total_count key is not the total count of elements in this page/block, but the total count of entries that satisfy the query/request. They can be the same if there are no more entries, but they don't have to.
The timestamp key is a UNIX timestamp (in seconds).
Example
challenge_get_entries_after_rank¶
challenge_get_entries_after_rank(challenge_id : String, limit : int, after_rank : int)
Requests the entries of the challenge with the given challenge_id after a given after_rank, for example, 5 returns challenge results starting with the 6th user. The limit argument defines the number of entries to return and must be more than 0.
The after_rank argument is exclusive, meaning that if for example you call this function with a limit of 3 and after_rank of 5, the response will include the 6th, 7th and 8th ranks/entries.
Returns: A GDOculusPlatformPromise that will contain a Dictionary with information about a block of entries from the challenge. The promise will error if the request couldn't be fulfilled.
Note
Take a look at the example response and the note from the challenges_get_entries function to know more details about the possible response from this function.
Example
challenge_get_entries_by_ids¶
challenge_get_entries_by_ids(challenge_id : String, limit : int, user_ids : Array, start_at : LeaderboardStartAt)
Requests the entries of the challenge with the given challenge_id and only entries that match the given user_ids. The limit argument defines the number of entries to return and must be more than 0. If the start_at argument is LEADERBOARD_START_AT_CENTERED_ON_VIEWER or LEADERBOARD_START_AT_CENTERED_ON_VIEWER_OR_TOP the current user/player ID will be automatically added to the request.
Returns: A GDOculusPlatformPromise that will contain a Dictionary with information about a block of entries from the challenge. The promise will error if the request couldn't be fulfilled.
Note
Take a look at the example response and the note from the challenges_get_entries function to know more details about the possible response from this function.
Example
challenges_join¶
challenges_join(challenge_id : String)
Sends a request to join the current user to the challenge with the challenge_id if the user has permission.
Returns: A GDOculusPlatformPromise that will contain a Dictionary with information about the challenge with the given challenge_id if fulfilled. The promise will error if the request couldn't be completed.
See the example response from challenges_get to know the format of the Dictionary that this function will return.
challenges_leave¶
challenges_leave(challenge_id : String)
Sends a request to withdraw the current user to the challenge with the challenge_id if the user has permission.
Returns: A GDOculusPlatformPromise that will contain a Dictionary with information about the challenge with the given challenge_id if fulfilled. The promise will error if the request couldn't be completed.
See the example response from challenges_get to know the format of the Dictionary that this function will return.
challenges_decline_invite¶
challenges_decline_invite(challenge_id : String)
Sends a request to decline an invite to join the challenge with the given challenge_id.
Returns: A GDOculusPlatformPromise that will contain a Dictionary with information about the challenge with the given challenge_id if fulfilled. The promise will error if the request couldn't be completed.
See the example response from challenges_get to know the format of the Dictionary that this function will return.