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
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 aStatBlock. 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
fieldsontoitem, remembering each field's prior value (not merely deleting it), and restores exactly that value onceclockexpires the effect orcancel()is called early - the same "never has to remember to remove what it added" guaranteeapplyStatusEffectalready gives aStatBlock.