Skip to content

Step 4: Place bets and collect

Your session is up and the config is loaded. Now the round loop needs two more calls. placeBet starts or continues a round. collect banks winnings when the game offers that choice.

What to do

  1. Call placeBet({ backendURL, token, stake, config }) with a stake from config.stakes. The result carries scenario (your game-specific outcome data), totalWin, and engineData.
  2. Render the round from scenario. Its contents depend on your game type: a slot board, a plinko bucket, or a Hi/Lo card, for example.
  3. Check engineData.inProgress. If it is set, the round has more steps. Call placeBet again to continue it. Pass any additionalData or playerChoice that step needs.
  4. Check engineData.canCollect. If it is set, the player can bank what they have won. Call collect({ backendURL, token }).
  5. Handle failures. Do not assume success. Some error codes are recoverable and you should retry them. Others end the round.

TIP

Do you want to test a specific outcome, such as a big win, a bonus trigger, or a bust, instead of waiting on real RNG (random number generation)? See Cheating.

Where to read more

  • Getting Started with hizi engine SDK: steps 4 to 6 of the quick start cover placeBet, multi-step rounds, and collect.
  • Game Flow: one worked, class-based implementation of the whole round lifecycle. Use it as a model for your client.
  • Response Handling: the IGameResult shape, multi-step continuations, and progression counters.
  • Error Handling: the response union, recoverable error codes, and what to do with each.
  • Game Guides: the scenario shape for each game type, and any additionalData that type's rounds need.

Next: Step 5: Implement the Operator Interface.