From a75309bc301fdcab62031289f70b74ce5d5edc88 Mon Sep 17 00:00:00 2001 From: NeTT Date: Sat, 14 Sep 2024 11:36:37 +0530 Subject: [PATCH] update roll --- src/roll.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/roll.ts b/src/roll.ts index 68e1607..fb2a3f3 100644 --- a/src/roll.ts +++ b/src/roll.ts @@ -1,3 +1,30 @@ +/** + * 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. + * ```ts + * 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 + * ``` + * + * ```ts + * 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. + * ``` + * @module + */ + /** One item from a gacha pool */ export type GachaChoice = { result: ItemType; @@ -30,7 +57,6 @@ export type GachaChoice = { * ] * roll(items, 19) // Rolls one item from the list of items, faster because the total chance is known. * ``` - * @module */ export function roll( choices: ItemType[],