Cosmos Journeyer API Documentation - v1.10.1
    Preparing search index...

    Function wheelOfFortune

    • A useful function to randomly choose an option from a list of options, each option having a weight.

      Type Parameters

      • T

      Parameters

      • options: [T, number][]

        An array of tuples, each tuple being an option of type T and its weight. (The weights don't have to add up to 1.0, they are normalized internally.)

      • randomValue: number

        A random value between 0.0 and 1.0 that you can provide with any random number generator of your choice.

      Returns T

      The chosen option.

      An error if the wheel of fortune failed. (This should never happen.)