volleyballsimtypes 0.0.404 → 0.0.407

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.
@@ -21,6 +21,8 @@ function transformToType(position) {
21
21
  return 'MIDDLE_BACK';
22
22
  case service_1.CourtPosition.RIGHT_BACK:
23
23
  return 'RIGHT_BACK';
24
+ case service_1.CourtPosition.RESERVE_LIBERO:
25
+ return 'RESERVE_LIBERO';
24
26
  default:
25
27
  throw new Error('UNKNOWN_ROLE');
26
28
  }
@@ -1,6 +1,6 @@
1
1
  import { MatchSetAttributes, MatchSetModel } from '../models';
2
2
  import { MatchSet } from '../../service';
3
- export type CourtPositionType = 'NOT_IN_COURT' | 'LIBERO_ZONE' | 'LEFT_FRONT' | 'MIDDLE_FRONT' | 'RIGHT_FRONT' | 'LEFT_BACK' | 'MIDDLE_BACK' | 'RIGHT_BACK';
3
+ export type CourtPositionType = 'NOT_IN_COURT' | 'LIBERO_ZONE' | 'LEFT_FRONT' | 'MIDDLE_FRONT' | 'RIGHT_FRONT' | 'LEFT_BACK' | 'MIDDLE_BACK' | 'RIGHT_BACK' | 'RESERVE_LIBERO';
4
4
  export type Side = 'HOME' | 'AWAY';
5
5
  export interface PlayerPositionAttributes {
6
6
  player_id: string;
@@ -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),
@@ -17,6 +17,8 @@ function transformToType(position) {
17
17
  return 'MIDDLE_BACK';
18
18
  case CourtPosition.RIGHT_BACK:
19
19
  return 'RIGHT_BACK';
20
+ case CourtPosition.RESERVE_LIBERO:
21
+ return 'RESERVE_LIBERO';
20
22
  default:
21
23
  throw new Error('UNKNOWN_ROLE');
22
24
  }
@@ -1,6 +1,6 @@
1
1
  import { MatchSetAttributes, MatchSetModel } from '../models';
2
2
  import { MatchSet } from '../../service';
3
- export type CourtPositionType = 'NOT_IN_COURT' | 'LIBERO_ZONE' | 'LEFT_FRONT' | 'MIDDLE_FRONT' | 'RIGHT_FRONT' | 'LEFT_BACK' | 'MIDDLE_BACK' | 'RIGHT_BACK';
3
+ export type CourtPositionType = 'NOT_IN_COURT' | 'LIBERO_ZONE' | 'LEFT_FRONT' | 'MIDDLE_FRONT' | 'RIGHT_FRONT' | 'LEFT_BACK' | 'MIDDLE_BACK' | 'RIGHT_BACK' | 'RESERVE_LIBERO';
4
4
  export type Side = 'HOME' | 'AWAY';
5
5
  export interface PlayerPositionAttributes {
6
6
  player_id: string;
@@ -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),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.404",
3
+ "version": "0.0.407",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",