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.
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.