springroll.WeightedRandom Class

Module: Core

A class for generating weighted random values. Input objects are dictionary objects where the keys are the strings to be picked from, and the values are the corresponding odds as integers. For example:

{ itemWith25PercentChance: 2, itemWith50PercentChance: 4, otherItemWith25PercentChance: 2 }

Constructor

springroll.WeightedRandom

(
  • object
)

Parameters:

  • object Object

    The configuration object for this weighted value generator.

Methods

random

() String

Defined in random:38

Picks an item at random.

Returns:

String:

The randomly chosen value.