Include the SDK
nl-game-sdk.js in the game package when you pack it. Type definitions are in index.d.ts in the package.
Conventions
- Async methods return a Promise with a default timeout of 5 seconds. Methods that wait for the user have no timeout:
energy.requestPayment,energy.deposit,energy.withdraw,energy.claimDaily,energy.confirmStake,share.invite,auth.login. - On failure the Promise rejects with an
NLErrorwhosecodeis one of the following:
nl.system.getInfo().capabilitieslists the methods the current host actually supports. Use it to decide on fallbacks.
Startup
System
UI
Lifecycle
When the game goes to the background (
pause), pause timers and stop background music.
Audio
The app uses native audio, and the host handles the mute switch and call interruptions. The web version uses Web Audio, which unlocks after the first tap.
Haptics
Haptics fire at most once every 50 milliseconds, and extra calls are dropped. The web version uses
navigator.vibrate and skips silently where iOS Safari does not support it.
Identity
When the user is signed out, the first two methods return
AUTH_REQUIRED. In the app, the host prompts the user to sign in and reloads the game afterward. In the web version, if there is no token, the SDK redirects the whole page to the forum authorization page. On first use, the user confirms they are 18 or older and grants authorization.
Game energy
The game energy scopes are
game.energy.read, game.energy.stake, and game.energy.pay; the last two include read access. claimDaily, deposit, and withdraw open a host panel where the user chooses the amount.
Wallet:
{id, createdAt, kind, label, amount, balanceAfter, withdrawableDelta, withdrawableAfter, game, roomId?, orderId?}. label is already translated into the user’s language. A positive amount is income. A game of null means an entry of the wallet itself (deposit, withdrawal, claim). A nextCursor of null means there are no more entries. By default only this game’s entries and the wallet’s own entries are listed; allGames is available only in the app.
kind can be deposit, withdraw, daily_grant, relief_grant, stake_hold, stake_release, win, loss, bot_win, bot_loss, rake_burn, cap_burn, ticket, prize, bonus, item, refund.
See Game energy and payments for rules and limits.
Sharing
Debugging and configuration
The host reports startup time, crashes, frame rate, and connection quality automatically. The game does not need to handle them.
