mwg API
    Preparing search index...

    Interface BarrierLayer

    A shield/barrier pool absorbed before HP, decaying on its own each tick unlike a plain StatBlock stat, which only ever changes when something explicitly touches it. Several layers can be held at once - a fresh cast over an older one, a ward stacked on a shield - absorption always drains the most recently added layer first, so a ward cast on top of a standing shield breaks before the shield underneath it does, matching how a layered proc family (barrier-then-shield, shield-then-barrier) is meant to read regardless of order cast.

    import { Barrier } from '@datamoc/mw_games/actors';

    const barrier = new Barrier();
    barrier.add(20); // a shield spell
    barrier.add(10, 2); // a ward on top, decaying 2 per turn on its own

    const absorbed = barrier.absorb(15); // drains the ward first, then spills into the shield
    barrier.advance(1); // one turn of decay
    console.log(barrier.total);
    interface BarrierLayer {
        amount: number;
        decayPerTick?: number;
    }
    Index
    amount: number
    decayPerTick?: number

    how much this layer's amount drops per turn advanced; 0 (the default) never decays on its own