import { rollAffix, applyAffix, affixOf, removeAffix, copyAffix, matchesContext, type AffixTable } from '@datamoc/mw_games/actors';
const table: AffixTable = { entries: [{ id: 'flaming', trigger: 'strike', weight: 1, kinds: ['melee'] }] };
const sword = { id: 'sword', quantity: 1 };
const betterSword = { id: 'sword', quantity: 1, instanceId: 'b' };
const affix = rollAffix(table);
if (affix) applyAffix(sword, affix);
console.log(affixOf(sword)); // 'flaming'
if (affix && matchesContext(affix, { trigger: 'strike', kind: 'melee' })) {
console.log('flaming affix fires on this melee hit');
}
copyAffix(sword, betterSword); // carries the enchantment onto an upgraded item
removeAffix(sword);
Named item affixes: enchantments, glyphs, augments, curses - whatever a game's items can carry beyond their upgrade
level.mwgdraws the lineItemStatealready drew:levelis a number any item can have, but what "+1 blazing" means is a game's own design. An affix definition therefore carries only the routing information every such system shares - which trigger it answers to (strike,defend, or apassivethat is always on), how likely it is relative to its table, and whether it is a curse - and the game interprets the id itself when that trigger fires, the same wayMove.effectsis datamwgnever reads.