# Table Management

### Overview

The **TableManager** is a core component in uVegas that handles **spawning and managing all tables on the server**.\
It is designed to be **generic**, so it can manage different types of table prefabs (Blackjack, Poker, Roulette, and Slots) in a unified way.

***

### How It Works

* The `TableManager` exists as a **singleton network object** in your scene.
* It contains a **list of `TableSpawnData`** entries, each defining:
  * `tablePrefab` – the prefab to spawn (e.g., BlackjackTable, PokerTable)
  * `maxTables` – the maximum number of tables of this type
  * `maxSeats` – number of seats per table
* When the server starts (`OnStartServer`), it **spawns all configured tables** automatically.
* Each table is instantiated, initialized with its seat count, and spawned on the network using **Mirror's `NetworkServer.Spawn`**.
* After spawning, the table is **registered with the `LobbyManager`**, which allows players to see and join it.

***

### Table Prefabs

* Each table prefab must implement the `BaseTable` interface, which handles:
  * Seat allocation
  * Game initialization
  * Player interaction
* You can mix and match **different table types**:
  * Blackjack tables
  * Poker tables
  * Roulette tables
  * Slot machines (based on the same table logic)

***

### Integration with Lobby

* The `LobbyManager` keeps track of all active tables.
* Players use the lobby to **join available tables**, without needing to manually reference the spawned prefabs.
* This ensures **scalable multiplayer table management** and seamless integration with any uVegas game module.

***

> 💡 Tip: Configure your tables in the `TableManager` prefab before starting the server. Each `TableSpawnData` entry allows you to define **how many tables of each type** and **how many seats** each table supports.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uvegas.online/general-features/table-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
