# Game configuration and catalog exports

The `@skyla/original-games` package now ships with the canonical game catalog
and configuration helpers that power the legacy Skyla backend. Host
applications can reuse these assets without duplicating files from
`backend/Games` or `backend/config`.

## Game catalog

```js
const OriginalGames = require('@skyla/original-games');

console.log(OriginalGames.gameCatalog); // Array of game definitions and cover assets
```

The exported catalog is a direct copy of `backend/Games/list.js`, ensuring the
frontend, backend, and any host platform reference the same IDs, prefixes, and
image paths.

## Default configuration

The package resolves a configuration object at `OriginalGames.config`. It
contains the developer defaults that previously lived in `backend/config.js`
(house edge, bankroll seed balances, empty wallet templates, bot limits, and
asset base URLs).

```js
const OriginalGames = require('@skyla/original-games');

OriginalGames.config.house;      // => 2 (default house edge)
OriginalGames.config.BotsLimit;  // => 80 seeded bots per cycle
OriginalGames.config.avatarUrl;  // => http://localhost:3005/uploads/
```

## Environment overrides

Hosts can override any of the values above by supplying environment variables
*before* the package is imported. Supported keys are:

| Variable | Purpose |
| --- | --- |
| `ORIGINAL_GAMES_DEVELOPER` | Toggle developer tooling (`true`, `false`, `1`, `0`). |
| `ORIGINAL_GAMES_HOUSE_EDGE` | House edge percentage used by all games. |
| `ORIGINAL_GAMES_BOT_LIMIT` | Maximum number of simultaneously seeded bots. |
| `ORIGINAL_GAMES_ASSET_URL` | Absolute base URL that hosts avatar and cover assets. |
| `ORIGINAL_GAMES_DEV_PORT` | Optional port used to derive the default `avatarUrl` when running locally. Falls back to `PORT` or `3005`. |
| `ORIGINAL_GAMES_BALANCE` | JSON object describing the starting bankroll per currency. |
| `ORIGINAL_GAMES_WALLET` | JSON object describing the empty wallet template for new users/bots. |

Invalid values throw descriptive errors so misconfigurations are caught during
service start-up.

## Programmatic overrides / dependency injection

If environment variables are not desirable, hosts can supply overrides at
runtime. The helper mirrors the developer defaults and merges nested wallet
objects so only customised keys need to be provided.

```js
const OriginalGames = require('@skyla/original-games');

OriginalGames.setGameConfig({
  house: 1.5,
  avatarUrl: 'https://cdn.example.com/uploads/',
  BotsLimit: 120,
  BALANCE: { usdt: '1000.00000000' },
});
```

`setGameConfig` mutates the shared configuration instance so any previously
required modules (including the legacy backend) observe the new values.

For finer control, `createGameConfig` accepts the same options but returns a new
object without mutating the singleton. This is useful for unit tests or
stateless workers.

```js
const { createGameConfig } = require('@skyla/original-games');

const config = createGameConfig({ overrides: { house: 1.25 } });
```

## Production guidance

1. Define the relevant `ORIGINAL_GAMES_*` environment variables as part of your
   service deployment or secret management layer.
2. Alternatively, call `OriginalGames.setGameConfig()` during bootstrap with
   values fetched from your configuration service.
3. Ensure the asset URL points to a CDN or object storage bucket that exposes
   the `/assets/images/...` tree shipped with the games package.

Following the steps above keeps game odds, bankroll controls, and media assets
synchronised across every host that integrates the original Skyla games.
