ExPilot.Targets (ExPilot v0.1.1)

Copy Markdown View Source

Targets: the ! tiles a team defends. Each belongs to the team of the nearest base, takes three hits from anything but its own team, and comes back a minute after it is destroyed. Destroying one scores for the shooter's team.

ExPilot.Targets.new(arena)
ExPilot.Targets.hit(targets, cell, team)

Summary

Functions

The cells of targets currently destroyed.

A shot from team hits the target at cell.

A target for every ! on arena, each with its team.

Whether the target at cell stands, so a shot stops there.

Whether team has a target standing.

Let dt seconds pass: destroyed targets come back when their time is up.

Types

target()

@type target() :: %{
  pos: {integer(), integer()},
  team: integer() | nil,
  hits: non_neg_integer(),
  respawn_in: float()
}

Functions

gone(targets)

@spec gone([target()]) :: MapSet.t()

The cells of targets currently destroyed.

hit(targets, cell, team)

@spec hit([target()], {integer(), integer()}, integer() | nil) ::
  {[target()], :none | :hit | {:destroyed, integer() | nil, pos_integer()}}

A shot from team hits the target at cell.

Returns {targets, outcome}: :hit, {:destroyed, team, points} for the shooter's team, or :none when no standing target is there or it is the shooter's own.

new(arena)

@spec new(ExPilot.Map.t()) :: [target()]

A target for every ! on arena, each with its team.

standing?(targets, cell)

@spec standing?([target()], {integer(), integer()}) :: boolean()

Whether the target at cell stands, so a shot stops there.

standing_for?(targets, team)

@spec standing_for?([target()], integer() | nil) :: boolean()

Whether team has a target standing.

step(targets, dt)

@spec step([target()], float()) :: [target()]

Let dt seconds pass: destroyed targets come back when their time is up.