mwg API
    Preparing search index...

    Function rollRoster

    • Rolls a spawn/content roster: the regular entries, then whichever rare additions rolled in, then a per-entry alternative-variant swap over the regular entries only, then (unless disabled) a shuffle - the "add-rare, swap, shuffle" order a variant-spawn table commonly needs. Every roll, including a disabled rare entry's explicit non-roll, is recorded in trace, so two runs against the same seed can be diffed roll for roll rather than only by final roster.

      Type Parameters

      • T

      Parameters

      Returns ContentRollResult<T>

      import { rollRoster } from '@datamoc/mw_games/roguelike';

      const { roster, trace } = rollRoster(
      [{ value: 'rat' }, { value: 'rat', alternative: { value: 'albino rat', chance: 0.02 } }],
      [{ value: 'boss-rat', chance: 0.01 }] // a rare addition, on top of the regulars
      );