volleyballsimtypes 0.0.471 → 0.0.474

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.
Files changed (47) hide show
  1. package/dist/cjs/src/api/index.d.ts +2 -0
  2. package/dist/cjs/src/data/models/tactics.d.ts +2 -0
  3. package/dist/cjs/src/data/transformers/rally-event-injury.test.js +27 -0
  4. package/dist/cjs/src/data/transformers/rally-event.d.ts +1 -0
  5. package/dist/cjs/src/data/transformers/rally-event.js +16 -8
  6. package/dist/cjs/src/service/event/in-play-event.d.ts +1 -0
  7. package/dist/cjs/src/service/event/schemas/block.z.d.ts +1 -0
  8. package/dist/cjs/src/service/event/schemas/incident.z.d.ts +1 -0
  9. package/dist/cjs/src/service/event/schemas/incident.z.js +4 -1
  10. package/dist/cjs/src/service/event/schemas/reception.z.d.ts +1 -0
  11. package/dist/cjs/src/service/event/schemas/serve.z.d.ts +1 -0
  12. package/dist/cjs/src/service/event/schemas/set.z.d.ts +1 -0
  13. package/dist/cjs/src/service/event/schemas/spike.z.d.ts +1 -0
  14. package/dist/cjs/src/service/team/libero-sub.d.ts +4 -1
  15. package/dist/cjs/src/service/team/pinch-condition.d.ts +12 -2
  16. package/dist/cjs/src/service/team/pinch-condition.js +10 -2
  17. package/dist/cjs/src/service/team/schemas/designated-sub.z.d.ts +13 -1
  18. package/dist/cjs/src/service/team/schemas/designated-sub.z.js +3 -1
  19. package/dist/cjs/src/service/team/schemas/libero-sub.z.d.ts +94 -0
  20. package/dist/cjs/src/service/team/schemas/libero-sub.z.js +23 -6
  21. package/dist/cjs/src/service/team/schemas/libero-sub.z.test.js +33 -2
  22. package/dist/cjs/src/service/team/schemas/tactics.z.d.ts +68 -0
  23. package/dist/cjs/src/service/team/schemas/team.z.d.ts +68 -0
  24. package/dist/esm/src/api/index.d.ts +2 -0
  25. package/dist/esm/src/data/models/tactics.d.ts +2 -0
  26. package/dist/esm/src/data/transformers/rally-event-injury.test.js +29 -2
  27. package/dist/esm/src/data/transformers/rally-event.d.ts +1 -0
  28. package/dist/esm/src/data/transformers/rally-event.js +16 -8
  29. package/dist/esm/src/service/event/in-play-event.d.ts +1 -0
  30. package/dist/esm/src/service/event/schemas/block.z.d.ts +1 -0
  31. package/dist/esm/src/service/event/schemas/incident.z.d.ts +1 -0
  32. package/dist/esm/src/service/event/schemas/incident.z.js +4 -1
  33. package/dist/esm/src/service/event/schemas/reception.z.d.ts +1 -0
  34. package/dist/esm/src/service/event/schemas/serve.z.d.ts +1 -0
  35. package/dist/esm/src/service/event/schemas/set.z.d.ts +1 -0
  36. package/dist/esm/src/service/event/schemas/spike.z.d.ts +1 -0
  37. package/dist/esm/src/service/team/libero-sub.d.ts +4 -1
  38. package/dist/esm/src/service/team/pinch-condition.d.ts +12 -2
  39. package/dist/esm/src/service/team/pinch-condition.js +9 -1
  40. package/dist/esm/src/service/team/schemas/designated-sub.z.d.ts +13 -1
  41. package/dist/esm/src/service/team/schemas/designated-sub.z.js +4 -2
  42. package/dist/esm/src/service/team/schemas/libero-sub.z.d.ts +94 -0
  43. package/dist/esm/src/service/team/schemas/libero-sub.z.js +23 -6
  44. package/dist/esm/src/service/team/schemas/libero-sub.z.test.js +33 -2
  45. package/dist/esm/src/service/team/schemas/tactics.z.d.ts +68 -0
  46. package/dist/esm/src/service/team/schemas/team.z.d.ts +68 -0
  47. package/package.json +1 -1
@@ -50,6 +50,9 @@ export declare const TacticsInputSchema: z.ZodObject<{
50
50
  }, z.core.$strip>, z.ZodObject<{
51
51
  type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
52
52
  score: z.ZodNumber;
53
+ }, z.core.$strip>, z.ZodObject<{
54
+ type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
55
+ phase: z.ZodEnum<typeof import("..").MatchPhase>;
53
56
  }, z.core.$strip>], "type">>>;
54
57
  conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
55
58
  }, z.core.$strip>>>;
@@ -86,6 +89,9 @@ export declare const TacticsInputSchema: z.ZodObject<{
86
89
  }, z.core.$strip>, z.ZodObject<{
87
90
  type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
88
91
  score: z.ZodNumber;
92
+ }, z.core.$strip>, z.ZodObject<{
93
+ type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
94
+ phase: z.ZodEnum<typeof import("..").MatchPhase>;
89
95
  }, z.core.$strip>], "type">>>;
90
96
  conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
91
97
  starter: z.ZodCustom<Player, Player>;
@@ -98,15 +104,77 @@ export declare const TacticsInputSchema: z.ZodObject<{
98
104
  NEVER: "NEVER";
99
105
  FATIGUE: "FATIGUE";
100
106
  ALWAYS: "ALWAYS";
107
+ CONDITIONS: "CONDITIONS";
101
108
  }>;
102
109
  fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
110
+ conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
111
+ type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
112
+ }, z.core.$strip>, z.ZodObject<{
113
+ type: z.ZodLiteral<import("..").PinchConditionType.TEAM_SET_POINT>;
114
+ margin: z.ZodNumber;
115
+ opponent: z.ZodEnum<typeof import("..").OpponentRelation>;
116
+ }, z.core.$strip>, z.ZodObject<{
117
+ type: z.ZodLiteral<import("..").PinchConditionType.OPPONENT_SET_POINT>;
118
+ margin: z.ZodNumber;
119
+ }, z.core.$strip>, z.ZodObject<{
120
+ type: z.ZodLiteral<import("..").PinchConditionType.SCORE_DIFF>;
121
+ direction: z.ZodEnum<typeof import("..").ScoreDirection>;
122
+ points: z.ZodNumber;
123
+ }, z.core.$strip>, z.ZodObject<{
124
+ type: z.ZodLiteral<import("..").PinchConditionType.AFTER_ROTATIONS>;
125
+ rotations: z.ZodNumber;
126
+ }, z.core.$strip>, z.ZodObject<{
127
+ type: z.ZodLiteral<import("..").PinchConditionType.FROM_SET>;
128
+ set: z.ZodNumber;
129
+ }, z.core.$strip>, z.ZodObject<{
130
+ type: z.ZodLiteral<import("..").PinchConditionType.MIN_OWN_SCORE>;
131
+ score: z.ZodNumber;
132
+ }, z.core.$strip>, z.ZodObject<{
133
+ type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
134
+ score: z.ZodNumber;
135
+ }, z.core.$strip>, z.ZodObject<{
136
+ type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
137
+ phase: z.ZodEnum<typeof import("..").MatchPhase>;
138
+ }, z.core.$strip>], "type">>>;
139
+ conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
103
140
  }, z.core.$strip>>>;
104
141
  mode: z.ZodEnum<{
105
142
  NEVER: "NEVER";
106
143
  FATIGUE: "FATIGUE";
107
144
  ALWAYS: "ALWAYS";
145
+ CONDITIONS: "CONDITIONS";
108
146
  }>;
109
147
  fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
148
+ conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
149
+ type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
150
+ }, z.core.$strip>, z.ZodObject<{
151
+ type: z.ZodLiteral<import("..").PinchConditionType.TEAM_SET_POINT>;
152
+ margin: z.ZodNumber;
153
+ opponent: z.ZodEnum<typeof import("..").OpponentRelation>;
154
+ }, z.core.$strip>, z.ZodObject<{
155
+ type: z.ZodLiteral<import("..").PinchConditionType.OPPONENT_SET_POINT>;
156
+ margin: z.ZodNumber;
157
+ }, z.core.$strip>, z.ZodObject<{
158
+ type: z.ZodLiteral<import("..").PinchConditionType.SCORE_DIFF>;
159
+ direction: z.ZodEnum<typeof import("..").ScoreDirection>;
160
+ points: z.ZodNumber;
161
+ }, z.core.$strip>, z.ZodObject<{
162
+ type: z.ZodLiteral<import("..").PinchConditionType.AFTER_ROTATIONS>;
163
+ rotations: z.ZodNumber;
164
+ }, z.core.$strip>, z.ZodObject<{
165
+ type: z.ZodLiteral<import("..").PinchConditionType.FROM_SET>;
166
+ set: z.ZodNumber;
167
+ }, z.core.$strip>, z.ZodObject<{
168
+ type: z.ZodLiteral<import("..").PinchConditionType.MIN_OWN_SCORE>;
169
+ score: z.ZodNumber;
170
+ }, z.core.$strip>, z.ZodObject<{
171
+ type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
172
+ score: z.ZodNumber;
173
+ }, z.core.$strip>, z.ZodObject<{
174
+ type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
175
+ phase: z.ZodEnum<typeof import("..").MatchPhase>;
176
+ }, z.core.$strip>], "type">>>;
177
+ conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
110
178
  }, z.core.$strip>>;
111
179
  liberoReplacementSets: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodCustom<Player, Player>>>>;
112
180
  rotationSystem: z.ZodDefault<z.ZodEnum<typeof RotationSystemEnum>>;
@@ -58,6 +58,9 @@ export declare const TeamInputSchema: z.ZodObject<{
58
58
  }, z.core.$strip>, z.ZodObject<{
59
59
  type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
60
60
  score: z.ZodNumber;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
63
+ phase: z.ZodEnum<typeof import("..").MatchPhase>;
61
64
  }, z.core.$strip>], "type">>>;
62
65
  conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
63
66
  }, z.core.$strip>>>;
@@ -94,6 +97,9 @@ export declare const TeamInputSchema: z.ZodObject<{
94
97
  }, z.core.$strip>, z.ZodObject<{
95
98
  type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
96
99
  score: z.ZodNumber;
100
+ }, z.core.$strip>, z.ZodObject<{
101
+ type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
102
+ phase: z.ZodEnum<typeof import("..").MatchPhase>;
97
103
  }, z.core.$strip>], "type">>>;
98
104
  conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
99
105
  starter: z.ZodCustom<Player, Player>;
@@ -106,15 +112,77 @@ export declare const TeamInputSchema: z.ZodObject<{
106
112
  NEVER: "NEVER";
107
113
  FATIGUE: "FATIGUE";
108
114
  ALWAYS: "ALWAYS";
115
+ CONDITIONS: "CONDITIONS";
109
116
  }>;
110
117
  fatigueBand: z.ZodOptional<z.ZodEnum<typeof import("..").EnergyBand>>;
118
+ conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
119
+ type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
120
+ }, z.core.$strip>, z.ZodObject<{
121
+ type: z.ZodLiteral<import("..").PinchConditionType.TEAM_SET_POINT>;
122
+ margin: z.ZodNumber;
123
+ opponent: z.ZodEnum<typeof import("..").OpponentRelation>;
124
+ }, z.core.$strip>, z.ZodObject<{
125
+ type: z.ZodLiteral<import("..").PinchConditionType.OPPONENT_SET_POINT>;
126
+ margin: z.ZodNumber;
127
+ }, z.core.$strip>, z.ZodObject<{
128
+ type: z.ZodLiteral<import("..").PinchConditionType.SCORE_DIFF>;
129
+ direction: z.ZodEnum<typeof import("..").ScoreDirection>;
130
+ points: z.ZodNumber;
131
+ }, z.core.$strip>, z.ZodObject<{
132
+ type: z.ZodLiteral<import("..").PinchConditionType.AFTER_ROTATIONS>;
133
+ rotations: z.ZodNumber;
134
+ }, z.core.$strip>, z.ZodObject<{
135
+ type: z.ZodLiteral<import("..").PinchConditionType.FROM_SET>;
136
+ set: z.ZodNumber;
137
+ }, z.core.$strip>, z.ZodObject<{
138
+ type: z.ZodLiteral<import("..").PinchConditionType.MIN_OWN_SCORE>;
139
+ score: z.ZodNumber;
140
+ }, z.core.$strip>, z.ZodObject<{
141
+ type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
142
+ score: z.ZodNumber;
143
+ }, z.core.$strip>, z.ZodObject<{
144
+ type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
145
+ phase: z.ZodEnum<typeof import("..").MatchPhase>;
146
+ }, z.core.$strip>], "type">>>;
147
+ conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
111
148
  }, z.core.$strip>>>;
112
149
  mode: z.ZodEnum<{
113
150
  NEVER: "NEVER";
114
151
  FATIGUE: "FATIGUE";
115
152
  ALWAYS: "ALWAYS";
153
+ CONDITIONS: "CONDITIONS";
116
154
  }>;
117
155
  fatigueBand: z.ZodOptional<z.ZodEnum<typeof import("..").EnergyBand>>;
156
+ conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
157
+ type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
158
+ }, z.core.$strip>, z.ZodObject<{
159
+ type: z.ZodLiteral<import("..").PinchConditionType.TEAM_SET_POINT>;
160
+ margin: z.ZodNumber;
161
+ opponent: z.ZodEnum<typeof import("..").OpponentRelation>;
162
+ }, z.core.$strip>, z.ZodObject<{
163
+ type: z.ZodLiteral<import("..").PinchConditionType.OPPONENT_SET_POINT>;
164
+ margin: z.ZodNumber;
165
+ }, z.core.$strip>, z.ZodObject<{
166
+ type: z.ZodLiteral<import("..").PinchConditionType.SCORE_DIFF>;
167
+ direction: z.ZodEnum<typeof import("..").ScoreDirection>;
168
+ points: z.ZodNumber;
169
+ }, z.core.$strip>, z.ZodObject<{
170
+ type: z.ZodLiteral<import("..").PinchConditionType.AFTER_ROTATIONS>;
171
+ rotations: z.ZodNumber;
172
+ }, z.core.$strip>, z.ZodObject<{
173
+ type: z.ZodLiteral<import("..").PinchConditionType.FROM_SET>;
174
+ set: z.ZodNumber;
175
+ }, z.core.$strip>, z.ZodObject<{
176
+ type: z.ZodLiteral<import("..").PinchConditionType.MIN_OWN_SCORE>;
177
+ score: z.ZodNumber;
178
+ }, z.core.$strip>, z.ZodObject<{
179
+ type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
180
+ score: z.ZodNumber;
181
+ }, z.core.$strip>, z.ZodObject<{
182
+ type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
183
+ phase: z.ZodEnum<typeof import("..").MatchPhase>;
184
+ }, z.core.$strip>], "type">>>;
185
+ conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
118
186
  }, z.core.$strip>>;
119
187
  liberoReplacementSets: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodCustom<Player, Player>>>>;
120
188
  rotationSystem: z.ZodDefault<z.ZodEnum<typeof import("..").RotationSystemEnum>>;
@@ -114,6 +114,8 @@ export interface ApiInjuryReplacement {
114
114
  export interface ApiLiberoSetSubConfig {
115
115
  mode: LiberoSubMode;
116
116
  fatigueBand?: EnergyBand;
117
+ conditions?: PinchCondition[];
118
+ conditionLogic?: ConditionLogic;
117
119
  }
118
120
  export interface ApiLiberoSubConfig extends ApiLiberoSetSubConfig {
119
121
  sets?: ApiLiberoSetSubConfig[];
@@ -47,6 +47,8 @@ export interface InjuryReplacementAttributes {
47
47
  export interface LiberoSetSubConfigAttributes {
48
48
  mode: LiberoSubMode;
49
49
  fatigueBand?: EnergyBand;
50
+ conditions?: PinchCondition[];
51
+ conditionLogic?: ConditionLogic;
50
52
  }
51
53
  export interface LiberoSubConfigAttributes extends LiberoSetSubConfigAttributes {
52
54
  sets?: LiberoSetSubConfigAttributes[];
@@ -1,7 +1,7 @@
1
1
  import { describe, it, expect } from '@jest/globals';
2
2
  import { v4 as uuidv4 } from 'uuid';
3
- import { EventTypeEnum, Serve, ServeFailureEnum, ServeTypeEnum, Spike, SpikeFailureEnum, SpikeTypeEnum, Substitution } from '../../service';
4
- import { transformToCompact, transformToServe, transformToSpike, transformToSubstitution } from './rally-event';
3
+ import { Block, BlockFailureEnum, BlockTypeEnum, EventTypeEnum, Serve, ServeFailureEnum, ServeTypeEnum, Spike, SpikeFailureEnum, SpikeTypeEnum, Substitution } from '../../service';
4
+ import { transformToBlock, transformToCompact, transformToServe, transformToSpike, transformToSubstitution } from './rally-event';
5
5
  describe('rally-event compact round trip — injury substitution marker', () => {
6
6
  const playerIn = uuidv4();
7
7
  const playerOut = uuidv4();
@@ -74,6 +74,33 @@ describe('rally-event compact round trip — incident marker on the causing even
74
74
  const decoded = transformToSpike(legacy, roster);
75
75
  expect(decoded.incident).toBeUndefined();
76
76
  });
77
+ it('packs a non-actor blocker incident with the hurt player under h and round-trips it', () => {
78
+ const lead = uuidv4();
79
+ const helper = uuidv4();
80
+ const blockRoster = [lead, helper];
81
+ const blockIndex = new Map(blockRoster.map((id, i) => [id, i]));
82
+ const block = Block.create({
83
+ playerId: lead,
84
+ blockers: [lead, helper],
85
+ score: 48,
86
+ target: 8,
87
+ failure: BlockFailureEnum.NO_FAILURE,
88
+ type: BlockTypeEnum.DOUBLE,
89
+ incident: { kind: 'KNOCK', severity: 3, playerId: helper }
90
+ });
91
+ const compact = transformToCompact(block, blockIndex);
92
+ expect(compact.i).toBe(13);
93
+ expect(compact.h).toBe(1);
94
+ const decoded = transformToBlock(compact, blockRoster);
95
+ expect(decoded.incident).toEqual({ kind: 'KNOCK', severity: 3, playerId: helper });
96
+ });
97
+ it('omits h when the hurt player IS the event actor', () => {
98
+ const compact = transformToCompact(makeSpike({ kind: 'INJURY', severity: 2, playerId }), playerIndex);
99
+ expect(compact.i).toBe(2);
100
+ expect('h' in compact).toBe(false);
101
+ const decoded = transformToSpike(compact, roster);
102
+ expect(decoded.incident).toEqual({ kind: 'INJURY', severity: 2 });
103
+ });
77
104
  it('rejects an out-of-range or malformed incident at the schema', () => {
78
105
  expect(() => makeSpike({ kind: 'INJURY', severity: 5 })).toThrow(/INVALID_SPIKE/);
79
106
  expect(() => makeSpike({ kind: 'INJURY', severity: 0 })).toThrow(/INVALID_SPIKE/);
@@ -11,6 +11,7 @@ export interface CompactEvent {
11
11
  o?: number;
12
12
  j?: number;
13
13
  i?: number;
14
+ h?: number;
14
15
  }
15
16
  export declare function transformToCompact(evt: RallyEvent, playerIndex: Map<string, number>): CompactEvent;
16
17
  export declare function transformToBlock(event: CompactEvent, roster: string[]): Block;
@@ -5,10 +5,14 @@ function incidentToCompact(incident) {
5
5
  return undefined;
6
6
  return incident.kind === 'KNOCK' ? 10 + incident.severity : incident.severity;
7
7
  }
8
- function incidentFromCompact(i) {
8
+ function incidentFromCompact(i, h, roster) {
9
9
  if (i == null)
10
10
  return undefined;
11
- return i >= 10 ? { kind: 'KNOCK', severity: i - 10 } : { kind: 'INJURY', severity: i };
11
+ const playerId = h != null && roster != null ? roster[h] : undefined;
12
+ return {
13
+ ...(i >= 10 ? { kind: 'KNOCK', severity: i - 10 } : { kind: 'INJURY', severity: i }),
14
+ ...(playerId != null ? { playerId } : {})
15
+ };
12
16
  }
13
17
  export function transformToCompact(evt, playerIndex) {
14
18
  const out = {
@@ -21,8 +25,12 @@ export function transformToCompact(evt, playerIndex) {
21
25
  out.a = evt.target;
22
26
  out.s = evt.score;
23
27
  const i = incidentToCompact(evt.incident);
24
- if (i != null)
28
+ if (i != null) {
25
29
  out.i = i;
30
+ if (evt.incident?.playerId != null && evt.incident.playerId !== evt.playerId) {
31
+ out.h = playerIndex.get(evt.incident.playerId);
32
+ }
33
+ }
26
34
  if (evt instanceof Block) {
27
35
  out.b = evt.blockers.map(id => playerIndex.get(id));
28
36
  }
@@ -46,7 +54,7 @@ export function transformToBlock(event, roster) {
46
54
  target: event.a,
47
55
  blockers: (event.b ?? []).map(i => roster[i]),
48
56
  score: event.s,
49
- incident: incidentFromCompact(event.i)
57
+ incident: incidentFromCompact(event.i, event.h, roster)
50
58
  });
51
59
  }
52
60
  export function transformToLiberoReplacement(event, roster) {
@@ -63,7 +71,7 @@ export function transformToReception(event, roster) {
63
71
  playerId: roster[event.p],
64
72
  target: event.a,
65
73
  score: event.s,
66
- incident: incidentFromCompact(event.i)
74
+ incident: incidentFromCompact(event.i, event.h, roster)
67
75
  });
68
76
  }
69
77
  export function transformToServe(event, roster) {
@@ -73,7 +81,7 @@ export function transformToServe(event, roster) {
73
81
  playerId: roster[event.p],
74
82
  target: event.a,
75
83
  score: event.s,
76
- incident: incidentFromCompact(event.i)
84
+ incident: incidentFromCompact(event.i, event.h, roster)
77
85
  });
78
86
  }
79
87
  export function transformToSet(event, roster) {
@@ -83,7 +91,7 @@ export function transformToSet(event, roster) {
83
91
  playerId: roster[event.p],
84
92
  target: event.a,
85
93
  score: event.s,
86
- incident: incidentFromCompact(event.i)
94
+ incident: incidentFromCompact(event.i, event.h, roster)
87
95
  });
88
96
  }
89
97
  export function transformToSpike(event, roster) {
@@ -93,7 +101,7 @@ export function transformToSpike(event, roster) {
93
101
  playerId: roster[event.p],
94
102
  target: event.a,
95
103
  score: event.s,
96
- incident: incidentFromCompact(event.i)
104
+ incident: incidentFromCompact(event.i, event.h, roster)
97
105
  });
98
106
  }
99
107
  export function transformToSubstitution(event, roster) {
@@ -4,6 +4,7 @@ import { Trait } from '../player';
4
4
  export interface EventIncident {
5
5
  readonly kind: 'KNOCK' | 'INJURY';
6
6
  readonly severity: number;
7
+ readonly playerId?: string;
7
8
  }
8
9
  export interface InPlayEventOpts extends RallyEventOpts {
9
10
  readonly target: CourtTarget;
@@ -33,6 +33,7 @@ export declare const BlockInputSchema: z.ZodObject<{
33
33
  INJURY: "INJURY";
34
34
  }>;
35
35
  severity: z.ZodNumber;
36
+ playerId: z.ZodOptional<z.ZodUUID>;
36
37
  }, z.core.$strip>>;
37
38
  }, z.core.$strip>;
38
39
  export type BlockInput = z.infer<typeof BlockInputSchema>;
@@ -5,5 +5,6 @@ export declare const EventIncidentSchema: z.ZodObject<{
5
5
  INJURY: "INJURY";
6
6
  }>;
7
7
  severity: z.ZodNumber;
8
+ playerId: z.ZodOptional<z.ZodUUID>;
8
9
  }, z.core.$strip>;
9
10
  export type EventIncidentInput = z.infer<typeof EventIncidentSchema>;
@@ -4,5 +4,8 @@ import { z } from 'zod';
4
4
  // InjurySeverityEnum value (1-4).
5
5
  export const EventIncidentSchema = z.object({
6
6
  kind: z.enum(['KNOCK', 'INJURY']),
7
- severity: z.number().int().min(1).max(4)
7
+ severity: z.number().int().min(1).max(4),
8
+ // Who got hurt, ONLY when it is not the event's actor (a secondary blocker on a multi-player block);
9
+ // absent = the event's own playerId.
10
+ playerId: z.uuid().optional()
8
11
  }).refine(v => v.kind !== 'KNOCK' || v.severity <= 3, { message: 'INVALID_KNOCK_TIER' });
@@ -32,6 +32,7 @@ export declare const ReceptionInputSchema: z.ZodObject<{
32
32
  INJURY: "INJURY";
33
33
  }>;
34
34
  severity: z.ZodNumber;
35
+ playerId: z.ZodOptional<z.ZodUUID>;
35
36
  }, z.core.$strip>>;
36
37
  }, z.core.$strip>;
37
38
  export type ReceptionInput = z.infer<typeof ReceptionInputSchema>;
@@ -32,6 +32,7 @@ export declare const ServeInputSchema: z.ZodObject<{
32
32
  INJURY: "INJURY";
33
33
  }>;
34
34
  severity: z.ZodNumber;
35
+ playerId: z.ZodOptional<z.ZodUUID>;
35
36
  }, z.core.$strip>>;
36
37
  }, z.core.$strip>;
37
38
  export type ServeInput = z.infer<typeof ServeInputSchema>;
@@ -32,6 +32,7 @@ export declare const SetInputSchema: z.ZodObject<{
32
32
  INJURY: "INJURY";
33
33
  }>;
34
34
  severity: z.ZodNumber;
35
+ playerId: z.ZodOptional<z.ZodUUID>;
35
36
  }, z.core.$strip>>;
36
37
  }, z.core.$strip>;
37
38
  export type SetInput = z.infer<typeof SetInputSchema>;
@@ -32,6 +32,7 @@ export declare const SpikeInputSchema: z.ZodObject<{
32
32
  INJURY: "INJURY";
33
33
  }>;
34
34
  severity: z.ZodNumber;
35
+ playerId: z.ZodOptional<z.ZodUUID>;
35
36
  }, z.core.$strip>>;
36
37
  }, z.core.$strip>;
37
38
  export type SpikeInput = z.infer<typeof SpikeInputSchema>;
@@ -1,8 +1,11 @@
1
1
  import { EnergyBand } from './energy-band';
2
- export type LiberoSubMode = 'NEVER' | 'FATIGUE' | 'ALWAYS';
2
+ import { ConditionLogic, PinchCondition } from './pinch-condition';
3
+ export type LiberoSubMode = 'NEVER' | 'FATIGUE' | 'ALWAYS' | 'CONDITIONS';
3
4
  export interface LiberoSetSubConfig {
4
5
  readonly mode: LiberoSubMode;
5
6
  readonly fatigueBand?: EnergyBand;
7
+ readonly conditions?: PinchCondition[];
8
+ readonly conditionLogic?: ConditionLogic;
6
9
  }
7
10
  export interface LiberoSubConfig extends LiberoSetSubConfig {
8
11
  readonly sets?: LiberoSetSubConfig[];
@@ -6,7 +6,12 @@ export declare enum PinchConditionType {
6
6
  AFTER_ROTATIONS = "AFTER_ROTATIONS",// from the team's Nth serve turn in the set onward
7
7
  FROM_SET = "FROM_SET",// only set N or later
8
8
  MIN_OWN_SCORE = "MIN_OWN_SCORE",// only once own score >= N
9
- MIN_OPPONENT_SCORE = "MIN_OPPONENT_SCORE"
9
+ MIN_OPPONENT_SCORE = "MIN_OPPONENT_SCORE",// only once opponent score >= N
10
+ PHASE = "PHASE"
11
+ }
12
+ export declare enum MatchPhase {
13
+ SERVING = "SERVING",
14
+ RECEIVING = "RECEIVING"
10
15
  }
11
16
  export declare enum OpponentRelation {
12
17
  AHEAD = "AHEAD",
@@ -50,7 +55,11 @@ export interface MinOpponentScoreCondition {
50
55
  readonly type: PinchConditionType.MIN_OPPONENT_SCORE;
51
56
  readonly score: number;
52
57
  }
53
- export type PinchCondition = AsapCondition | TeamSetPointCondition | OpponentSetPointCondition | ScoreDiffCondition | AfterRotationsCondition | FromSetCondition | MinOwnScoreCondition | MinOpponentScoreCondition;
58
+ export interface PhaseCondition {
59
+ readonly type: PinchConditionType.PHASE;
60
+ readonly phase: MatchPhase;
61
+ }
62
+ export type PinchCondition = AsapCondition | TeamSetPointCondition | OpponentSetPointCondition | ScoreDiffCondition | AfterRotationsCondition | FromSetCondition | MinOwnScoreCondition | MinOpponentScoreCondition | PhaseCondition;
54
63
  export type ConditionLogic = 'ALL' | 'ANY';
55
64
  export interface PinchSetState {
56
65
  readonly ownScore: number;
@@ -58,4 +67,5 @@ export interface PinchSetState {
58
67
  readonly setTarget: number;
59
68
  readonly setNumber: number;
60
69
  readonly ownServeTurns: number;
70
+ readonly phase: MatchPhase;
61
71
  }
@@ -10,8 +10,16 @@ export var PinchConditionType;
10
10
  PinchConditionType["AFTER_ROTATIONS"] = "AFTER_ROTATIONS";
11
11
  PinchConditionType["FROM_SET"] = "FROM_SET";
12
12
  PinchConditionType["MIN_OWN_SCORE"] = "MIN_OWN_SCORE";
13
- PinchConditionType["MIN_OPPONENT_SCORE"] = "MIN_OPPONENT_SCORE"; // only once opponent score >= N
13
+ PinchConditionType["MIN_OPPONENT_SCORE"] = "MIN_OPPONENT_SCORE";
14
+ PinchConditionType["PHASE"] = "PHASE"; // the team is serving or receiving this rally (used by the libero deployment rule)
14
15
  })(PinchConditionType || (PinchConditionType = {}));
16
+ // Which side of the rally the team is on. Known at each dead ball: the serving team is SERVING, the other
17
+ // RECEIVING. Consumed by the PHASE condition (libero deployment); pinch servers always evaluate while SERVING.
18
+ export var MatchPhase;
19
+ (function (MatchPhase) {
20
+ MatchPhase["SERVING"] = "SERVING";
21
+ MatchPhase["RECEIVING"] = "RECEIVING";
22
+ })(MatchPhase || (MatchPhase = {}));
15
23
  export var OpponentRelation;
16
24
  (function (OpponentRelation) {
17
25
  OpponentRelation["AHEAD"] = "AHEAD";
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { Player } from '../../player';
3
3
  import { EnergyBand } from '../energy-band';
4
- import { OpponentRelation, PinchConditionType, ScoreDirection } from '../pinch-condition';
4
+ import { MatchPhase, OpponentRelation, PinchConditionType, ScoreDirection } from '../pinch-condition';
5
5
  export declare const SubBandSchema: z.ZodUnion<readonly [z.ZodEnum<typeof EnergyBand>, z.ZodLiteral<"NEVER">]>;
6
6
  export declare const PinchConditionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7
7
  type: z.ZodLiteral<PinchConditionType.ASAP>;
@@ -28,6 +28,9 @@ export declare const PinchConditionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
28
28
  }, z.core.$strip>, z.ZodObject<{
29
29
  type: z.ZodLiteral<PinchConditionType.MIN_OPPONENT_SCORE>;
30
30
  score: z.ZodNumber;
31
+ }, z.core.$strip>, z.ZodObject<{
32
+ type: z.ZodLiteral<PinchConditionType.PHASE>;
33
+ phase: z.ZodEnum<typeof MatchPhase>;
31
34
  }, z.core.$strip>], "type">;
32
35
  export declare const ConditionLogicSchema: z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>;
33
36
  export declare const SubModeSchema: z.ZodEnum<{
@@ -69,6 +72,9 @@ export declare const SetSubConfigSchema: z.ZodObject<{
69
72
  }, z.core.$strip>, z.ZodObject<{
70
73
  type: z.ZodLiteral<PinchConditionType.MIN_OPPONENT_SCORE>;
71
74
  score: z.ZodNumber;
75
+ }, z.core.$strip>, z.ZodObject<{
76
+ type: z.ZodLiteral<PinchConditionType.PHASE>;
77
+ phase: z.ZodEnum<typeof MatchPhase>;
72
78
  }, z.core.$strip>], "type">>>;
73
79
  conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
74
80
  }, z.core.$strip>;
@@ -107,6 +113,9 @@ export declare const DesignatedSubSchema: z.ZodObject<{
107
113
  }, z.core.$strip>, z.ZodObject<{
108
114
  type: z.ZodLiteral<PinchConditionType.MIN_OPPONENT_SCORE>;
109
115
  score: z.ZodNumber;
116
+ }, z.core.$strip>, z.ZodObject<{
117
+ type: z.ZodLiteral<PinchConditionType.PHASE>;
118
+ phase: z.ZodEnum<typeof MatchPhase>;
110
119
  }, z.core.$strip>], "type">>>;
111
120
  conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
112
121
  }, z.core.$strip>>>;
@@ -143,6 +152,9 @@ export declare const DesignatedSubSchema: z.ZodObject<{
143
152
  }, z.core.$strip>, z.ZodObject<{
144
153
  type: z.ZodLiteral<PinchConditionType.MIN_OPPONENT_SCORE>;
145
154
  score: z.ZodNumber;
155
+ }, z.core.$strip>, z.ZodObject<{
156
+ type: z.ZodLiteral<PinchConditionType.PHASE>;
157
+ phase: z.ZodEnum<typeof MatchPhase>;
146
158
  }, z.core.$strip>], "type">>>;
147
159
  conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
148
160
  starter: z.ZodCustom<Player, Player>;
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { Player } from '../../player';
3
3
  import { EnergyBand } from '../energy-band';
4
- import { OpponentRelation, PinchConditionType, ScoreDirection } from '../pinch-condition';
4
+ import { MatchPhase, OpponentRelation, PinchConditionType, ScoreDirection } from '../pinch-condition';
5
5
  const playerInstanceSchema = z.custom((v) => v instanceof Player, {
6
6
  message: 'INVALID_PLAYER_INSTANCE'
7
7
  });
@@ -14,7 +14,9 @@ export const PinchConditionSchema = z.discriminatedUnion('type', [
14
14
  z.object({ type: z.literal(PinchConditionType.AFTER_ROTATIONS), rotations: z.number().int().min(1).max(6) }),
15
15
  z.object({ type: z.literal(PinchConditionType.FROM_SET), set: z.number().int().min(1).max(5) }),
16
16
  z.object({ type: z.literal(PinchConditionType.MIN_OWN_SCORE), score: z.number().int().min(0).max(40) }),
17
- z.object({ type: z.literal(PinchConditionType.MIN_OPPONENT_SCORE), score: z.number().int().min(0).max(40) })
17
+ z.object({ type: z.literal(PinchConditionType.MIN_OPPONENT_SCORE), score: z.number().int().min(0).max(40) }),
18
+ // PHASE is used by the libero deployment rule (which reuses this schema); pinch servers never offer it.
19
+ z.object({ type: z.literal(PinchConditionType.PHASE), phase: z.nativeEnum(MatchPhase) })
18
20
  ]);
19
21
  export const ConditionLogicSchema = z.union([z.literal('ALL'), z.literal('ANY')]);
20
22
  export const SubModeSchema = z.enum(['FATIGUE', 'PINCH', 'NEVER']);