mwg API
    Preparing search index...

    Function assignAppearances

    • Deals each kind a distinct label from a shuffled copy of the pool - pure, so a game that wants the shuffle scoped (one seed per run, say) wraps it in Random.withSeed.

      Parameters

      Returns Map<string, string>

      import { assignAppearances, Appearances } from '@datamoc/mw_games/actors';

      const potions = assignAppearances({ kinds: ['healing', 'poison'], labels: ['red', 'blue'] });
      console.log(potions.get('healing')); // 'red' or 'blue', fixed for this shuffle

      // Appearances wraps this per category, drawing lazily on first ask and caching for the run
      const appearances = new Appearances({ potions: { kinds: ['healing', 'poison'], labels: ['red', 'blue'] } });
      const label = appearances.appearanceOf('potions', 'healing');