import { GachaMachine } from "https://deno.land/x/fortuna@v2.0.3/mod.ts";
Roll one item from a pool using binary search. Requires special transformation.
Examples
Example 1
Example 1
const items = [
{ result: "SSR cool character", cumulativeChance: 1 },
{ result: "Kinda rare character", cumulativeChance: 4 },
{ result: "Mob character", cumulativeChance: 9 },
{ result: "Mob character", cumulativeChance: 14 },
{ result: "Mob character", cumulativeChance: 19 },
]
GachaMachine.rollWithBinarySearch(items) // Rolls one item from the list of items
Supplying totalChance does not affect the execution speed much.
Parameters
items: ComputedGachaData<ItemType>[]
List of items to roll from, each having a result
and cumulativeChance
.