r4nkt
  • Introduction
  • Getting Started
  • Concepts
    • Overview
    • Achievements
    • Actions
    • Activities
    • Badges
    • Criteria
    • Criteria Conditions
    • Criteria Groups
    • Custom Data Reference
    • Games
    • Leaderboards
    • Players
    • Rewards
    • Scores
  • Cookbook
    • Criteria Conditions
    • Achievements
  • API
    • Overview
    • Authentication
    • Achievements
    • Actions
    • Activities
    • Criteria
    • Criteria Groups
    • Leaderboards
    • Players
    • Player Badges
    • Rewards
    • Scores
  • Webhooks
    • Overview
    • Getting Started
    • Events
  • PHP SDK
    • Overview
    • Getting Started
  • Laravel Package
    • Overview
    • Installation
    • Webhooks
Powered by GitBook
On this page

Was this helpful?

  1. Concepts

Custom Data Reference

PreviousCriteria GroupsNextGames

Last updated 3 years ago

Was this helpful?

Custom data references give you much more flexibility and power when it comes to defining your achievements. Using them will allow you to create achievements that:

  • are more dynamic

  • better reflect the domain knowledge of your game

Custom data references can be used in a handful of and can be used to reference custom data on the following entities:

  • action: This refers to the action that is part of the current player activity.

  • activity: This refers to the current player activity.

  • player: This refers to the player that is part of the current player activity.

This is how it works:

  • You report your player activity.

  • R4nkt receives the reported player activity and begins to process it. This is what is considered the current player activity.

  • When applying criteria conditions, any custom data references that are encountered will be replaced with whatever value is found for the current player activity, whether that be the player, the action, or the activity itself.

The custom references themselves work in a fairly straightforward manner. They "reach into" the relevant resource's custom_data value, with each "dot" (.) referring to nested values.

Example

A simple example would be to define an achievement to be awarded whenever certain actions are performed on your player's birthday. Since you have many players, how do you do this?

You would use custom data references, of course:

  • month:{player.birthdate.month}

  • dayOfMonth:{player.birthdate.day}

A full definition would like like so:

{
  "groups": [
    {
      "conditions": [
        "month:{player.birthdate.month}",
        "dayOfMonth:{player.birthdate.day}"
      ]
    }
  ]
}

And your player's custom_data might look like so:

{
  "birthdate": {
    "day": 29,
    "month": 5,
    "year": 1970
  }
}
criteria conditions