# `Cauldron2D.Drafter.Client.Seats`
[🔗](https://github.com/jaman/cauldron/blob/v0.3.0/cauldron_2d_drafter/lib/cauldron_2d/drafter/client/seats.ex#L1)

The further players a client plays on the same machine, from the game's
`local_seats/1`: each a player of the world with its own keys and its own controller.

A seat is `%{id, input, pad, device, last_input}`, `device` what the seat last played
with: `:keyboard`, or `{:pad, name}` with the name its controller connected under. Seats join the world with `frames: false`,
so the client receives frames only as its own player; each key event reaches every
seat's input and counts where that seat's keymap binds it; a controller event reaches
the one seat it is routed to. `send_input/3` sends a seat's input only when it changed.

# `seat`

```elixir
@type seat() :: %{
  id: String.t(),
  input: Cauldron2D.Input.t(),
  pad: Cauldron2D.Input.Pad.t(),
  device: :keyboard | {:pad, String.t() | nil},
  last_input: map() | nil
}
```

# `controller`

Seat `index` (counting from `0`) after a controller event.

# `expire`

```elixir
@spec expire([seat()], integer()) :: [seat()]
```

Every seat's input with its timed holds expired at `now`.

# `join`

```elixir
@spec join(
  GenServer.server(),
  String.t(),
  map(),
  [Cauldron2D.Input.keymap()],
  Cauldron2D.Input.Pad.padmap(),
  keyword()
) :: [seat()]
```

The seats `keymaps` describe, joined to `world` as `"<username> 2"` and on. A seat
the world refuses is left out. `props` are the player's own join props, given to each
seat with its own `:username` and with `:seat_of`, the player's own username, so the
world can tell whose seat it is; `input_options` are those of the player's own input.

# `key`

```elixir
@spec key([seat()], term(), integer()) :: [seat()]
```

Every seat's input after a key or pointer event at `now`; a seat whose keymap binds
the key plays with the keyboard from then on.

# `keyed?`

```elixir
@spec keyed?(Cauldron2D.Input.t(), term()) :: boolean()
```

Whether the key event `event` is one `input` binds.

# `leave`

```elixir
@spec leave([seat()], GenServer.server()) :: :ok
```

Every seat out of `world`.

# `pad_device`

```elixir
@spec pad_device(:keyboard | {:pad, String.t() | nil}, map(), String.t() | nil) ::
  :keyboard | {:pad, String.t() | nil}
```

The device after controller event `event` from the controller named `name`: that controller, unless the event is its going away.

# `release`

```elixir
@spec release([seat()], [Cauldron2D.Input.keymap()], keyword()) :: [seat()]
```

Every seat holding nothing, its keys read by the keymap it had.

# `send_input`

```elixir
@spec send_input([seat()], GenServer.server(), (map() -&gt; map())) :: [seat()]
```

Every seat whose input changed sent to `world`, its read input passed through `steer`
first, as the client steers its own player's.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
