Game Balancing
The Spil Games platform makes use of configuration files to support the dynamic balancing of your games. These are JavaScript Object Notation (JSON) files that allow you to change all required parameters in a human-readable format without updating the published game.
The parameter configuration requirements are identified and agreed between the game’s designers and the Spil Games Account Manager. Once finalized, they are communicated to the game’s developers. A default JSON is provided as part of the Spil Games SDK. After publication, the configuration file is maintained by Spil Games LiveOps.
Best Practice
We recommend the following:
- Balancing issues are best left until you have a good set of game core mechanics.
- Pricing should not be managed using the game configuration file. Generally, this is better managed through the shop features. For more information, see “Supporting Wallet, Shop and Inventory Control”.
Understanding How It Work
Your game should start by it requesting the latest version of the configuration file. The Spil Games SDK will try to retrieve this from the Spil Games back-end server. If there is no network connection, the Spil Games SDK will fall back to its last known version. The configuration file and all its parameter values can be managed using SLOT (Spil Games Live Operations Tool). The procedure and requirements for this are described in the rest of this chapter.
Requesting a Configuration File
The Spil Games SDK provides two methods for retrieving a game’s configuration file from the Spil Games server. You can retrieve the entire file using the following code:
Parsing the JSON Configuration File
You can use the following methods for working with the Game Config:
The Spil Games Unity SDK also includes methods for converting JSON strings to objects via the SpilGames.Unity.JSON.JSONHelper method.
Important
The configuration service should always return a value. However, if, for any reason, it does not, ensure that you check and handle a possible null return.
Listening for Updates to the Configuration File
By default, game configuration calls will always return the last saved value. However, it is also possible to listen for configuration updates, which often happen in a background process, using the OnConfigUpdated event. After receiving the update, you can refresh the user interface and game state. Use the following code.
Implementing a Default Configuration File
If there is no network connection, the Spil Games SDK will use a default configuration file. In addition, users might open the app for the first time and not have an Internet connection. For those situations, a default configuration file called “defaultGameConfig.json” needs to be added to your project’s root folder. The following is an example of a simple configuration file for the game Pixel Wizard.
Using Firebase Remote Config
The Spil SDK offers the possibility to work with the Firebase Remote Config. For Android, you need to make sure that the Firebase module is included. For more information on how to set up the values in Firebase, check the following link:
https://firebase.google.com/docs/remote-config/
In order to work with the Firebase Remote Config directly through the Spil SDK, use the following methods and callbacks: