Display Challenge Progress

Player's Progress API helps you display the player’s progress in different Gameball programs within your app or web page. It returns the player's progress in challenges, levels, wallet points balance, and referrals, in addition to other information related to the player.

Let's begin with a simple use case where you would like to show the player their progress in achieving the available challenges

All the needed information is available in the challenge progress array within the player’s progress API response, as follows:

"challengesProgress":[
    {
        "id":"123",
        "name":"Welcome",
        "description":"Welcome Challenge",
        "isUnlocked":true,
        "highScoreAmount":null,
        "completionPercentage":0,
        "isRepeatable":false,
        "achievedCount":0,
        "icon":"https://cdn.gameball.co/uploads/client776/643323652begb.png"
    },
    {
        "id":"p123",
        "name":"Place Order",
        "isUnlocked":true,
        "highScoreAmount":null,
        "completionPercentage":55,
        "isRepeatable":true,
        "achievedCount":2,
        "icon":"https://cdn.gameball.co/uploads/client776/a643323652begb.png"
    }
]

The challenge progress holds the progress of the player against every eligible challenge. Let's examine each challenge attribute returned by the challenge progress array and see how they can help us in building the UI.

First thing we may use is the id, name, description and icon. These attributes can be used to draw the eligible challenges list for the player without progress information.

Now let's say you want to highlight the achieved challenges and dim the non achieved challenge on your UI. You can easily do this by checking the achievedCount attribute. Where a 0 represents not yet achieved and 1 or more denotes that a challenge was achieved at least once.

In our example the Welcome challenge achieved count is equal to 1 and First Order challenge achieved count is equal to 0, hence we will be adding a dimming style for the First Order challenge icon.

For challenges where a player has done a progress but not yet completed, you can make use of completionPercentage attribute where it represents the current progress. Let's say we have a challenge “Tenth Order” that the user will achieve when making 10 orders. If the user completed 6 orders, the response will look like this:

{
    "id":"p123",
    "name":"Tenth Order",
    "isUnlocked":true,
    "highScoreAmount":null,
    "completionPercentage":60,
    "isRepeatable":false,
    "achievedCount":0,
    "icon":"https://cdn.gameball.co/uploads/client776/a643323652begb.png"
}

Last updated