-
Notifications
You must be signed in to change notification settings - Fork 0
Trophies
Simón Olivo (Sarturo) edited this page Aug 2, 2020
·
12 revisions
The following functions allow you to implement the Trophy feature in your games.
fetch_trophy(params: Dictionary, options: Dictionary) -> GameJoltAPIRequest
Returns one trophy or multiple trophies, depending on the parameters passed in.
- 'username': String The player's username.
- 'user_token': String The player's game_token.
-
'achieved': bool (optional) Set
true
to return only the achieved trophies for a user. Setfalse
to return only trophies the user hasn't achieved. If you don't introduce this parameter, it will retrieve all trophies. - 'trophy_id': int (optional) If you would like to return just one trophy, you may pass the trophy ID with this parameter. If you do, only that trophy will be returned in the response. You may also pass multiple trophy IDs here if you want to return a subset of all the trophies. You do this as a comma-separated list in the same way you would for retrieving multiple users. Passing a trophy_id will ignore the achieved parameter if it is passed.
-
'ssl': bool (optional) If SSL is enabled (set to
true
), API requests are made by using the HTTPS protocol. (Enabled by default).
-
api_request_completed(data: Array) Returns an array of several elements, each one with the following Dictionary:
- "id": int The ID of the trophy.
- "title": String The title of the trophy on the site.
- "description": String The trophy description text.
- "difficulty": String Bronze, Silver, Gold, or Platinum.
- "image_url": String The URL of the trophy's thumbnail image.
-
"achieved": bool or String Date/time when the trophy was achieved by the user, or
false
if the user hasn't achieved it yet.
- api_request_failed(error: String) Returns an error message.
add_achieved(params: Dictionary, options: Dictionary) -> GameJoltAPIRequest
Sets a trophy as achieved for a particular user.
- 'username': String The player's username.
- 'user_token': String The player's game_token.
- 'trophy_id': int The ID of the trophy to add for the user.
-
'ssl': bool (optional) If SSL is enabled (set to
true
), API requests are made by using the HTTPS protocol. (Enabled by default).
- api_request_completed(data: Array) Returns an empty array.
- api_request_failed(error: String) Returns an error message.
remove_achieved(params: Dictionary, options: Dictionary) -> GameJoltAPIRequest
Remove a previously achieved trophy for a particular user.
- 'username': String The player's username.
- 'user_token': String The player's game_token.
- 'trophy_id': int The ID of the trophy to add for the user.
-
'ssl': bool (optional) If SSL is enabled (set to
true
), API requests are made by using the HTTPS protocol. (Enabled by default).
- api_request_completed(data: Array) Returns an empty array.
- api_request_failed(error: String) Returns an error message.