Skip to content

Commit

Permalink
update roll
Browse files Browse the repository at this point in the history
  • Loading branch information
retraigo committed Sep 14, 2024
1 parent f7877c2 commit a75309b
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/roll.ts
Original file line number Diff line number Diff line change
@@ -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<ItemType> = {
result: ItemType;
Expand Down Expand Up @@ -30,7 +57,6 @@ export type GachaChoice<ItemType> = {
* ]
* roll(items, 19) // Rolls one item from the list of items, faster because the total chance is known.
* ```
* @module
*/
export function roll<ItemType>(
choices: ItemType[],
Expand Down

0 comments on commit a75309b

Please sign in to comment.