import { applyStatusEffect, StatBlock } from '@datamoc/mw_games/actors';
import { TurnClock } from '@datamoc/mw_games/world';
const stats = new StatBlock({ base: { hp: 20, attack: 5 } });
const clock = new TurnClock();
const poison = applyStatusEffect(stats, clock, {
modifiers: [{ stat: 'attack', op: 'add', value: -2 }],
duration: 3,
tick: () => stats.setBase('hp', stats.base('hp') - 2),
});
clock.advance(); // one poison tick
poison.cancel(); // a cure spell removes it early
A temporary buff or debuff: applies
modifierstostatsand registers their expiry withclock, so a game never has to remember to remove what it added. The seamTurnClockandStatBlocknever had on their own -TurnClockticks and expires effects,StatBlockresolves modifiers, but nothing tied one's expiry to the other's removal.cancel()on the returned handle removes the modifiers immediately and unregisters the clock entry - needed becauseTurnClock.removealone only stops future ticks, it does not know this entry ever touched aStatBlockat all.