volleyballsimtypes 0.0.375 → 0.0.377
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/cjs/src/data/models/currency-transaction.d.ts +3 -2
- package/dist/cjs/src/data/models/currency-transaction.js +1 -0
- package/dist/cjs/src/service/player/player-generator.js +16 -9
- package/dist/cjs/src/service/player/rarity.d.ts +7 -0
- package/dist/cjs/src/service/player/rarity.js +11 -1
- package/dist/cjs/src/service/utils/faker-generators.js +3 -0
- package/dist/esm/src/data/models/currency-transaction.d.ts +3 -2
- package/dist/esm/src/data/models/currency-transaction.js +1 -0
- package/dist/esm/src/service/player/player-generator.js +17 -10
- package/dist/esm/src/service/player/rarity.d.ts +7 -0
- package/dist/esm/src/service/player/rarity.js +10 -0
- package/dist/esm/src/service/utils/faker-generators.js +3 -0
- package/package.json +1 -1
|
@@ -11,9 +11,10 @@ export declare enum CurrencyTransactionSourceEnum {
|
|
|
11
11
|
GACHA_PULL = "GACHA_PULL",
|
|
12
12
|
COACH_UPGRADE = "COACH_UPGRADE",
|
|
13
13
|
PLAYER_DISMISS = "PLAYER_DISMISS",
|
|
14
|
-
ADMIN_GRANT = "ADMIN_GRANT"
|
|
14
|
+
ADMIN_GRANT = "ADMIN_GRANT",
|
|
15
|
+
SEASON_REWARD = "SEASON_REWARD"
|
|
15
16
|
}
|
|
16
|
-
export type CurrencyTransactionSource = CurrencyTransactionSourceEnum.MATCH_REWARD | CurrencyTransactionSourceEnum.GACHA_PULL | CurrencyTransactionSourceEnum.COACH_UPGRADE | CurrencyTransactionSourceEnum.PLAYER_DISMISS | CurrencyTransactionSourceEnum.ADMIN_GRANT;
|
|
17
|
+
export type CurrencyTransactionSource = CurrencyTransactionSourceEnum.MATCH_REWARD | CurrencyTransactionSourceEnum.GACHA_PULL | CurrencyTransactionSourceEnum.COACH_UPGRADE | CurrencyTransactionSourceEnum.PLAYER_DISMISS | CurrencyTransactionSourceEnum.ADMIN_GRANT | CurrencyTransactionSourceEnum.SEASON_REWARD;
|
|
17
18
|
export interface CurrencyTransactionAttributes {
|
|
18
19
|
transaction_id: string;
|
|
19
20
|
user_id: string;
|
|
@@ -14,6 +14,7 @@ var CurrencyTransactionSourceEnum;
|
|
|
14
14
|
CurrencyTransactionSourceEnum["COACH_UPGRADE"] = "COACH_UPGRADE";
|
|
15
15
|
CurrencyTransactionSourceEnum["PLAYER_DISMISS"] = "PLAYER_DISMISS";
|
|
16
16
|
CurrencyTransactionSourceEnum["ADMIN_GRANT"] = "ADMIN_GRANT";
|
|
17
|
+
CurrencyTransactionSourceEnum["SEASON_REWARD"] = "SEASON_REWARD";
|
|
17
18
|
})(CurrencyTransactionSourceEnum || (exports.CurrencyTransactionSourceEnum = CurrencyTransactionSourceEnum = {}));
|
|
18
19
|
class CurrencyTransactionModel extends sequelize_1.Model {
|
|
19
20
|
static initModel(sequelize) {
|
|
@@ -115,9 +115,11 @@ class PlayerGenerator {
|
|
|
115
115
|
const RECEIVE = (0, stats_1.getMultipliers)(stats_1.StatsEnum.RECEIVE);
|
|
116
116
|
const BLOCK = (0, stats_1.getMultipliers)(stats_1.StatsEnum.BLOCK);
|
|
117
117
|
const SERVE = (0, stats_1.getMultipliers)(stats_1.StatsEnum.SERVE);
|
|
118
|
-
const STAMINA = (0, stats_1.getMultipliers)(stats_1.StatsEnum.STAMINA);
|
|
119
118
|
function buildPerformanceFromRole(weights, minValue, maxValue) {
|
|
120
119
|
return performance_stats_1.PerformanceStats.create(Object.fromEntries(performance_stats_1.performanceStatKeys.map((key) => {
|
|
120
|
+
// Stamina always uses its own per-rarity range (guaranteed floor), regardless of role weight.
|
|
121
|
+
if (key === 'stamina')
|
|
122
|
+
return [key, rollStamina(rarity)];
|
|
121
123
|
if (weights[key] > 0)
|
|
122
124
|
return [key, (0, node_crypto_1.randomInt)(minValue, maxValue + 1)];
|
|
123
125
|
else
|
|
@@ -132,7 +134,9 @@ class PlayerGenerator {
|
|
|
132
134
|
return buildPerformanceFromRole(weights, rarity_1.RarityRanges.COMMON[0], rarity_1.RarityRanges.COMMON[1]);
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
|
-
return performance_stats_1.PerformanceStats.create(Object.fromEntries(performance_stats_1.performanceStatKeys.map((key) =>
|
|
137
|
+
return performance_stats_1.PerformanceStats.create(Object.fromEntries(performance_stats_1.performanceStatKeys.map((key) => key === 'stamina'
|
|
138
|
+
? [key, rollStamina(rarity)]
|
|
139
|
+
: [key, Math.round((0, node_crypto_1.randomInt)(rarity_1.RarityRanges.COMMON[0], rarity_1.RarityRanges.COMMON[1]))])));
|
|
136
140
|
}
|
|
137
141
|
case rarity_1.RarityEnum.RARE: {
|
|
138
142
|
if (role != null) {
|
|
@@ -149,7 +153,7 @@ class PlayerGenerator {
|
|
|
149
153
|
for (let i = 3; i < 5; i++) {
|
|
150
154
|
assignValues(stats[i], rarity_1.RarityRanges.COMMON[0], rarity_1.RarityRanges.COMMON[1], performance);
|
|
151
155
|
}
|
|
152
|
-
|
|
156
|
+
performance.stamina = rollStamina(rarity);
|
|
153
157
|
return performance_stats_1.PerformanceStats.create(performance);
|
|
154
158
|
}
|
|
155
159
|
case rarity_1.RarityEnum.LEGENDARY: {
|
|
@@ -160,15 +164,13 @@ class PlayerGenerator {
|
|
|
160
164
|
}
|
|
161
165
|
}
|
|
162
166
|
const s1 = (0, utils_1.shuffle)([ATTACK, SET, RECEIVE, BLOCK]);
|
|
163
|
-
const s2 = (0, utils_1.shuffle)([SERVE, STAMINA]);
|
|
164
167
|
const performance = Object.fromEntries(performance_stats_1.performanceStatKeys.map((key) => [key, 1]));
|
|
165
168
|
assignValues(s1[0], rarity_1.RarityRanges.LEGENDARY[0], rarity_1.RarityRanges.LEGENDARY[1], performance);
|
|
166
169
|
for (let i = 1; i < 4; i++) {
|
|
167
170
|
assignValues(s1[i], rarity_1.RarityRanges.RARE[0], rarity_1.RarityRanges.RARE[1], performance);
|
|
168
171
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
+
assignValues(SERVE, rarity_1.RarityRanges.COMMON[0], rarity_1.RarityRanges.RARE[1], performance);
|
|
173
|
+
performance.stamina = rollStamina(rarity);
|
|
172
174
|
return performance_stats_1.PerformanceStats.create(performance);
|
|
173
175
|
}
|
|
174
176
|
case rarity_1.RarityEnum.MYTHIC: {
|
|
@@ -186,7 +188,7 @@ class PlayerGenerator {
|
|
|
186
188
|
assignValues(stats[i], rarity_1.RarityRanges.RARE[0], rarity_1.RarityRanges.RARE[1], performance);
|
|
187
189
|
}
|
|
188
190
|
assignValues(SERVE, rarity_1.RarityRanges.LEGENDARY[0], rarity_1.RarityRanges.LEGENDARY[1], performance);
|
|
189
|
-
|
|
191
|
+
performance.stamina = rollStamina(rarity);
|
|
190
192
|
return performance_stats_1.PerformanceStats.create(performance);
|
|
191
193
|
}
|
|
192
194
|
case rarity_1.RarityEnum.SPECIAL: {
|
|
@@ -205,7 +207,7 @@ class PlayerGenerator {
|
|
|
205
207
|
for (let i = 3; i < 5; i++) {
|
|
206
208
|
assignValues(stats[i], rarity_1.RarityRanges.LEGENDARY[0], rarity_1.RarityRanges.LEGENDARY[1], performance);
|
|
207
209
|
}
|
|
208
|
-
|
|
210
|
+
performance.stamina = rollStamina(rarity);
|
|
209
211
|
return performance_stats_1.PerformanceStats.create(performance);
|
|
210
212
|
}
|
|
211
213
|
default: {
|
|
@@ -251,6 +253,11 @@ function pickPlayerCountry(teamCountry, allCountries) {
|
|
|
251
253
|
}
|
|
252
254
|
return allCountries[Math.floor(Math.random() * allCountries.length)];
|
|
253
255
|
}
|
|
256
|
+
// Stamina value for a rarity, drawn uniformly from its StaminaRanges floor..ceil (inclusive).
|
|
257
|
+
function rollStamina(rarity) {
|
|
258
|
+
const [low, high] = rarity_1.StaminaRanges[rarity];
|
|
259
|
+
return (0, node_crypto_1.randomInt)(low, high + 1);
|
|
260
|
+
}
|
|
254
261
|
function assignValues(stat, low, high, performance) {
|
|
255
262
|
performance_stats_1.performanceStatKeys.filter((key) => stat[key] != null && stat[key] > 0)
|
|
256
263
|
.forEach((key) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RarityRanges = exports.RarityEnum = void 0;
|
|
3
|
+
exports.StaminaRanges = exports.RarityRanges = exports.RarityEnum = void 0;
|
|
4
4
|
var RarityEnum;
|
|
5
5
|
(function (RarityEnum) {
|
|
6
6
|
RarityEnum["COMMON"] = "COMMON";
|
|
@@ -16,3 +16,13 @@ exports.RarityRanges = {
|
|
|
16
16
|
[RarityEnum.MYTHIC]: [80, 89],
|
|
17
17
|
[RarityEnum.SPECIAL]: [90, 99]
|
|
18
18
|
};
|
|
19
|
+
// Stamina has its own per-rarity range with a guaranteed floor, applied identically in both the
|
|
20
|
+
// role-weighted and the generic generation paths (stamina is otherwise a secondary stat that would
|
|
21
|
+
// bottom out near 1 in the generic path). Floors: RARE 15, LEGENDARY 30, MYTHIC 45, SPECIAL 60.
|
|
22
|
+
exports.StaminaRanges = {
|
|
23
|
+
[RarityEnum.COMMON]: [1, 59],
|
|
24
|
+
[RarityEnum.RARE]: [15, 69],
|
|
25
|
+
[RarityEnum.LEGENDARY]: [30, 69],
|
|
26
|
+
[RarityEnum.MYTHIC]: [45, 89],
|
|
27
|
+
[RarityEnum.SPECIAL]: [60, 99]
|
|
28
|
+
};
|
|
@@ -42,6 +42,9 @@ function romanize(s) {
|
|
|
42
42
|
if (s.length === 0 || LATIN_NAME.test(s))
|
|
43
43
|
return s;
|
|
44
44
|
return (0, transliteration_1.transliterate)(s)
|
|
45
|
+
// Transliteration can emit stray symbols/digits for some scripts (e.g. an Arabic hamza -> '@').
|
|
46
|
+
// Keep only Latin letters and whitespace so we end up with a clean name.
|
|
47
|
+
.replace(/[^\p{Script=Latin}\s]/gu, '')
|
|
45
48
|
.split(/\s+/)
|
|
46
49
|
.filter(part => part.length > 0)
|
|
47
50
|
.map(part => capitalize(part.toLowerCase()))
|
|
@@ -11,9 +11,10 @@ export declare enum CurrencyTransactionSourceEnum {
|
|
|
11
11
|
GACHA_PULL = "GACHA_PULL",
|
|
12
12
|
COACH_UPGRADE = "COACH_UPGRADE",
|
|
13
13
|
PLAYER_DISMISS = "PLAYER_DISMISS",
|
|
14
|
-
ADMIN_GRANT = "ADMIN_GRANT"
|
|
14
|
+
ADMIN_GRANT = "ADMIN_GRANT",
|
|
15
|
+
SEASON_REWARD = "SEASON_REWARD"
|
|
15
16
|
}
|
|
16
|
-
export type CurrencyTransactionSource = CurrencyTransactionSourceEnum.MATCH_REWARD | CurrencyTransactionSourceEnum.GACHA_PULL | CurrencyTransactionSourceEnum.COACH_UPGRADE | CurrencyTransactionSourceEnum.PLAYER_DISMISS | CurrencyTransactionSourceEnum.ADMIN_GRANT;
|
|
17
|
+
export type CurrencyTransactionSource = CurrencyTransactionSourceEnum.MATCH_REWARD | CurrencyTransactionSourceEnum.GACHA_PULL | CurrencyTransactionSourceEnum.COACH_UPGRADE | CurrencyTransactionSourceEnum.PLAYER_DISMISS | CurrencyTransactionSourceEnum.ADMIN_GRANT | CurrencyTransactionSourceEnum.SEASON_REWARD;
|
|
17
18
|
export interface CurrencyTransactionAttributes {
|
|
18
19
|
transaction_id: string;
|
|
19
20
|
user_id: string;
|
|
@@ -11,6 +11,7 @@ export var CurrencyTransactionSourceEnum;
|
|
|
11
11
|
CurrencyTransactionSourceEnum["COACH_UPGRADE"] = "COACH_UPGRADE";
|
|
12
12
|
CurrencyTransactionSourceEnum["PLAYER_DISMISS"] = "PLAYER_DISMISS";
|
|
13
13
|
CurrencyTransactionSourceEnum["ADMIN_GRANT"] = "ADMIN_GRANT";
|
|
14
|
+
CurrencyTransactionSourceEnum["SEASON_REWARD"] = "SEASON_REWARD";
|
|
14
15
|
})(CurrencyTransactionSourceEnum || (CurrencyTransactionSourceEnum = {}));
|
|
15
16
|
export class CurrencyTransactionModel extends Model {
|
|
16
17
|
static initModel(sequelize) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { randomInt } from 'node:crypto';
|
|
3
|
-
import { RarityEnum, RarityRanges } from './rarity';
|
|
3
|
+
import { RarityEnum, RarityRanges, StaminaRanges } from './rarity';
|
|
4
4
|
import { performanceStatKeys, PerformanceStats } from './performance-stats';
|
|
5
5
|
import { assignRoles } from './role';
|
|
6
6
|
import { getMultipliers, StatsEnum } from './stats';
|
|
@@ -110,9 +110,11 @@ export class PlayerGenerator {
|
|
|
110
110
|
const RECEIVE = getMultipliers(StatsEnum.RECEIVE);
|
|
111
111
|
const BLOCK = getMultipliers(StatsEnum.BLOCK);
|
|
112
112
|
const SERVE = getMultipliers(StatsEnum.SERVE);
|
|
113
|
-
const STAMINA = getMultipliers(StatsEnum.STAMINA);
|
|
114
113
|
function buildPerformanceFromRole(weights, minValue, maxValue) {
|
|
115
114
|
return PerformanceStats.create(Object.fromEntries(performanceStatKeys.map((key) => {
|
|
115
|
+
// Stamina always uses its own per-rarity range (guaranteed floor), regardless of role weight.
|
|
116
|
+
if (key === 'stamina')
|
|
117
|
+
return [key, rollStamina(rarity)];
|
|
116
118
|
if (weights[key] > 0)
|
|
117
119
|
return [key, randomInt(minValue, maxValue + 1)];
|
|
118
120
|
else
|
|
@@ -127,7 +129,9 @@ export class PlayerGenerator {
|
|
|
127
129
|
return buildPerformanceFromRole(weights, RarityRanges.COMMON[0], RarityRanges.COMMON[1]);
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
|
-
return PerformanceStats.create(Object.fromEntries(performanceStatKeys.map((key) =>
|
|
132
|
+
return PerformanceStats.create(Object.fromEntries(performanceStatKeys.map((key) => key === 'stamina'
|
|
133
|
+
? [key, rollStamina(rarity)]
|
|
134
|
+
: [key, Math.round(randomInt(RarityRanges.COMMON[0], RarityRanges.COMMON[1]))])));
|
|
131
135
|
}
|
|
132
136
|
case RarityEnum.RARE: {
|
|
133
137
|
if (role != null) {
|
|
@@ -144,7 +148,7 @@ export class PlayerGenerator {
|
|
|
144
148
|
for (let i = 3; i < 5; i++) {
|
|
145
149
|
assignValues(stats[i], RarityRanges.COMMON[0], RarityRanges.COMMON[1], performance);
|
|
146
150
|
}
|
|
147
|
-
|
|
151
|
+
performance.stamina = rollStamina(rarity);
|
|
148
152
|
return PerformanceStats.create(performance);
|
|
149
153
|
}
|
|
150
154
|
case RarityEnum.LEGENDARY: {
|
|
@@ -155,15 +159,13 @@ export class PlayerGenerator {
|
|
|
155
159
|
}
|
|
156
160
|
}
|
|
157
161
|
const s1 = shuffle([ATTACK, SET, RECEIVE, BLOCK]);
|
|
158
|
-
const s2 = shuffle([SERVE, STAMINA]);
|
|
159
162
|
const performance = Object.fromEntries(performanceStatKeys.map((key) => [key, 1]));
|
|
160
163
|
assignValues(s1[0], RarityRanges.LEGENDARY[0], RarityRanges.LEGENDARY[1], performance);
|
|
161
164
|
for (let i = 1; i < 4; i++) {
|
|
162
165
|
assignValues(s1[i], RarityRanges.RARE[0], RarityRanges.RARE[1], performance);
|
|
163
166
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
+
assignValues(SERVE, RarityRanges.COMMON[0], RarityRanges.RARE[1], performance);
|
|
168
|
+
performance.stamina = rollStamina(rarity);
|
|
167
169
|
return PerformanceStats.create(performance);
|
|
168
170
|
}
|
|
169
171
|
case RarityEnum.MYTHIC: {
|
|
@@ -181,7 +183,7 @@ export class PlayerGenerator {
|
|
|
181
183
|
assignValues(stats[i], RarityRanges.RARE[0], RarityRanges.RARE[1], performance);
|
|
182
184
|
}
|
|
183
185
|
assignValues(SERVE, RarityRanges.LEGENDARY[0], RarityRanges.LEGENDARY[1], performance);
|
|
184
|
-
|
|
186
|
+
performance.stamina = rollStamina(rarity);
|
|
185
187
|
return PerformanceStats.create(performance);
|
|
186
188
|
}
|
|
187
189
|
case RarityEnum.SPECIAL: {
|
|
@@ -200,7 +202,7 @@ export class PlayerGenerator {
|
|
|
200
202
|
for (let i = 3; i < 5; i++) {
|
|
201
203
|
assignValues(stats[i], RarityRanges.LEGENDARY[0], RarityRanges.LEGENDARY[1], performance);
|
|
202
204
|
}
|
|
203
|
-
|
|
205
|
+
performance.stamina = rollStamina(rarity);
|
|
204
206
|
return PerformanceStats.create(performance);
|
|
205
207
|
}
|
|
206
208
|
default: {
|
|
@@ -245,6 +247,11 @@ export function pickPlayerCountry(teamCountry, allCountries) {
|
|
|
245
247
|
}
|
|
246
248
|
return allCountries[Math.floor(Math.random() * allCountries.length)];
|
|
247
249
|
}
|
|
250
|
+
// Stamina value for a rarity, drawn uniformly from its StaminaRanges floor..ceil (inclusive).
|
|
251
|
+
function rollStamina(rarity) {
|
|
252
|
+
const [low, high] = StaminaRanges[rarity];
|
|
253
|
+
return randomInt(low, high + 1);
|
|
254
|
+
}
|
|
248
255
|
function assignValues(stat, low, high, performance) {
|
|
249
256
|
performanceStatKeys.filter((key) => stat[key] != null && stat[key] > 0)
|
|
250
257
|
.forEach((key) => {
|
|
@@ -13,3 +13,13 @@ export const RarityRanges = {
|
|
|
13
13
|
[RarityEnum.MYTHIC]: [80, 89],
|
|
14
14
|
[RarityEnum.SPECIAL]: [90, 99]
|
|
15
15
|
};
|
|
16
|
+
// Stamina has its own per-rarity range with a guaranteed floor, applied identically in both the
|
|
17
|
+
// role-weighted and the generic generation paths (stamina is otherwise a secondary stat that would
|
|
18
|
+
// bottom out near 1 in the generic path). Floors: RARE 15, LEGENDARY 30, MYTHIC 45, SPECIAL 60.
|
|
19
|
+
export const StaminaRanges = {
|
|
20
|
+
[RarityEnum.COMMON]: [1, 59],
|
|
21
|
+
[RarityEnum.RARE]: [15, 69],
|
|
22
|
+
[RarityEnum.LEGENDARY]: [30, 69],
|
|
23
|
+
[RarityEnum.MYTHIC]: [45, 89],
|
|
24
|
+
[RarityEnum.SPECIAL]: [60, 99]
|
|
25
|
+
};
|
|
@@ -36,6 +36,9 @@ export function romanize(s) {
|
|
|
36
36
|
if (s.length === 0 || LATIN_NAME.test(s))
|
|
37
37
|
return s;
|
|
38
38
|
return transliterate(s)
|
|
39
|
+
// Transliteration can emit stray symbols/digits for some scripts (e.g. an Arabic hamza -> '@').
|
|
40
|
+
// Keep only Latin letters and whitespace so we end up with a clean name.
|
|
41
|
+
.replace(/[^\p{Script=Latin}\s]/gu, '')
|
|
39
42
|
.split(/\s+/)
|
|
40
43
|
.filter(part => part.length > 0)
|
|
41
44
|
.map(part => capitalize(part.toLowerCase()))
|