We are often asked how to track a player's maximum score in for each day/week/month. Using a leaderboard that resets daily/weekly/monthly (see Reset Frequency here) won't achieve this. The reason for this is that when you configure a leaderboard to reset, the leaderboard will reset the entries but not the underlying running total data. So, if I scored 50 on day one, I would need to score >50 on day two to register a new high score. However, you can make use of leaderboard partitions to start from zero each day.
There are two steps to complete for this:
- Set up an Event that you will use for your leaderboard's running total that has a score Attribute to collect a player's scores.
- Add a second Attribute to your Event which uses a generalized date format for it's Default Value and which also uses a Grouped setting for its Default Aggregation Value.
You can then use the Grouped Attribute to partition your leaderboard's data against to show separate entries for each day/week/month/year.
Step 1: Creating an Event for a Running Total with a Date Formatted Attribute
Here's an example of an Event configuration you can use for a driving time-partitioned leaderboards, and which is intended to illustrate the kind of Grouped Attributes you will need to meet this use case for resetting leaderboards on a daily/weekly/monthly basis.
In this example, the important part to note are the expressions used for the Default Values of the Event's day/week/month/year Attributes. Take the day Attribute - because we have used this type of generalized expression as the Default Value for the day Attribute, it will automatically be added in accordance with this format in the partition. For example, for January 25th it will be added as "01-25". For the next day, January 26th, it will be added as "01-26", and so on. To read more about the supported expressions, please see here.
Step 2: Configuring a Partitioned Leaderboard used a Running Total with a Time-Based Grouped Attribute
An example of a day leaderboard configuration is given below. Note that we are partitioning on the day Attribute we set up the leaderboard_Time Event's configuration. You can also create separate leaderboards for week, month, and year in a similar way. Just remember to swap out the partitioned value for the time period on which you want to partition your leaderboard - week for week, month for month, and so on.
Checking Leaderboard Configuration in the Test Harness
Now you can submit a score in the Test Harness. Authenticate as a player and then send your score Event. Note that the day Attribute doesn't need to be added as it's handled by the Default Value we set in the Event.
You should get a NewHighScoreMessage like the one below.
As you can see, the "leaderboardShortCode" is "LB_DAY.day.01-25". Tomorrow it will be "LB_DAY.day.01-26" and so on. This is the best way to implement this system. You'll likely need to change the logic for retrieving the leaderboard's data on the client side to accommodate this.