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 Copy
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
Example