ExPilot.Arenas (ExPilot v0.1.1)

Copy Markdown View Source

ExPilot's arenas on Cauldron2D.Arenas: a map each, its world an ExPilot.Game, its robots (ExPilot.Robot) and its ledger recorder seated beside it.

:ok = ExPilot.Arenas.register(:dogfight, "priv/maps/dogfight.map.gz")
ExPilot.Arenas.list()
Cauldron2D.Player.join(ExPilot.Arenas.world_name(:dogfight), "alice", %{})

The map of a registered arena is kept under its name for the clients to draw from; map/1 reads it, adopt/2 keeps a map that came from another node. Everything else — starting on the first join, stopping when idle, humans/1, running/1 — is Cauldron2D.Arenas's.

Summary

Functions

Keep arena as the map called name, for a client on another node whose worlds run there; map/1 finds it.

Stop arena id and remove it from the list.

The players in arena id who are not robots; [] while it is not running.

Every registered arena, as the lobby lists them, with the humans in each and its mode beside the kind.

The map a registered arena plays on, by the map's name.

Register arena id and start its world and robots at once.

Make arena id known, on the map at path (or an ExPilot.Map), without starting it.

The map name and tick rate arena id was registered with, for an arena cut from the same map; nil for an unknown id.

Whether arena id's world is running.

Stop arena id's world and robots, keeping it registered; close/1 removes it.

The name of arena id's world; using it starts the world when it is not running.

Types

id()

@type id() :: atom()

Functions

adopt(name, arena)

@spec adopt(String.t(), ExPilot.Map.t()) :: :ok

Keep arena as the map called name, for a client on another node whose worlds run there; map/1 finds it.

close(id)

@spec close(id()) :: :ok

Stop arena id and remove it from the list.

humans(id)

@spec humans(id()) :: [term()]

The players in arena id who are not robots; [] while it is not running.

list()

@spec list() :: [Cauldron2D.Client.Game.arena()]

Every registered arena, as the lobby lists them, with the humans in each and its mode beside the kind.

map(name)

@spec map(String.t()) :: ExPilot.Map.t() | nil

The map a registered arena plays on, by the map's name.

open(id, path_or_map, opts \\ [])

@spec open(id(), Path.t() | ExPilot.Map.t(), keyword()) ::
  {:ok, pid()} | {:error, term()}

Register arena id and start its world and robots at once.

register(id, path_or_map, opts \\ [])

@spec register(id(), Path.t() | ExPilot.Map.t(), keyword()) :: :ok | {:error, term()}

Make arena id known, on the map at path (or an ExPilot.Map), without starting it.

Options

  • :robots — how many robots to seat, never more than the map's bases less one for every human in it and one to spare. Default: the map's maxrobots
  • :hz — the world's tick rate. Default 50
  • :seed, :lives, :only, :first_to — the game's, as ExPilot.Game.init/1 takes them
  • :note — what the lobby says of the arena. Default: its size and robots
  • :mode — its kind in the lobby. Default: ExPilot.Game.mode/1 of the map

registration(id)

@spec registration(id()) :: %{map: String.t(), hz: pos_integer()} | nil

The map name and tick rate arena id was registered with, for an arena cut from the same map; nil for an unknown id.

running?(id)

@spec running?(id()) :: boolean()

Whether arena id's world is running.

stop(id)

@spec stop(id()) :: :ok

Stop arena id's world and robots, keeping it registered; close/1 removes it.

world_name(id)

@spec world_name(id()) :: GenServer.name()

The name of arena id's world; using it starts the world when it is not running.