Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fortuna/src/roll.ts

A TypeScript module for random events and gacha.
Latest
import * as fortuna from "https://deno.land/x/fortuna@v4.1.4/src/roll.ts";

Roll one item from a pool using linear search. Simple and great for one-time use pools. Use GachaMachine if you will be picking multiple items from the same pool.

const items = [
  { result: "SSR cool character", chance: 1 },
  { result: "Kinda rare character", chance: 3 },
  { result: "Mob character", chance: 5 },
  { result: "Mob character", chance: 5 },
  { result: "Mob character", chance: 5 },
]
roll(items) // Rolls one item from the list of items
const items = [
  { result: "SSR cool character", chance: 1 },
  { result: "Kinda rare character", chance: 3 },
  { result: "Mob character", chance: 5 },
  { result: "Mob character", chance: 5 },
  { result: "Mob character", chance: 5 },
]
roll(items, 19) // Rolls one item from the list of items, faster because the total chance is known.

Functions

Roll one item from a pool using linear search. Simple and great for one-time use pools. Use GachaMachine if you will be picking multiple items from the same pool.

Type Aliases

One item from a gacha pool