volleyballsimtypes 0.0.448 → 0.0.449
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/player-generator.js +1 -1
- package/dist/cjs/src/service/player/role.d.ts +1 -1
- package/dist/cjs/src/service/player/role.js +7 -1
- package/dist/esm/src/service/player/player-generator.js +1 -1
- package/dist/esm/src/service/player/role.d.ts +1 -1
- package/dist/esm/src/service/player/role.js +7 -1
- package/package.json +1 -1
|
@@ -304,7 +304,7 @@ class PlayerGenerator {
|
|
|
304
304
|
const rarity = _rarity ?? rollRarity({ legendaryPity: 0, mythicPity: 0, specialPity: 0 }).rarity;
|
|
305
305
|
const name = (0, utils_1.generatePlayerName)(country.locales, 1)[0];
|
|
306
306
|
const stats = PlayerGenerator.generatePerformance(rarity, role);
|
|
307
|
-
const roles = (0, role_1.assignRoles)(stats, rarity);
|
|
307
|
+
const roles = (0, role_1.assignRoles)(stats, rarity, role);
|
|
308
308
|
const traits = (0, trait_1.assignTraits)(roles, rarity, maxTraits);
|
|
309
309
|
const birthAge = (0, node_crypto_1.randomInt)(15, 21);
|
|
310
310
|
const declineProfile = decline_1.declineProfiles[(0, node_crypto_1.randomInt)(0, decline_1.declineProfiles.length)];
|
|
@@ -14,7 +14,7 @@ export interface RolesFormula {
|
|
|
14
14
|
weight: PerformanceStatsParams;
|
|
15
15
|
}
|
|
16
16
|
export declare function calculateRoleScore(stats: PerformanceStats, role: Role): number;
|
|
17
|
-
export declare function assignRoles(stats: PerformanceStats, rarity: Rarity): Role[];
|
|
17
|
+
export declare function assignRoles(stats: PerformanceStats, rarity: Rarity, forcedRole?: Role): Role[];
|
|
18
18
|
/**
|
|
19
19
|
* Returns the role-based multiplier for a player performing a given action.
|
|
20
20
|
* When the player holds multiple roles, the least-penalising role wins.
|
|
@@ -43,7 +43,7 @@ function getRoleCountRange(rarity) {
|
|
|
43
43
|
default: return [1, 1];
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
function assignRoles(stats, rarity) {
|
|
46
|
+
function assignRoles(stats, rarity, forcedRole) {
|
|
47
47
|
const scores = Object.values(RoleEnum)
|
|
48
48
|
.map((role) => ({
|
|
49
49
|
role,
|
|
@@ -52,6 +52,12 @@ function assignRoles(stats, rarity) {
|
|
|
52
52
|
.sort((x, y) => y.score - x.score);
|
|
53
53
|
const [min, max] = getRoleCountRange(rarity);
|
|
54
54
|
const count = min + Math.floor(Math.random() * (max - min + 1));
|
|
55
|
+
// A forced role (role pick, wishlist proc, team seeding) must be the player's primary role.
|
|
56
|
+
// Remaining slots fill with the top-scoring other roles so multi-role rarity flavour is kept.
|
|
57
|
+
if (forcedRole != null) {
|
|
58
|
+
const others = scores.map(s => s.role).filter(r => r !== forcedRole);
|
|
59
|
+
return [forcedRole, ...others].slice(0, count);
|
|
60
|
+
}
|
|
55
61
|
return scores.slice(0, count).map(s => s.role);
|
|
56
62
|
}
|
|
57
63
|
// ─── Role event penalties ─────────────────────────────────────────────────────
|
|
@@ -298,7 +298,7 @@ export class PlayerGenerator {
|
|
|
298
298
|
const rarity = _rarity ?? rollRarity({ legendaryPity: 0, mythicPity: 0, specialPity: 0 }).rarity;
|
|
299
299
|
const name = generatePlayerName(country.locales, 1)[0];
|
|
300
300
|
const stats = PlayerGenerator.generatePerformance(rarity, role);
|
|
301
|
-
const roles = assignRoles(stats, rarity);
|
|
301
|
+
const roles = assignRoles(stats, rarity, role);
|
|
302
302
|
const traits = assignTraits(roles, rarity, maxTraits);
|
|
303
303
|
const birthAge = randomInt(15, 21);
|
|
304
304
|
const declineProfile = declineProfiles[randomInt(0, declineProfiles.length)];
|
|
@@ -14,7 +14,7 @@ export interface RolesFormula {
|
|
|
14
14
|
weight: PerformanceStatsParams;
|
|
15
15
|
}
|
|
16
16
|
export declare function calculateRoleScore(stats: PerformanceStats, role: Role): number;
|
|
17
|
-
export declare function assignRoles(stats: PerformanceStats, rarity: Rarity): Role[];
|
|
17
|
+
export declare function assignRoles(stats: PerformanceStats, rarity: Rarity, forcedRole?: Role): Role[];
|
|
18
18
|
/**
|
|
19
19
|
* Returns the role-based multiplier for a player performing a given action.
|
|
20
20
|
* When the player holds multiple roles, the least-penalising role wins.
|
|
@@ -33,7 +33,7 @@ function getRoleCountRange(rarity) {
|
|
|
33
33
|
default: return [1, 1];
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
export function assignRoles(stats, rarity) {
|
|
36
|
+
export function assignRoles(stats, rarity, forcedRole) {
|
|
37
37
|
const scores = Object.values(RoleEnum)
|
|
38
38
|
.map((role) => ({
|
|
39
39
|
role,
|
|
@@ -42,6 +42,12 @@ export function assignRoles(stats, rarity) {
|
|
|
42
42
|
.sort((x, y) => y.score - x.score);
|
|
43
43
|
const [min, max] = getRoleCountRange(rarity);
|
|
44
44
|
const count = min + Math.floor(Math.random() * (max - min + 1));
|
|
45
|
+
// A forced role (role pick, wishlist proc, team seeding) must be the player's primary role.
|
|
46
|
+
// Remaining slots fill with the top-scoring other roles so multi-role rarity flavour is kept.
|
|
47
|
+
if (forcedRole != null) {
|
|
48
|
+
const others = scores.map(s => s.role).filter(r => r !== forcedRole);
|
|
49
|
+
return [forcedRole, ...others].slice(0, count);
|
|
50
|
+
}
|
|
45
51
|
return scores.slice(0, count).map(s => s.role);
|
|
46
52
|
}
|
|
47
53
|
// ─── Role event penalties ─────────────────────────────────────────────────────
|