mwg API
    Preparing search index...

    Interface EncounterEntry<T>

    A weighted encounter table, checked once per step - what decides that walking through tall grass sometimes meets a wild creature and usually does not, and that a rarer species turns up less often than a common one.

    Built on mwg/core's Random.chance and Random.weighted rather than its own dice, so an encounter roll is seeded and reproducible the same way everything else in a run is.

    import { rollEncounter } from '@datamoc/mw_games/world';

    const grassland = {
    rate: 0.1,
    entries: [{ value: 'rat', weight: 3 }, { value: 'bat', weight: 1 }],
    };

    const encounter = rollEncounter(grassland); // 'rat', 'bat', or null most steps
    interface EncounterEntry<T> {
        value: T;
        weight: number;
    }

    Type Parameters

    • T
    Index
    value: T
    weight: number