How it works ?
Diagram of the flow
When a player wants to play a game, player sends room amount and RNG contract address. If there is no room with this RNG and room amount new room has been created. And player becomes Creator.
If there is an open room already playerjoins to that room and becomes Opponent and randomness will be requested from the desired RNG Source.
Player can also join an already open room and becomes Opponent.
If player is creator and there is no opponent in the game, player can cancel the game. Cancelling the game results in a %100 refund of the tokens.
Also if a game not results in a while, deployer can cancel that room. This operation also results in a %100 refund of the tokens to the players.
When randomness request resulted, triggerer or keeper will call this function to calculate the winner and forward the bet amounts. Calculation and forwarding the funds executes on-chain contracts.
When a game starts, player's bet amounts will held in a vault contract. When a game resulted (cancellation or finished) vault move the bet amounts to the corresponding players.
RNG source is a smart contract that provides randomness for games.