ships.Function.mapDamageTypes - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki

@elite-dangerous-almanac/core / ships / mapDamageTypes

Function: mapDamageTypes()

mapDamageTypes(value): DamageTypeValues

Defined in: src/ships/resistances.ts:133

Build a DamageTypeValues by calling value once per damage type.

Parameters

value

(type) => number

Called with each damage type in turn; returns that type's figure.

Returns

DamageTypeValues

The four figures in one record.

Remarks

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.

Example

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]));
⚠️ **GitHub.com Fallback** ⚠️