mwg API
    Preparing search index...

    Function rollLoot

    • Parameters

      Returns { id: string; quantity: number } | null

      what dropped, or null when the roll misses or the table is empty

      import { rollLoot, type LootTable } from '@datamoc/mw_games/actors';

      const ratLoot: LootTable = {
      chance: 0.5,
      entries: [{ id: 'gold', weight: 3, quantity: 5 }, { id: 'cheese', weight: 1 }],
      };

      const drop = rollLoot(ratLoot); // { id: 'gold', quantity: 5 }, or null, most of the time