mwg API
    Preparing search index...

    Function applyItemStatusEffect

    • A temporary status on an item itself - a weapon coated in poison for a fixed number of turns, a shield reinforced until it wears off, a ring blessed only "for this floor" - the item-targeted counterpart to applyStatusEffect, which only ever targets a StatBlock. Today's item-level fields (cursed, blessed, level, affix) are all permanent until a game explicitly changes them; this is what expires one instead.

      Applies fields onto item, remembering each field's prior value (not merely deleting it), and restores exactly that value once clock expires the effect or cancel() is called early - the same "never has to remember to remove what it added" guarantee applyStatusEffect already gives a StatBlock.

      Type Parameters

      • T extends object

      Parameters

      Returns ItemStatusEffectHandle

      import { applyItemStatusEffect } from '@datamoc/mw_games/actors';
      import { TurnClock } from '@datamoc/mw_games/world';

      const sword = { id: 'sword', quantity: 1, blessed: false };
      const clock = new TurnClock();

      const blessing = applyItemStatusEffect(sword, clock, { fields: { blessed: true }, duration: 3 });
      clock.advance(3); // blessed reverts to false automatically
      blessing.cancel(); // or end it early