Skip to main content

Game Flow

Preparation

Before starting with the normal flow, the game should check if it's in replay mode. In this case, the game should obtain the data from the round to replay instead of following the normal flow.

You have all the information of this special flow here.

Start

Once you have the connector and setup the contract, you can start communication with the connector.

At this point you can specify the listeners:

ETHEREAL.onRequestAudioChange((isEnabled: boolean) => {/** Your code here */);

:::doc More information Check the full list of listeners here :::

You can start notifying events:

ETHEREAL.notifyAudioChange(true);

:::doc More information Check the full list of notifications here :::

Player session

Before doing anything else, you need to obtain the data related to the session of the player:

await ETHEREAL.rgs.open();
Warning

Data related to the game or player will be not available until the open call is made.

Now you have access to the connector data:

let allowAutoplay: boolean = ETHEREAL.data.allowAutoplay();

:::doc More information Check the full list of data here :::

Game init

Receive the initial data from the game engine:

let initResponse: any = await ETHEREAL.rgs.init();
  • This will return the object as specified on the contract element InitResponse

This data will tell you if the game is recovering a round, list of bets allowed, etc.

Play

From this point on, you can do as many plays as needed:

let playResponse: PlayResponse = await ETHEREAL.rgs.play(<playRequest>, <totalBet>);
  • As play request, send an object that matches the element PlayRequest on the contract.
  • As bet use the amount (NOT in currency) used for this play. (Specify the bet even if it's a promotional round)
  • This will return the object as specified on the contract element PlayResponse

Abort play

After requesting a play, the server can return an error (for example, not enough balance to play). The game then must be able to return to the idle state previous to that play.

Add a listener to know when the server request to abort the play:

ETHEREAL.onRequestAbortPlay(() => { /** Your code **/ });
Update the balance

If the game client has deducted the bet from the balance, make sure the balance return to it's correct value checking ETHEREAL.rgs.data.getBalance(); It should be updated automatically if the game client included the API listener to the balance update.

After going back to the idle state, the player can continue playing normally.