volleyballsimtypes 0.0.404 → 0.0.406
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.
|
@@ -88,15 +88,27 @@ function buildPinchServerSubs(pinchServerSubs, roster) {
|
|
|
88
88
|
return map;
|
|
89
89
|
}
|
|
90
90
|
function transformToObject(model, roster) {
|
|
91
|
+
const lineup = transformToLineup(model.lineup, roster);
|
|
92
|
+
// A second libero only makes sense alongside a starting libero (LIBERO_ZONE). Edge/legacy data can carry a
|
|
93
|
+
// second_libero (and its swap config) with no starting libero -- e.g. the starting libero was removed
|
|
94
|
+
// without clearing it -- which fails validation on load and would crash the whole sim batch. Drop the
|
|
95
|
+
// orphaned pair so the team still loads (it just plays without liberos); the next tactics save rewrites it.
|
|
96
|
+
// Drop the second libero when there's no starting libero, OR when the L2 player is no longer on the roster
|
|
97
|
+
// (e.g. retired/dismissed) -- both leave it orphaned. Use roster.find (not findPlayer) so a gone L2 yields
|
|
98
|
+
// undefined instead of throwing.
|
|
99
|
+
const hasStartingLibero = lineup[service_1.CourtPosition.LIBERO_ZONE] != null;
|
|
100
|
+
const secondLibero = (hasStartingLibero && model.second_libero != null)
|
|
101
|
+
? roster.find((p) => p.id === model.second_libero)
|
|
102
|
+
: undefined;
|
|
91
103
|
return service_1.Tactics.create({
|
|
92
104
|
substitutionTolerance: model.substitution_tolerance,
|
|
93
105
|
receiveRotationOffset: model.receive_rotation_offset,
|
|
94
|
-
lineup
|
|
106
|
+
lineup,
|
|
95
107
|
liberoReplacements: model.libero_replacements.map((lr) => findPlayer(lr, roster)),
|
|
96
108
|
pinchServerSubs: buildPinchServerSubs(model.pinch_server_subs, roster),
|
|
97
109
|
substitutionBand: model.substitution_band,
|
|
98
|
-
secondLibero
|
|
99
|
-
liberoSub: model.libero_sub ?? undefined,
|
|
110
|
+
secondLibero,
|
|
111
|
+
liberoSub: secondLibero != null ? (model.libero_sub ?? undefined) : undefined,
|
|
100
112
|
liberoReplacementSets: model.libero_replacement_sets?.map(set => set.map((id) => findPlayer(id, roster))),
|
|
101
113
|
designatedSubs: (model.designated_subs ?? []).map(d => ({
|
|
102
114
|
starter: findPlayer(d.starterId, roster),
|
|
@@ -84,15 +84,27 @@ function buildPinchServerSubs(pinchServerSubs, roster) {
|
|
|
84
84
|
return map;
|
|
85
85
|
}
|
|
86
86
|
function transformToObject(model, roster) {
|
|
87
|
+
const lineup = transformToLineup(model.lineup, roster);
|
|
88
|
+
// A second libero only makes sense alongside a starting libero (LIBERO_ZONE). Edge/legacy data can carry a
|
|
89
|
+
// second_libero (and its swap config) with no starting libero -- e.g. the starting libero was removed
|
|
90
|
+
// without clearing it -- which fails validation on load and would crash the whole sim batch. Drop the
|
|
91
|
+
// orphaned pair so the team still loads (it just plays without liberos); the next tactics save rewrites it.
|
|
92
|
+
// Drop the second libero when there's no starting libero, OR when the L2 player is no longer on the roster
|
|
93
|
+
// (e.g. retired/dismissed) -- both leave it orphaned. Use roster.find (not findPlayer) so a gone L2 yields
|
|
94
|
+
// undefined instead of throwing.
|
|
95
|
+
const hasStartingLibero = lineup[CourtPosition.LIBERO_ZONE] != null;
|
|
96
|
+
const secondLibero = (hasStartingLibero && model.second_libero != null)
|
|
97
|
+
? roster.find((p) => p.id === model.second_libero)
|
|
98
|
+
: undefined;
|
|
87
99
|
return Tactics.create({
|
|
88
100
|
substitutionTolerance: model.substitution_tolerance,
|
|
89
101
|
receiveRotationOffset: model.receive_rotation_offset,
|
|
90
|
-
lineup
|
|
102
|
+
lineup,
|
|
91
103
|
liberoReplacements: model.libero_replacements.map((lr) => findPlayer(lr, roster)),
|
|
92
104
|
pinchServerSubs: buildPinchServerSubs(model.pinch_server_subs, roster),
|
|
93
105
|
substitutionBand: model.substitution_band,
|
|
94
|
-
secondLibero
|
|
95
|
-
liberoSub: model.libero_sub ?? undefined,
|
|
106
|
+
secondLibero,
|
|
107
|
+
liberoSub: secondLibero != null ? (model.libero_sub ?? undefined) : undefined,
|
|
96
108
|
liberoReplacementSets: model.libero_replacement_sets?.map(set => set.map((id) => findPlayer(id, roster))),
|
|
97
109
|
designatedSubs: (model.designated_subs ?? []).map(d => ({
|
|
98
110
|
starter: findPlayer(d.starterId, roster),
|