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
}
]
}
- Each document has its unique
unnyId
. Balancy generates it and never changes. - Simple types are stored by the parameter Name (in camelCase). For ex: "stringParam": "test".
- Enum stored by its int value.
- 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 theunnyId
=122
in the JSON file, located at this address:https://cdn.unnychat.com/entities/11111111-1111-1111-111111111111/dev/DamageInfo_v5.json
. - Component types work the same as Documents from p.4.
- 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.
With store item.
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:
-
Document of LiveOps Item template.
2. Item of MyItem template which has LiveOps Item template as a parent.
Now you want to get information about offers and rewards data in it.
-
Get GameOffer template version from versions file.
-
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.Get store item id from here (parameter
unnyIdStoreItem: "3744"
); -
Get StoreItem template version from versions file.
-
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 unnyId3744
from .2. It has reward field with items field in it. In our example we have two rewards.Get unnyIdItem param value of these rewards:
3517
and3749
. -
Get Item template version from versions file.
-
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 unnyId3517
from .4You can get all needed reward parameters from here.
-
Same for your custom templates which has Item template as parent. In our example it's MyItem template. Get its version from versions file.
-
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 unnyId3749
from .4You 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.
- At launch, it downloads the Version file.
- Compares the remote Version file with the cached one.
- If any of the Template JSON files were changed, we downloaded and cached the newest versions.
- Then all the JSON files are read, mapped to the classes, and added to Global Dictionary by the key
unnyId
. - All the links are resolved from the Global Dictionary when requested.