Flow Lobbies
off-chain & on-chain combination detailed
Last updated
off-chain & on-chain combination detailed
Last updated
User creates lobby by calling the contract from the game interface
Each lobby is unique. It uses a combination of multiple formulas to generate a random road that is in the set parameters. By doing so, 2 lobbies with exact same input for creation will be different.
Players can pay to enter the lobby using the smart contract by joining the lobby with the id from the game interface
The lobby is in checking state
. It waits to get confirmed on-chain. Till then, for increased security, it cannot be joined, because it may fail before it gets confirmed on-chain.
The game checks the on-chain contract's read-only function that gives a list of the users that paid the entry price. If the read-only of get-score
returns any value it means the join got confirmed for that player on that lobby. After the check confirms, the player can race as many times as he wants before the time of the lobby ends.
The results are published on-chain every 10 minutes ~ 1 stacks block.
A pre-determined formula determines how much in rewards each player receives based on the scores and places they got of their best run in the lobby. Any type of formula can be used, paying only the first 5 or only the first to increase competitiveness, paying everybody in smaller amounts to incentivize participation. We picked one in the middle that rewards the first few places the most, while also sending a piece of the rewards to the other players.