Game Settlement Concept
Understanding Game Settlement: Optimizing In-Game Transactions
Last updated
Understanding Game Settlement: Optimizing In-Game Transactions
Last updated
Before implementing the GameSettle API, let's start with a basic concept of game settlement. Imagine you want to develop a simple card game where four players participate.
Each player needs to spend 100 vZOO to join the game, resulting in a total of 400 vZOO in the game pool. At the end of the game, the winner receives 200 vZOO, the second-place player receives 150 vZOO, the third-place player receives 50 vZOO, and the fourth-place player receives nothing. You can use the game settlement API to broadcast the vZOO rewards each player has obtained.
In the game lobby, Player #1 joins. The game server calls the "Game/Ready" API to check Player #1's vZOO balance. If the balance is sufficient, the player is verified and remains in the lobby. If not, the player is kicked out.
Player #2 joins but doesn't have enough vZOO to play. The game server removes this player from the lobby.
Players #3, #4, and #5 join with sufficient vZOO to play.
With four players ready, the game server calls the "Game/Start" API to initiate the game. This API transfers their 100 vZOO to the locked vZOO pool, totaling 400 vZOO.
After gameplay, the final vZOO amounts for each player are as follows:
Player #3 (Winner): 200 vZOO
Player #4 (Second place): 150 vZOO
Player #1 (Third place): 50 vZOO
Player #5: 0 vZOO
The game server needs to call the "Game/Over" API with the round ID and provide the player reward information in the order they entered (from "Game/Start"), such as [50, 200, 150, 0].
If you want to receive a fee from each game, for example, 5%, you can deduct this percentage from what each player receives.
After the gameplay, the final vZOO amounts for each player are as follows:
Player #3 (Winner): 200 vZOO
Player #4 (Second place): 150 vZOO
Player #1 (Third place): 50 vZOO
Player #5: 0 vZOO
To calculate the developer fee, deduct 5% from each player's amount:
Player #1: 49 vZOO (2.45 vZOO as dev fee)
Player #3: 196 vZOO (9.8 vZOO as dev fee)
Player #4: 147 vZOO (7.35 vZOO as dev fee)
Player #5: 0 vZOO (0 vZOO as dev fee)
The total developer fee is 19.6 vZOO, and the final broadcast amounts become [46.55, 186.2, 139.65, 0]. The game server simply calls the "Game/Over" API with the new final broadcast [46.55, 186.2, 139.65, 0] and provides the gameResultAmount as 19.6.
If you want to offer additional vZOO as promotional rewards to encourage users to play your game, you can top-up the locked vZOO pool. Assuming you want to support an extra 100 vZOO for each game, with four players ready to start the game, the game server can call the "Game/Start" API with a gameLockAmount of 100 vZOO. The total locked vZOO in the pool will then be 500 vZOO. After gameplay, the final vZOO amounts for each player are as follows:
Player #3 (Winner): 200 vZOO + 50 vZOO (extra)
Player #4 (Second place): 150 vZOO + 40 vZOO (extra)
Player #1 (Third place): 50 vZOO + 10 vZOO (extra)
Player #5: 0 vZOO
The game server needs to call the "Game/Over" API with the round ID and provide the player reward information in the order they entered (from "Game/Start"), such as [60, 250, 190, 0]. Each reward amount should be reduced by the platform fee (assumed to be 2%). Therefore, the final broadcast amounts will be [58.8, 245, 186.2, 0].
You can also adjust the developer fee in this section. However, ensure that the total paid amount plus the platform fee is less than the total locked vZOO in the pool. From the game server side, you have the flexibility to mix and match these concepts as desired.