volleyballsimtypes 0.0.403 → 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: transformToLineup(model.lineup, roster),
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: model.second_libero != null ? findPlayer(model.second_libero, roster) : undefined,
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),
@@ -10,7 +10,8 @@ export declare enum CourtPosition {
10
10
  RIGHT_FRONT = 2,
11
11
  LEFT_BACK = 5,
12
12
  MIDDLE_BACK = 6,
13
- RIGHT_BACK = 1
13
+ RIGHT_BACK = 1,
14
+ RESERVE_LIBERO = 8
14
15
  }
15
16
  export declare enum CourtTarget {
16
17
  NO_TARGET = 0,
@@ -23,6 +23,10 @@ var CourtPosition;
23
23
  CourtPosition[CourtPosition["LEFT_BACK"] = 5] = "LEFT_BACK";
24
24
  CourtPosition[CourtPosition["MIDDLE_BACK"] = 6] = "MIDDLE_BACK";
25
25
  CourtPosition[CourtPosition["RIGHT_BACK"] = 1] = "RIGHT_BACK";
26
+ // The off-court member of the libero pair: the second libero held in reserve, or the starting libero
27
+ // once the second libero is swapped in for a set. Distinct from NOT_IN_COURT so it is never counted as
28
+ // one of the (max 6) bench subs.
29
+ CourtPosition[CourtPosition["RESERVE_LIBERO"] = 8] = "RESERVE_LIBERO";
26
30
  })(CourtPosition || (exports.CourtPosition = CourtPosition = {}));
27
31
  var CourtTarget;
28
32
  (function (CourtTarget) {
@@ -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: transformToLineup(model.lineup, roster),
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: model.second_libero != null ? findPlayer(model.second_libero, roster) : undefined,
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),
@@ -10,7 +10,8 @@ export declare enum CourtPosition {
10
10
  RIGHT_FRONT = 2,
11
11
  LEFT_BACK = 5,
12
12
  MIDDLE_BACK = 6,
13
- RIGHT_BACK = 1
13
+ RIGHT_BACK = 1,
14
+ RESERVE_LIBERO = 8
14
15
  }
15
16
  export declare enum CourtTarget {
16
17
  NO_TARGET = 0,
@@ -14,6 +14,10 @@ export var CourtPosition;
14
14
  CourtPosition[CourtPosition["LEFT_BACK"] = 5] = "LEFT_BACK";
15
15
  CourtPosition[CourtPosition["MIDDLE_BACK"] = 6] = "MIDDLE_BACK";
16
16
  CourtPosition[CourtPosition["RIGHT_BACK"] = 1] = "RIGHT_BACK";
17
+ // The off-court member of the libero pair: the second libero held in reserve, or the starting libero
18
+ // once the second libero is swapped in for a set. Distinct from NOT_IN_COURT so it is never counted as
19
+ // one of the (max 6) bench subs.
20
+ CourtPosition[CourtPosition["RESERVE_LIBERO"] = 8] = "RESERVE_LIBERO";
17
21
  })(CourtPosition || (CourtPosition = {}));
18
22
  export var CourtTarget;
19
23
  (function (CourtTarget) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.403",
3
+ "version": "0.0.406",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",