# Demo and Real Gameplay

## Gameplay overview

When building an integration with Hub88 you can start with setting up DEMO mode to ensure that all data communication flows correctly.&#x20;

To start setting up the full gameplay, either in **DEMO** mode or **Real** mode, you'll need to meet the prerequisites outlined in [Getting Started](https://docs.hub88.io/developer-docs/operator-api-reference/getting-started) and get acquainted with the API in [Operator API Overview](https://docs.hub88.io/developer-docs/operator-api-reference/operator-api-overview).&#x20;

The gameplay logic will process is as follows with API call modifications needed for [DEMO mode](#demo-gameplay).

{% hint style="info" %}
Note that the process is different for **DEMO** and **REAL** gameplay modes.&#x20;

**In** **DEMO** mode, user can open the game, check the rules/graphics, and play with fun mode money.
{% endhint %}

{% stepper %}
{% step %}
Obtain a game URL from Hub88 by calling [`POST /operator/generic/v2/game/url`](https://docs.hub88.io/developer-docs/games-api#get-a-game-url) .
{% endstep %}

{% step %}
**Direct** the customer to the **URL** **provided** by **Hub88**.
{% endstep %}

{% step %}
Respond to in-game events sent by Hub88 and update the customer's balance (**SEAMLESS WALLET ONLY**)
{% endstep %}
{% endstepper %}

{% hint style="success" %}
**The high level gameplay corresponds to** [**the core communications flow between Supplier and Operator APIs.**](https://docs.hub88.io/developer-docs/hub88-apis/core-api-flow)
{% endhint %}

## Demo gameplay

{% hint style="info" %}
Note that the process is different for **DEMO** and **REAL** gameplay modes.&#x20;

**In** **DEMO** mode, user can open the game, check the rules/graphics, and play with demo mode money.
{% endhint %}

{% stepper %}
{% step %}
**Operator** makes a **Game API** call to [`POST /operator/generic/v2/game/url`](https://docs.hub88.io/developer-docs/games-api#get-a-game-url) to obtain game launch URL.&#x20;

For **DEMO** mode, Operator has to pass `"currency":"XXX"`. \
Parameters `token`, `user` can be **omitted**.
{% endstep %}

{% step %}
When the game URL is returned, the **Operator** uses it to direct the player to the game (for example, launch it in iframe or redirect the player to the URL).
{% endstep %}

{% step %}
In **DEMO** mode, no calls to Operator's API are made because providers handle the balance themselves.\
If player liked the game and wants to switch to **REAL** mode, **Operator** should proceed with the next steps.
{% endstep %}
{% endstepper %}

## Real gameplay

{% stepper %}
{% step %}
The Operator generates and stores a unique game session token.
{% endstep %}

{% step %}
The Operator makes a Game API call [`POST /operator/generic/v2/game/url`](https://docs.hub88.io/developer-docs/games-api#get-a-game-url) and passes the generated token along with the other request parameters.

{% hint style="info" %}
**NB!**: In case of **SEAMLESS WALLET** integration, Operator needs to be ready to respond to balance API calls even before getting the game URL back.
{% endhint %}
{% endstep %}

{% step %}
When the game URL is returned, the Operator uses it to direct the player to the game (for example, launch it in iframe or redirect the player to the URL).
{% endstep %}

{% step %}
{% hint style="info" %}
Following steps are for **SEAMLESS WALLET integration only**. \
\
In case of **Transfer Wallet** integration, all game actions and balance updates will be handled on Hub88 side.
{% endhint %}
{% endstep %}

{% step %}
When the game URL is loaded in the browser, Hub88 server makes a Wallet API call [`/user/balance`](https://docs.hub88.io/developer-docs/wallet-api#post-user-balance) to the Operator's server.
{% endstep %}

{% step %}
The Operator verifies the token against the stored token and returns the user's balance. The user can then place a bet.
{% endstep %}

{% step %}
When the user attempts to place a bet, a Wallet API call [`/transaction/bet`](https://docs.hub88.io/developer-docs/wallet-api#post-transaction-bet) is triggered on the Operator's server.
{% endstep %}

{% step %}
The Operator verifies the token, ensures that the user has enough money for this bet, decreases the user's balance by the bet amount, and returns the updated user's balance.
{% endstep %}

{% step %}
If the user wins, the Wallet API triggers a call [`/transaction/win`](https://docs.hub88.io/developer-docs/wallet-api#post-transaction-win) on the Operator's server.
{% endstep %}

{% step %}
The Operator verifies the token, increases the user's balance by the win amount, and returns the updated user's balance.
{% endstep %}

{% step %}
Behaviour in case of user's loss depends on game provider's internal logic. Possible options:

* Nothing is sent
* Sent win with amount 0
  {% endstep %}
  {% endstepper %}
