ships.Function.mapDamageTypes - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki
@elite-dangerous-almanac/core / ships / mapDamageTypes
mapDamageTypes(
value):DamageTypeValues
Defined in: src/ships/resistances.ts:133
Build a DamageTypeValues by calling value once per damage type.
(type) => number
Called with each damage type in turn; returns that type's figure.
The four figures in one record.
Every DamageTypeValues this module, ./shields and ./armour return is
assembled here, so the four names are written out once rather than at each site that
fans out over them.
import { mapDamageTypes } from '@elite-dangerous-almanac/core/ships/resistances';
import type {
DamageResistances,
DamageTypeValues,
} from '@elite-dangerous-almanac/core/ships/resistances';
declare const incoming: DamageTypeValues; // the resistible share of incoming damage
declare const shields: DamageResistances;
// What each type actually lands, the resistances having taken their share.
mapDamageTypes((type) => incoming[type] * (1 - shields[type]));