volleyballsimtypes 0.0.366 → 0.0.367
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.
|
@@ -74,9 +74,14 @@ class TeamGenerator {
|
|
|
74
74
|
throw new Error('NOT_ENOUGH_PLAYERS_FOR_TEAM_1');
|
|
75
75
|
const out = {};
|
|
76
76
|
let courtPlayer;
|
|
77
|
-
const
|
|
78
|
-
.
|
|
79
|
-
.
|
|
77
|
+
const byRole = players
|
|
78
|
+
.filter((player) => player.roles.includes(player_1.RoleEnum.LIBERO))
|
|
79
|
+
.sort(TeamGenerator.comparePlayers([player_1.RoleEnum.LIBERO]));
|
|
80
|
+
// If no player was assigned the LIBERO role (can happen with low-rarity teams),
|
|
81
|
+
// fall back to the player with the best LIBERO score.
|
|
82
|
+
const libero = byRole.length > 0
|
|
83
|
+
? byRole[0]
|
|
84
|
+
: [...players].sort(TeamGenerator.comparePlayers([player_1.RoleEnum.LIBERO]))[0];
|
|
80
85
|
if (libero == null)
|
|
81
86
|
throw new Error('UNDEFINED_LIBERO');
|
|
82
87
|
const filtered = players.filter(player => player.id !== libero.id);
|
|
@@ -68,9 +68,14 @@ export class TeamGenerator {
|
|
|
68
68
|
throw new Error('NOT_ENOUGH_PLAYERS_FOR_TEAM_1');
|
|
69
69
|
const out = {};
|
|
70
70
|
let courtPlayer;
|
|
71
|
-
const
|
|
72
|
-
.
|
|
73
|
-
.
|
|
71
|
+
const byRole = players
|
|
72
|
+
.filter((player) => player.roles.includes(RoleEnum.LIBERO))
|
|
73
|
+
.sort(TeamGenerator.comparePlayers([RoleEnum.LIBERO]));
|
|
74
|
+
// If no player was assigned the LIBERO role (can happen with low-rarity teams),
|
|
75
|
+
// fall back to the player with the best LIBERO score.
|
|
76
|
+
const libero = byRole.length > 0
|
|
77
|
+
? byRole[0]
|
|
78
|
+
: [...players].sort(TeamGenerator.comparePlayers([RoleEnum.LIBERO]))[0];
|
|
74
79
|
if (libero == null)
|
|
75
80
|
throw new Error('UNDEFINED_LIBERO');
|
|
76
81
|
const filtered = players.filter(player => player.id !== libero.id);
|