Skip to main content
Module

x/fortuna/mod.ts>GachaMachine

Weighted gacha system
Go to Latest
class GachaMachine
import { GachaMachine } from "https://deno.land/x/fortuna@v2.0.3/mod.ts";

A gacha machine for weighted selection.

Constructors

new
GachaMachine(items: GachaData<ItemType>[])

Create a new gacha machine for weighted selection.

Properties

maxTier: number
pool: number[]
totalChance: number

Methods

get(count?): ItemType[]

Roll items from the gacha machine.

getFromTier(tiers: number[], count?): ItemType[]

Roll items from specific tiers.

Static Methods

rollWithBinarySearch<ItemType>(items: ComputedGachaData<ItemType>[], totalChance?: number): ItemType

Roll one item from a pool using binary search. Requires special transformation.

rollWithLinearSearch<ItemType>(choices: GachaChoice<ItemType>[], totalChance?): ItemType

Roll one item from a pool using linear search. Simple and great for smaller pools.