-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.d.ts
39 lines (33 loc) · 1.05 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
export default class Lootr {
constructor(name?: string);
clean(path?: string): string;
randomInRange(range: Range): number;
add(item: Item, path?: string): Lootr;
branch(name: string): Lootr;
getBranch(name: string, create?: boolean): Lootr;
allItems(): Item[];
randomPick(allowedNesting: number, threshold?: number): Item;
roll(catalogPath: string, nesting?: number, threshold?: number): Item;
loot(drops: Drop[]): Item[];
setModifiers(modifiers: Modifier[]): void;
addModifiers(modifiers: Modifier[]): void;
modify(item: Item, modifier: Modifier): void;
modifyNameReplace(match: string): string;
}
interface Item {
[key: string]: any;
name: string;
}
interface Drop {
from: string,
depth?: number,
luck?: number,
stack?: number | Range,
modify?: boolean
}
interface Modifier {
[key: string]: string | number | Range | ModifierExpression;
name: string;
}
type Range = `${number}-${number}`;
type ModifierExpression = `+${number}` | `-${number}` | `*${number}` | `/${number}`;