Srd.Rules.Damage (srd_5e v0.2.0)

Copy Markdown View Source

Damage resolution.

Resolves a completed damage roll into a final amount after applying the target's resistances, vulnerabilities, and immunities to the damage type.

Summary

Types

One of the SRD damage types.

A defense a target has against certain damage types. Each is a list of the types it covers: :immune negates, :resist halves, :vulnerable doubles.

The defenses accepted by resolve/3.

t()

The result of resolving damage

Functions

Resolve a damage roll of the given type against a target's defenses.

The SRD damage types.

Types

damage_type()

@type damage_type() ::
  :acid
  | :bludgeoning
  | :cold
  | :fire
  | :force
  | :lightning
  | :necrotic
  | :piercing
  | :poison
  | :psychic
  | :radiant
  | :slashing
  | :thunder

One of the SRD damage types.

option()

@type option() ::
  {:immune, [damage_type()]}
  | {:resist, [damage_type()]}
  | {:vulnerable, [damage_type()]}

A defense a target has against certain damage types. Each is a list of the types it covers: :immune negates, :resist halves, :vulnerable doubles.

options()

@type options() :: [option()]

The defenses accepted by resolve/3.

t()

@type t() :: %Srd.Rules.Damage{
  final: non_neg_integer(),
  raw: non_neg_integer(),
  type: damage_type()
}

The result of resolving damage:

  • :type - the damage type
  • :raw - the amount rolled, before defenses
  • :final - the amount after resistance, vulnerability, or immunity

Functions

resolve(roll, type, opts \\ [])

@spec resolve(Srd.Dice.Roll.t(), damage_type(), options()) :: t()

Resolve a damage roll of the given type against a target's defenses.

Immunity yields no damage, resistance halves it (rounded down), and vulnerability doubles it.

types()

@spec types() :: [damage_type()]

The SRD damage types.