mwg API
    Preparing search index...

    Type Alias AffixTrigger

    AffixTrigger: "strike" | "defend" | "passive"

    Named item affixes: enchantments, glyphs, augments, curses - whatever a game's items can carry beyond their upgrade level.

    mwg draws the line ItemState already drew: level is 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 a passive that 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 way Move.effects is data mwg never reads.

    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);