@allemandi/gacha-engine 1.0.5 โ 1.0.7
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/README.md +27 -25
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
- [๐ ๏ธ Installation](#๏ธ-installation)
|
|
17
17
|
- [๐ Quick Usage Examples](#-quick-usage-examples)
|
|
18
18
|
- [๐ API](#-api)
|
|
19
|
+
- [Constructor](#constructor)
|
|
20
|
+
- [Methods](#methods)
|
|
19
21
|
- [๐งช Tests](#-tests)
|
|
20
22
|
- [๐ Related Projects](#-related-projects)
|
|
21
23
|
- [๐ค Contributing](#-contributing)
|
|
@@ -52,17 +54,17 @@ const pools = [
|
|
|
52
54
|
{
|
|
53
55
|
rarity: 'SSR',
|
|
54
56
|
items: [
|
|
55
|
-
{ name: 'Super Hobo', weight: 0
|
|
56
|
-
{ name: 'Broke King', weight: 0.
|
|
57
|
-
{ name: 'Cardboard Hero', weight: 0.
|
|
57
|
+
{ name: 'Super Hobo', weight: 1.0, rateUp: true },
|
|
58
|
+
{ name: 'Broke King', weight: 0.5 },
|
|
59
|
+
{ name: 'Cardboard Hero', weight: 0.5 }
|
|
58
60
|
]
|
|
59
61
|
},
|
|
60
62
|
{
|
|
61
63
|
rarity: 'SR',
|
|
62
64
|
items: [
|
|
63
|
-
{ name: 'Cold Salaryman', weight:
|
|
64
|
-
{ name: 'Numb Artist', weight: 1.
|
|
65
|
-
{ name: 'Crying Cook', weight: 1.
|
|
65
|
+
{ name: 'Cold Salaryman', weight: 2.5, rateUp: true },
|
|
66
|
+
{ name: 'Numb Artist', weight: 1.25 },
|
|
67
|
+
{ name: 'Crying Cook', weight: 1.25 }
|
|
66
68
|
]
|
|
67
69
|
},
|
|
68
70
|
{
|
|
@@ -86,11 +88,11 @@ console.log('10 rolls:', engine.roll(10).join(', '));
|
|
|
86
88
|
|
|
87
89
|
const rate = engine.getItemDropRate('Super Hobo');
|
|
88
90
|
console.log('Drop rate for Super Hobo:', (rate * 100) + '%');
|
|
89
|
-
//
|
|
91
|
+
// (1.0 / 2.0) * 0.01 = 0.005 โ 0.5%
|
|
90
92
|
|
|
91
93
|
const cumulative = engine.getCumulativeProbabilityForItem('Super Hobo', 300);
|
|
92
|
-
console.log('Probability in 300 rolls:', (cumulative * 100) + '%');
|
|
93
|
-
// ~77.
|
|
94
|
+
console.log('Probability in 300 rolls:', (cumulative * 100).toFixed(1) + '%');
|
|
95
|
+
// ~77.8%
|
|
94
96
|
|
|
95
97
|
console.log('Rolls for 50% chance:', engine.getRollsForTargetProbability('Super Hobo', 0.5));
|
|
96
98
|
// 139
|
|
@@ -107,20 +109,20 @@ const pools = [
|
|
|
107
109
|
{
|
|
108
110
|
rarity: 'SSR',
|
|
109
111
|
items: [
|
|
110
|
-
{ name: 'Superior Rat', weight: 0.
|
|
112
|
+
{ name: 'Superior Rat', weight: 0.008, rateUp: true },
|
|
111
113
|
{ name: 'Dumpster King', weight: 0.002 }
|
|
112
114
|
]
|
|
113
115
|
},
|
|
114
116
|
{
|
|
115
117
|
rarity: 'SR',
|
|
116
118
|
items: [
|
|
117
|
-
{ name: 'Sleepy Chef', weight: 0.
|
|
119
|
+
{ name: 'Sleepy Chef', weight: 0.04 }
|
|
118
120
|
]
|
|
119
121
|
},
|
|
120
122
|
{
|
|
121
123
|
rarity: 'R',
|
|
122
124
|
items: [
|
|
123
|
-
{ name: 'Unknown Student', weight: 0.
|
|
125
|
+
{ name: 'Unknown Student', weight: 0.95 }
|
|
124
126
|
]
|
|
125
127
|
}
|
|
126
128
|
];
|
|
@@ -131,15 +133,15 @@ console.log('Roll x5:', engine.roll(5).join(', '));
|
|
|
131
133
|
|
|
132
134
|
const dropRate = engine.getItemDropRate('Superior Rat');
|
|
133
135
|
console.log('Drop rate for Superior Rat:', (dropRate * 100) + '%');
|
|
134
|
-
// 0.
|
|
136
|
+
// 0.8%
|
|
135
137
|
|
|
136
|
-
const cumulative = engine.getCumulativeProbabilityForItem('Superior Rat',
|
|
137
|
-
console.log('Chance after
|
|
138
|
-
//
|
|
138
|
+
const cumulative = engine.getCumulativeProbabilityForItem('Superior Rat', 200);
|
|
139
|
+
console.log('Chance after 200 rolls:', (cumulative * 100).toFixed(1) + '%');
|
|
140
|
+
// 79.9%
|
|
139
141
|
|
|
140
142
|
const rollsFor50 = engine.getRollsForTargetProbability('Superior Rat', 0.5);
|
|
141
143
|
console.log('Rolls for 50% chance:', rollsFor50);
|
|
142
|
-
//
|
|
144
|
+
// 87
|
|
143
145
|
|
|
144
146
|
console.log('Rate-up items:', engine.getRateUpItems().join(', '));
|
|
145
147
|
// Superior Rat
|
|
@@ -162,15 +164,15 @@ console.log('Rate-up items:', engine.getRateUpItems().join(', '));
|
|
|
162
164
|
{
|
|
163
165
|
rarity: 'SSR',
|
|
164
166
|
items: [
|
|
165
|
-
{ name: 'Trash Wizard', weight:
|
|
166
|
-
{ name: 'Park Master', weight: 1.
|
|
167
|
+
{ name: 'Trash Wizard', weight: 0.5 },
|
|
168
|
+
{ name: 'Park Master', weight: 1.5, rateUp: true }
|
|
167
169
|
]
|
|
168
170
|
},
|
|
169
171
|
{
|
|
170
172
|
rarity: 'SR',
|
|
171
173
|
items: [
|
|
172
|
-
{ name: 'Street Sweeper', weight:
|
|
173
|
-
{ name: 'Bench Philosopher', weight:
|
|
174
|
+
{ name: 'Street Sweeper', weight: 1.0 },
|
|
175
|
+
{ name: 'Bench Philosopher', weight: 3.0, rateUp: true }
|
|
174
176
|
]
|
|
175
177
|
},
|
|
176
178
|
{
|
|
@@ -188,16 +190,16 @@ console.log('Rate-up items:', engine.getRateUpItems().join(', '));
|
|
|
188
190
|
|
|
189
191
|
console.log('1x Roll:', engine.roll());
|
|
190
192
|
console.log('Drop rate for Park Master:', (rate * 100).toFixed(2) + '%');
|
|
191
|
-
// 1.
|
|
193
|
+
// 1.5 / 2.0 * 0.02 = 0.015 โ 1.50%
|
|
192
194
|
|
|
193
195
|
console.log('Cumulative 200 rolls:', (cumulative * 100).toFixed(1) + '%');
|
|
194
|
-
//
|
|
196
|
+
// "95.1%"
|
|
195
197
|
|
|
196
198
|
console.log('Rolls for 75% chance:', rolls);
|
|
197
|
-
//
|
|
199
|
+
// 92
|
|
198
200
|
|
|
199
201
|
console.log('Rate-up items:', engine.getRateUpItems().join(', '));
|
|
200
|
-
// Park Master
|
|
202
|
+
// "Park Master, Bench Philosopher"
|
|
201
203
|
|
|
202
204
|
console.log('All items:', engine.getAllItemDropRates().map(i => i.name));
|
|
203
205
|
// ["Trash Wizard", "Park Master", "Street Sweeper", "Bench Philosopher", "Bus Stop Ghost"]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allemandi/gacha-engine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
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",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "rollup -c",
|
|
31
31
|
"test": "vitest run",
|
|
32
|
+
"test:dist": "node test/smoke-cjs.cjs && node test/smoke-esm.mjs && node test/smoke-umd.cjs",
|
|
32
33
|
"dev:test": "vitest",
|
|
33
34
|
"lint": "eslint ."
|
|
34
35
|
},
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
54
55
|
"@rollup/plugin-json": "^6.1.0",
|
|
55
56
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
56
|
-
"@rollup/plugin-terser": "^0.
|
|
57
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
57
58
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
58
59
|
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
|
59
60
|
"@typescript-eslint/parser": "^8.57.0",
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
"rollup": "^4.59.0",
|
|
63
64
|
"rollup-plugin-dts": "^6.4.0",
|
|
64
65
|
"tslib": "^2.8.1",
|
|
65
|
-
"typescript": "^
|
|
66
|
+
"typescript": "^6.0.2",
|
|
66
67
|
"vitest": "^4.1.0"
|
|
67
68
|
}
|
|
68
69
|
}
|