Skip to content

Data Scheme

During the Deploy, Balancy generates JSON files and uploads them to our CDN. For each template, we create an individual file with the version suffix.

The main file, where you can find the latest versions for all the JSON, is located here:

https://cdn.unnychat.com/entities/{game_id}/{environment}/versions.json
Parameter Description
{game_id} guid of your game; You can find it the dashboard
{environment} Environment: dev, stage, production

For example, if you deployed from the DEV environment for the game with guid 11111111-1111-1111-111111111111, then the address of your versions file is next:

https://cdn.unnychat.com/entities/11111111-1111-1111-111111111111/dev/versions.json

Versions File Structure

{
    "dictionaries": [
        {
            "version": "3",
            "name": "EnemyInfo",
            "id": "10587"
        },
        {
            "version": "5",
            "name": "DamageInfo",
            "id": "12"
        }
    ]
}

The key dictionaries value contains the list of all the templates' info.

Key Description
version the latest version of the template; the version increases only if there are any changes in the template itself or any of its documents
name Name of the Template
id System information. Never changes compared to the name

The link to the EnemyInfo data will be available at:

https://cdn.unnychat.com/entities/11111111-1111-1111-111111111111/dev/EnemyInfo_v3.json

Template Data File Structure

{
    "list": []
}

The value by the key list contains the list for all the documents of the current Template. Each document contains all the parameters by name and some system information. For example:

{
    "list": [
        {
            "unnyId": "3398",
            "unnyIdDamageInfoOfEnemy": "122",
            "probabilityInt": 1,
            "probabilityFloat": 1.2,
            "stringParam": "test",
            "count": {
                "unnyId": "3399",
                "min": 1,
                "max": 1
            },
            "limitedBool": true,
            "myEnum": 1
        }
    ]
}
  1. Each document has its unique unnyId. Balancy generates it and never changes.
  2. Simple types are stored by the parameter Name (in camelCase). For ex: "stringParam": "test".
  3. Enum stored by its int value.
  4. Reference types (Document or List of Documents) have a harder logic. The key of such parameters has the prefix unnyId. For example, parameter DamageInfoOfEnemy is stored in JSON as unnyIdDamageInfoOfEnemy. The value contains the unnyId of the reference. In our example, the reference is to the Document from DamageInfo, which currently has version 5. It means that you can find the document with the unnyId = 122 in the JSON file, located at this address: https://cdn.unnychat.com/entities/11111111-1111-1111-111111111111/dev/DamageInfo_v5.json.
  5. Component types work the same as Documents from p.4.
  6. Injected Component is being injected into the value. They don't generate an additional JSON file. In our example, parameter Count.

Examples

Offer Data

Let's say you have an offer.

Game offers

With store item.

Store items

Store item has Reward parameter. It consists of documents of Item template and their child templates.

In this example we use two items in Reward:

  1. Document of LiveOps Item template.

    Items 2. Item of MyItem template which has LiveOps Item template as a parent.

    My items

Now you want to get information about offers and rewards data in it.

  1. Get GameOffer template version from versions file.

    Items

  2. Now you can download offers data using the link https://cdn.unnychat.com/entities/11111111-1111-1111-111111111111/dev/SmartObjects.GameOffer_v15.json. It will have the list of offers. In our example only one offer.

    Items

    Get store item id from here (parameter unnyIdStoreItem: "3744");

  3. Get StoreItem template version from versions file.

    Items

  4. Download store items using the link https://cdn.unnychat.com/entities/11111111-1111-1111-111111111111/dev/SmartObjects.StoreItem_v17.json. It will have one store item with unnyId 3744 from .2. It has reward field with items field in it. In our example we have two rewards.

    Items

    Get unnyIdItem param value of these rewards: 3517 and 3749.

  5. Get Item template version from versions file.

    Items

  6. Download items using the link https://cdn.unnychat.com/entities/11111111-1111-1111-111111111111/dev/SmartObjects.Item_v13.json. It will have one item with unnyId 3517 from .4

    Items

    You can get all needed reward parameters from here.

  7. Same for your custom templates which has Item template as parent. In our example it's MyItem template. Get its version from versions file.

    Items

  8. Download my items using the link https://cdn.unnychat.com/entities/11111111-1111-1111-111111111111/dev/MyItem_v13.json. It will have one item with unnyId 3749 from .4

    Items

    You can get all needed reward parameters from here. In our custom template we have additional parameter AdditionCoins, and it has value 11.

Code Generator

You can study the code generated by Balancy to understand how everything works.

  1. At launch, it downloads the Version file.
  2. Compares the remote Version file with the cached one.
  3. If any of the Template JSON files were changed, we downloaded and cached the newest versions.
  4. Then all the JSON files are read, mapped to the classes, and added to Global Dictionary by the key unnyId.
  5. All the links are resolved from the Global Dictionary when requested.