volleyballsimtypes 0.0.371 → 0.0.373
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/service/player/role.js +5 -5
- package/dist/cjs/src/service/player/role.test.js +4 -4
- package/dist/cjs/src/service/team/index.d.ts +1 -0
- package/dist/cjs/src/service/team/index.js +1 -0
- package/dist/cjs/src/service/team/team-name.d.ts +15 -0
- package/dist/cjs/src/service/team/team-name.js +29 -0
- package/dist/esm/src/service/player/role.js +5 -5
- package/dist/esm/src/service/player/role.test.js +4 -4
- package/dist/esm/src/service/team/index.d.ts +1 -0
- package/dist/esm/src/service/team/index.js +1 -0
- package/dist/esm/src/service/team/team-name.d.ts +15 -0
- package/dist/esm/src/service/team/team-name.js +24 -0
- package/package.json +1 -1
|
@@ -35,12 +35,12 @@ function calculateRoleScore(stats, role) {
|
|
|
35
35
|
// ─── Role assignment ──────────────────────────────────────────────────────────
|
|
36
36
|
function getRoleCountRange(rarity) {
|
|
37
37
|
switch (rarity) {
|
|
38
|
-
case rarity_1.RarityEnum.COMMON: return [1,
|
|
39
|
-
case rarity_1.RarityEnum.RARE: return [1,
|
|
40
|
-
case rarity_1.RarityEnum.LEGENDARY: return [1,
|
|
38
|
+
case rarity_1.RarityEnum.COMMON: return [1, 1];
|
|
39
|
+
case rarity_1.RarityEnum.RARE: return [1, 2];
|
|
40
|
+
case rarity_1.RarityEnum.LEGENDARY: return [1, 3];
|
|
41
41
|
case rarity_1.RarityEnum.MYTHIC: return [2, 4];
|
|
42
|
-
case rarity_1.RarityEnum.SPECIAL: return [3,
|
|
43
|
-
default: return [1,
|
|
42
|
+
case rarity_1.RarityEnum.SPECIAL: return [3, 4];
|
|
43
|
+
default: return [1, 1];
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
function assignRoles(stats, rarity) {
|
|
@@ -35,11 +35,11 @@ function setterStats() {
|
|
|
35
35
|
(0, globals_1.describe)('assignRoles()', () => {
|
|
36
36
|
const ITERATIONS = 2000;
|
|
37
37
|
globals_1.it.each([
|
|
38
|
-
[rarity_1.RarityEnum.COMMON, 1,
|
|
39
|
-
[rarity_1.RarityEnum.RARE, 1,
|
|
40
|
-
[rarity_1.RarityEnum.LEGENDARY, 1,
|
|
38
|
+
[rarity_1.RarityEnum.COMMON, 1, 1],
|
|
39
|
+
[rarity_1.RarityEnum.RARE, 1, 2],
|
|
40
|
+
[rarity_1.RarityEnum.LEGENDARY, 1, 3],
|
|
41
41
|
[rarity_1.RarityEnum.MYTHIC, 2, 4],
|
|
42
|
-
[rarity_1.RarityEnum.SPECIAL, 3,
|
|
42
|
+
[rarity_1.RarityEnum.SPECIAL, 3, 4]
|
|
43
43
|
])('%s: role count always within [%i, %i]', (rarity, min, max) => {
|
|
44
44
|
const stats = flatStats(50);
|
|
45
45
|
for (let i = 0; i < ITERATIONS; i++) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const TEAM_NAME_MIN_LENGTH = 3;
|
|
2
|
+
export declare const TEAM_NAME_MAX_LENGTH = 40;
|
|
3
|
+
/**
|
|
4
|
+
* Allowed team-name characters: Unicode letters (any script — Latin incl. ñ and
|
|
5
|
+
* Polish letters, Cyrillic, Greek, etc.), combining marks, digits, spaces, and
|
|
6
|
+
* basic name punctuation (hyphen, apostrophe, period).
|
|
7
|
+
*/
|
|
8
|
+
export declare const TEAM_NAME_PATTERN: RegExp;
|
|
9
|
+
/** Trim surrounding whitespace and normalise to NFC for consistent Unicode handling. */
|
|
10
|
+
export declare function normalizeTeamName(raw: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Validate a raw (untrimmed) team name. Normalises first (NFC + trim), then checks
|
|
13
|
+
* length, the allowed character set, and that it contains at least one letter or digit.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isValidTeamName(raw: string): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TEAM_NAME_PATTERN = exports.TEAM_NAME_MAX_LENGTH = exports.TEAM_NAME_MIN_LENGTH = void 0;
|
|
4
|
+
exports.normalizeTeamName = normalizeTeamName;
|
|
5
|
+
exports.isValidTeamName = isValidTeamName;
|
|
6
|
+
exports.TEAM_NAME_MIN_LENGTH = 3;
|
|
7
|
+
exports.TEAM_NAME_MAX_LENGTH = 40;
|
|
8
|
+
/**
|
|
9
|
+
* Allowed team-name characters: Unicode letters (any script — Latin incl. ñ and
|
|
10
|
+
* Polish letters, Cyrillic, Greek, etc.), combining marks, digits, spaces, and
|
|
11
|
+
* basic name punctuation (hyphen, apostrophe, period).
|
|
12
|
+
*/
|
|
13
|
+
exports.TEAM_NAME_PATTERN = /^[\p{L}\p{M}\p{N} .'-]+$/u;
|
|
14
|
+
const HAS_ALPHANUMERIC = /[\p{L}\p{N}]/u;
|
|
15
|
+
/** Trim surrounding whitespace and normalise to NFC for consistent Unicode handling. */
|
|
16
|
+
function normalizeTeamName(raw) {
|
|
17
|
+
return raw.normalize('NFC').trim();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validate a raw (untrimmed) team name. Normalises first (NFC + trim), then checks
|
|
21
|
+
* length, the allowed character set, and that it contains at least one letter or digit.
|
|
22
|
+
*/
|
|
23
|
+
function isValidTeamName(raw) {
|
|
24
|
+
const name = normalizeTeamName(raw);
|
|
25
|
+
return (name.length >= exports.TEAM_NAME_MIN_LENGTH &&
|
|
26
|
+
name.length <= exports.TEAM_NAME_MAX_LENGTH &&
|
|
27
|
+
exports.TEAM_NAME_PATTERN.test(name) &&
|
|
28
|
+
HAS_ALPHANUMERIC.test(name));
|
|
29
|
+
}
|
|
@@ -25,12 +25,12 @@ export function calculateRoleScore(stats, role) {
|
|
|
25
25
|
// ─── Role assignment ──────────────────────────────────────────────────────────
|
|
26
26
|
function getRoleCountRange(rarity) {
|
|
27
27
|
switch (rarity) {
|
|
28
|
-
case RarityEnum.COMMON: return [1,
|
|
29
|
-
case RarityEnum.RARE: return [1,
|
|
30
|
-
case RarityEnum.LEGENDARY: return [1,
|
|
28
|
+
case RarityEnum.COMMON: return [1, 1];
|
|
29
|
+
case RarityEnum.RARE: return [1, 2];
|
|
30
|
+
case RarityEnum.LEGENDARY: return [1, 3];
|
|
31
31
|
case RarityEnum.MYTHIC: return [2, 4];
|
|
32
|
-
case RarityEnum.SPECIAL: return [3,
|
|
33
|
-
default: return [1,
|
|
32
|
+
case RarityEnum.SPECIAL: return [3, 4];
|
|
33
|
+
default: return [1, 1];
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
export function assignRoles(stats, rarity) {
|
|
@@ -33,11 +33,11 @@ function setterStats() {
|
|
|
33
33
|
describe('assignRoles()', () => {
|
|
34
34
|
const ITERATIONS = 2000;
|
|
35
35
|
it.each([
|
|
36
|
-
[RarityEnum.COMMON, 1,
|
|
37
|
-
[RarityEnum.RARE, 1,
|
|
38
|
-
[RarityEnum.LEGENDARY, 1,
|
|
36
|
+
[RarityEnum.COMMON, 1, 1],
|
|
37
|
+
[RarityEnum.RARE, 1, 2],
|
|
38
|
+
[RarityEnum.LEGENDARY, 1, 3],
|
|
39
39
|
[RarityEnum.MYTHIC, 2, 4],
|
|
40
|
-
[RarityEnum.SPECIAL, 3,
|
|
40
|
+
[RarityEnum.SPECIAL, 3, 4]
|
|
41
41
|
])('%s: role count always within [%i, %i]', (rarity, min, max) => {
|
|
42
42
|
const stats = flatStats(50);
|
|
43
43
|
for (let i = 0; i < ITERATIONS; i++) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const TEAM_NAME_MIN_LENGTH = 3;
|
|
2
|
+
export declare const TEAM_NAME_MAX_LENGTH = 40;
|
|
3
|
+
/**
|
|
4
|
+
* Allowed team-name characters: Unicode letters (any script — Latin incl. ñ and
|
|
5
|
+
* Polish letters, Cyrillic, Greek, etc.), combining marks, digits, spaces, and
|
|
6
|
+
* basic name punctuation (hyphen, apostrophe, period).
|
|
7
|
+
*/
|
|
8
|
+
export declare const TEAM_NAME_PATTERN: RegExp;
|
|
9
|
+
/** Trim surrounding whitespace and normalise to NFC for consistent Unicode handling. */
|
|
10
|
+
export declare function normalizeTeamName(raw: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Validate a raw (untrimmed) team name. Normalises first (NFC + trim), then checks
|
|
13
|
+
* length, the allowed character set, and that it contains at least one letter or digit.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isValidTeamName(raw: string): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const TEAM_NAME_MIN_LENGTH = 3;
|
|
2
|
+
export const TEAM_NAME_MAX_LENGTH = 40;
|
|
3
|
+
/**
|
|
4
|
+
* Allowed team-name characters: Unicode letters (any script — Latin incl. ñ and
|
|
5
|
+
* Polish letters, Cyrillic, Greek, etc.), combining marks, digits, spaces, and
|
|
6
|
+
* basic name punctuation (hyphen, apostrophe, period).
|
|
7
|
+
*/
|
|
8
|
+
export const TEAM_NAME_PATTERN = /^[\p{L}\p{M}\p{N} .'-]+$/u;
|
|
9
|
+
const HAS_ALPHANUMERIC = /[\p{L}\p{N}]/u;
|
|
10
|
+
/** Trim surrounding whitespace and normalise to NFC for consistent Unicode handling. */
|
|
11
|
+
export function normalizeTeamName(raw) {
|
|
12
|
+
return raw.normalize('NFC').trim();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Validate a raw (untrimmed) team name. Normalises first (NFC + trim), then checks
|
|
16
|
+
* length, the allowed character set, and that it contains at least one letter or digit.
|
|
17
|
+
*/
|
|
18
|
+
export function isValidTeamName(raw) {
|
|
19
|
+
const name = normalizeTeamName(raw);
|
|
20
|
+
return (name.length >= TEAM_NAME_MIN_LENGTH &&
|
|
21
|
+
name.length <= TEAM_NAME_MAX_LENGTH &&
|
|
22
|
+
TEAM_NAME_PATTERN.test(name) &&
|
|
23
|
+
HAS_ALPHANUMERIC.test(name));
|
|
24
|
+
}
|