@allemandi/gacha-engine 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +57 -2
- package/package.json +3 -2
- package/dist/gacha-engine.d.ts +0 -33
- package/dist/types.d.ts +0 -21
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface GachaItem {
|
|
2
|
+
name: string;
|
|
3
|
+
weight: number;
|
|
4
|
+
rateUp?: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface RarityInput {
|
|
7
|
+
rarity: string;
|
|
8
|
+
items: GachaItem[];
|
|
9
|
+
}
|
|
10
|
+
/** Weighted mode requires explicit rarityRates */
|
|
11
|
+
interface WeightedGachaEngineConfig {
|
|
12
|
+
mode: 'weighted';
|
|
13
|
+
rarityRates: Record<string, number>;
|
|
14
|
+
pools: RarityInput[];
|
|
15
|
+
}
|
|
16
|
+
/** Flat rate mode does NOT use rarityRates */
|
|
17
|
+
interface FlatRateGachaEngineConfig {
|
|
18
|
+
mode: 'flatRate';
|
|
19
|
+
pools: RarityInput[];
|
|
20
|
+
}
|
|
21
|
+
type GachaEngineConfig = WeightedGachaEngineConfig | FlatRateGachaEngineConfig;
|
|
22
|
+
|
|
23
|
+
declare class GachaEngine {
|
|
24
|
+
private static readonly SCALE;
|
|
25
|
+
private static readonly MAX_SAFE_SCALE;
|
|
26
|
+
private mode;
|
|
27
|
+
private pools;
|
|
28
|
+
private rarityRatesScaled;
|
|
29
|
+
private flatRateMap;
|
|
30
|
+
private dropRateCacheScaled;
|
|
31
|
+
private flatRateRateUpItems;
|
|
32
|
+
constructor(config: GachaEngineConfig);
|
|
33
|
+
private scaleRarityRates;
|
|
34
|
+
private toScaled;
|
|
35
|
+
private fromScaled;
|
|
36
|
+
private validateConfig;
|
|
37
|
+
getItemDropRate(name: string): number;
|
|
38
|
+
getCumulativeProbabilityForItem(name: string, rolls: number): number;
|
|
39
|
+
getRollsForTargetProbability(name: string, targetProbability: number): number;
|
|
40
|
+
getRateUpItems(): string[];
|
|
41
|
+
getAllItemDropRates(): {
|
|
42
|
+
name: string;
|
|
43
|
+
dropRate: number;
|
|
44
|
+
rarity: string;
|
|
45
|
+
}[];
|
|
46
|
+
roll(count?: number): string[];
|
|
47
|
+
private selectRarity;
|
|
48
|
+
private selectItemFromPool;
|
|
49
|
+
getDebugInfo(): {
|
|
50
|
+
scale: number;
|
|
51
|
+
rarityRatesScaled: Record<string, number>;
|
|
52
|
+
rarityRatesFloat: Record<string, number>;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { GachaEngine };
|
|
57
|
+
export type { FlatRateGachaEngineConfig, GachaEngineConfig, GachaItem, RarityInput, WeightedGachaEngineConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allemandi/gacha-engine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Practical, type-safe toolkit for simulating and understanding gacha rates and rate-ups.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.module.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"build": "rollup -c",
|
|
31
31
|
"test": "vitest run",
|
|
32
32
|
"dev:test": "vitest",
|
|
33
|
-
"lint": "eslint
|
|
33
|
+
"lint": "eslint ."
|
|
34
34
|
},
|
|
35
35
|
"keywords": [
|
|
36
36
|
"gacha",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"eslint": "^10.0.3",
|
|
61
61
|
"globals": "^17.4.0",
|
|
62
62
|
"rollup": "^4.59.0",
|
|
63
|
+
"rollup-plugin-dts": "^6.4.0",
|
|
63
64
|
"tslib": "^2.8.1",
|
|
64
65
|
"typescript": "^5.8.3",
|
|
65
66
|
"vitest": "^4.1.0"
|
package/dist/gacha-engine.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { GachaEngineConfig } from './types';
|
|
2
|
-
export declare class GachaEngine {
|
|
3
|
-
private static readonly SCALE;
|
|
4
|
-
private static readonly MAX_SAFE_SCALE;
|
|
5
|
-
private mode;
|
|
6
|
-
private pools;
|
|
7
|
-
private rarityRatesScaled;
|
|
8
|
-
private flatRateMap;
|
|
9
|
-
private dropRateCacheScaled;
|
|
10
|
-
private flatRateRateUpItems;
|
|
11
|
-
constructor(config: GachaEngineConfig);
|
|
12
|
-
private scaleRarityRates;
|
|
13
|
-
private toScaled;
|
|
14
|
-
private fromScaled;
|
|
15
|
-
private validateConfig;
|
|
16
|
-
getItemDropRate(name: string): number;
|
|
17
|
-
getCumulativeProbabilityForItem(name: string, rolls: number): number;
|
|
18
|
-
getRollsForTargetProbability(name: string, targetProbability: number): number;
|
|
19
|
-
getRateUpItems(): string[];
|
|
20
|
-
getAllItemDropRates(): {
|
|
21
|
-
name: string;
|
|
22
|
-
dropRate: number;
|
|
23
|
-
rarity: string;
|
|
24
|
-
}[];
|
|
25
|
-
roll(count?: number): string[];
|
|
26
|
-
private selectRarity;
|
|
27
|
-
private selectItemFromPool;
|
|
28
|
-
getDebugInfo(): {
|
|
29
|
-
scale: number;
|
|
30
|
-
rarityRatesScaled: Record<string, number>;
|
|
31
|
-
rarityRatesFloat: Record<string, number>;
|
|
32
|
-
};
|
|
33
|
-
}
|
package/dist/types.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface GachaItem {
|
|
2
|
-
name: string;
|
|
3
|
-
weight: number;
|
|
4
|
-
rateUp?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface RarityInput {
|
|
7
|
-
rarity: string;
|
|
8
|
-
items: GachaItem[];
|
|
9
|
-
}
|
|
10
|
-
/** Weighted mode requires explicit rarityRates */
|
|
11
|
-
export interface WeightedGachaEngineConfig {
|
|
12
|
-
mode: 'weighted';
|
|
13
|
-
rarityRates: Record<string, number>;
|
|
14
|
-
pools: RarityInput[];
|
|
15
|
-
}
|
|
16
|
-
/** Flat rate mode does NOT use rarityRates */
|
|
17
|
-
export interface FlatRateGachaEngineConfig {
|
|
18
|
-
mode: 'flatRate';
|
|
19
|
-
pools: RarityInput[];
|
|
20
|
-
}
|
|
21
|
-
export type GachaEngineConfig = WeightedGachaEngineConfig | FlatRateGachaEngineConfig;
|