Skip to content

$this->bga->tableOptions

Read values configured in gameoptions.jsonc and information about the current table.

API

get(int $optionId): ?int

Read a table option by its configuration ID in the range 100-199. Returns null when the option does not exist, such as at a table created before that option was introduced.

set(int $optionId, int $value): void

Update an option after resolving a random option to a concrete value. Use this to keep the displayed table option consistent with the chosen variant. Both the option ID and the selected value must exist in the configuration; an invalid ID or value causes an exception.

isTurnBased(): bool

Return whether the table uses turn-based play.

isRealTime(): bool

Return whether the table uses real-time play.

getGameVersion(): int

Return the game version used by this table.

getGameLanguage(): ?int

Return the selected language index from gameinfos, or null if the game has no game languages.

Example

$variant = $this->bga->tableOptions->get(100);
if ($this->bga->tableOptions->isTurnBased()) {
    // Apply any rules specific to turn-based play.
}

Missing options and random choices

Tables created before a new option was added may have no value for it. Choose a fallback explicitly:

$variant = $this->bga->tableOptions->get(104) ?? 1;
$expansionEnabled = $this->bga->tableOptions->get(100) === 1;

For a random option, resolve the random choice in your game logic, then publish the concrete configuration value:

$this->bga->tableOptions->set(100, $selectedValue);

Do not read framework-owned numeric globals as if they were table options. In particular, replace reads of 200 with isTurnBased or isRealTime, 207 with getGameLanguage, and 300 with getGameVersion.

Language-dependent games

Define language_dependency in gameinfos when the rules require players to share a language or select language-specific content. A map restricts play to the supported languages and assigns each one an index:

gameinfos.jsonc
"language_dependency": { "1": "en", "2": "fr" }
$languageIndex = $this->bga->tableOptions->getGameLanguage();
// 1 selects English content; 2 selects French content in this configuration.

false or an omitted setting means no language restriction. true requires a common language without providing a fixed list of supported languages. The index is a game configuration value, not the language of the current player's interface. See Language dependency for the configuration reference.