volleyballsimtypes 0.0.473 → 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.
- package/dist/cjs/src/api/index.d.ts +2 -0
- package/dist/cjs/src/data/models/tactics.d.ts +2 -0
- package/dist/cjs/src/service/team/libero-sub.d.ts +4 -1
- package/dist/cjs/src/service/team/pinch-condition.d.ts +12 -2
- package/dist/cjs/src/service/team/pinch-condition.js +10 -2
- package/dist/cjs/src/service/team/schemas/designated-sub.z.d.ts +13 -1
- package/dist/cjs/src/service/team/schemas/designated-sub.z.js +3 -1
- package/dist/cjs/src/service/team/schemas/libero-sub.z.d.ts +94 -0
- package/dist/cjs/src/service/team/schemas/libero-sub.z.js +23 -6
- package/dist/cjs/src/service/team/schemas/libero-sub.z.test.js +33 -2
- package/dist/cjs/src/service/team/schemas/tactics.z.d.ts +68 -0
- package/dist/cjs/src/service/team/schemas/team.z.d.ts +68 -0
- package/dist/esm/src/api/index.d.ts +2 -0
- package/dist/esm/src/data/models/tactics.d.ts +2 -0
- package/dist/esm/src/service/team/libero-sub.d.ts +4 -1
- package/dist/esm/src/service/team/pinch-condition.d.ts +12 -2
- package/dist/esm/src/service/team/pinch-condition.js +9 -1
- package/dist/esm/src/service/team/schemas/designated-sub.z.d.ts +13 -1
- package/dist/esm/src/service/team/schemas/designated-sub.z.js +4 -2
- package/dist/esm/src/service/team/schemas/libero-sub.z.d.ts +94 -0
- package/dist/esm/src/service/team/schemas/libero-sub.z.js +23 -6
- package/dist/esm/src/service/team/schemas/libero-sub.z.test.js +33 -2
- package/dist/esm/src/service/team/schemas/tactics.z.d.ts +68 -0
- package/dist/esm/src/service/team/schemas/team.z.d.ts +68 -0
- package/package.json +1 -1
|
@@ -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,8 +1,11 @@
|
|
|
1
1
|
import { EnergyBand } from './energy-band';
|
|
2
|
-
|
|
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
|
|
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
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// wins back the serve, out the moment the serve is lost). Each condition is evaluated against the live set
|
|
4
4
|
// state; a pinch entry combines them with ALL (every condition must hold) or ANY (one is enough).
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ScoreDirection = exports.OpponentRelation = exports.PinchConditionType = void 0;
|
|
6
|
+
exports.ScoreDirection = exports.OpponentRelation = exports.MatchPhase = exports.PinchConditionType = void 0;
|
|
7
7
|
var PinchConditionType;
|
|
8
8
|
(function (PinchConditionType) {
|
|
9
9
|
PinchConditionType["ASAP"] = "ASAP";
|
|
@@ -13,8 +13,16 @@ var PinchConditionType;
|
|
|
13
13
|
PinchConditionType["AFTER_ROTATIONS"] = "AFTER_ROTATIONS";
|
|
14
14
|
PinchConditionType["FROM_SET"] = "FROM_SET";
|
|
15
15
|
PinchConditionType["MIN_OWN_SCORE"] = "MIN_OWN_SCORE";
|
|
16
|
-
PinchConditionType["MIN_OPPONENT_SCORE"] = "MIN_OPPONENT_SCORE";
|
|
16
|
+
PinchConditionType["MIN_OPPONENT_SCORE"] = "MIN_OPPONENT_SCORE";
|
|
17
|
+
PinchConditionType["PHASE"] = "PHASE"; // the team is serving or receiving this rally (used by the libero deployment rule)
|
|
17
18
|
})(PinchConditionType || (exports.PinchConditionType = PinchConditionType = {}));
|
|
19
|
+
// Which side of the rally the team is on. Known at each dead ball: the serving team is SERVING, the other
|
|
20
|
+
// RECEIVING. Consumed by the PHASE condition (libero deployment); pinch servers always evaluate while SERVING.
|
|
21
|
+
var MatchPhase;
|
|
22
|
+
(function (MatchPhase) {
|
|
23
|
+
MatchPhase["SERVING"] = "SERVING";
|
|
24
|
+
MatchPhase["RECEIVING"] = "RECEIVING";
|
|
25
|
+
})(MatchPhase || (exports.MatchPhase = MatchPhase = {}));
|
|
18
26
|
var OpponentRelation;
|
|
19
27
|
(function (OpponentRelation) {
|
|
20
28
|
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>;
|
|
@@ -17,7 +17,9 @@ exports.PinchConditionSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
17
17
|
zod_1.z.object({ type: zod_1.z.literal(pinch_condition_1.PinchConditionType.AFTER_ROTATIONS), rotations: zod_1.z.number().int().min(1).max(6) }),
|
|
18
18
|
zod_1.z.object({ type: zod_1.z.literal(pinch_condition_1.PinchConditionType.FROM_SET), set: zod_1.z.number().int().min(1).max(5) }),
|
|
19
19
|
zod_1.z.object({ type: zod_1.z.literal(pinch_condition_1.PinchConditionType.MIN_OWN_SCORE), score: zod_1.z.number().int().min(0).max(40) }),
|
|
20
|
-
zod_1.z.object({ type: zod_1.z.literal(pinch_condition_1.PinchConditionType.MIN_OPPONENT_SCORE), score: zod_1.z.number().int().min(0).max(40) })
|
|
20
|
+
zod_1.z.object({ type: zod_1.z.literal(pinch_condition_1.PinchConditionType.MIN_OPPONENT_SCORE), score: zod_1.z.number().int().min(0).max(40) }),
|
|
21
|
+
// PHASE is used by the libero deployment rule (which reuses this schema); pinch servers never offer it.
|
|
22
|
+
zod_1.z.object({ type: zod_1.z.literal(pinch_condition_1.PinchConditionType.PHASE), phase: zod_1.z.nativeEnum(pinch_condition_1.MatchPhase) })
|
|
21
23
|
]);
|
|
22
24
|
exports.ConditionLogicSchema = zod_1.z.union([zod_1.z.literal('ALL'), zod_1.z.literal('ANY')]);
|
|
23
25
|
exports.SubModeSchema = zod_1.z.enum(['FATIGUE', 'PINCH', 'NEVER']);
|
|
@@ -4,14 +4,46 @@ export declare const LiberoSubModeSchema: z.ZodEnum<{
|
|
|
4
4
|
NEVER: "NEVER";
|
|
5
5
|
FATIGUE: "FATIGUE";
|
|
6
6
|
ALWAYS: "ALWAYS";
|
|
7
|
+
CONDITIONS: "CONDITIONS";
|
|
7
8
|
}>;
|
|
8
9
|
export declare const LiberoSetSubConfigSchema: z.ZodObject<{
|
|
9
10
|
mode: z.ZodEnum<{
|
|
10
11
|
NEVER: "NEVER";
|
|
11
12
|
FATIGUE: "FATIGUE";
|
|
12
13
|
ALWAYS: "ALWAYS";
|
|
14
|
+
CONDITIONS: "CONDITIONS";
|
|
13
15
|
}>;
|
|
14
16
|
fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
17
|
+
conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
18
|
+
type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
|
|
19
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
+
type: z.ZodLiteral<import("..").PinchConditionType.TEAM_SET_POINT>;
|
|
21
|
+
margin: z.ZodNumber;
|
|
22
|
+
opponent: z.ZodEnum<typeof import("..").OpponentRelation>;
|
|
23
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<import("..").PinchConditionType.OPPONENT_SET_POINT>;
|
|
25
|
+
margin: z.ZodNumber;
|
|
26
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
+
type: z.ZodLiteral<import("..").PinchConditionType.SCORE_DIFF>;
|
|
28
|
+
direction: z.ZodEnum<typeof import("..").ScoreDirection>;
|
|
29
|
+
points: z.ZodNumber;
|
|
30
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
+
type: z.ZodLiteral<import("..").PinchConditionType.AFTER_ROTATIONS>;
|
|
32
|
+
rotations: z.ZodNumber;
|
|
33
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
34
|
+
type: z.ZodLiteral<import("..").PinchConditionType.FROM_SET>;
|
|
35
|
+
set: z.ZodNumber;
|
|
36
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
37
|
+
type: z.ZodLiteral<import("..").PinchConditionType.MIN_OWN_SCORE>;
|
|
38
|
+
score: z.ZodNumber;
|
|
39
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
40
|
+
type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
|
|
41
|
+
score: z.ZodNumber;
|
|
42
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
+
type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
|
|
44
|
+
phase: z.ZodEnum<typeof import("..").MatchPhase>;
|
|
45
|
+
}, z.core.$strip>], "type">>>;
|
|
46
|
+
conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
15
47
|
}, z.core.$strip>;
|
|
16
48
|
export declare const LiberoSubConfigSchema: z.ZodObject<{
|
|
17
49
|
sets: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -19,13 +51,75 @@ export declare const LiberoSubConfigSchema: z.ZodObject<{
|
|
|
19
51
|
NEVER: "NEVER";
|
|
20
52
|
FATIGUE: "FATIGUE";
|
|
21
53
|
ALWAYS: "ALWAYS";
|
|
54
|
+
CONDITIONS: "CONDITIONS";
|
|
22
55
|
}>;
|
|
23
56
|
fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
57
|
+
conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
58
|
+
type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
|
|
59
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<import("..").PinchConditionType.TEAM_SET_POINT>;
|
|
61
|
+
margin: z.ZodNumber;
|
|
62
|
+
opponent: z.ZodEnum<typeof import("..").OpponentRelation>;
|
|
63
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
64
|
+
type: z.ZodLiteral<import("..").PinchConditionType.OPPONENT_SET_POINT>;
|
|
65
|
+
margin: z.ZodNumber;
|
|
66
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
67
|
+
type: z.ZodLiteral<import("..").PinchConditionType.SCORE_DIFF>;
|
|
68
|
+
direction: z.ZodEnum<typeof import("..").ScoreDirection>;
|
|
69
|
+
points: z.ZodNumber;
|
|
70
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
71
|
+
type: z.ZodLiteral<import("..").PinchConditionType.AFTER_ROTATIONS>;
|
|
72
|
+
rotations: z.ZodNumber;
|
|
73
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
74
|
+
type: z.ZodLiteral<import("..").PinchConditionType.FROM_SET>;
|
|
75
|
+
set: z.ZodNumber;
|
|
76
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
77
|
+
type: z.ZodLiteral<import("..").PinchConditionType.MIN_OWN_SCORE>;
|
|
78
|
+
score: z.ZodNumber;
|
|
79
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
80
|
+
type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
|
|
81
|
+
score: z.ZodNumber;
|
|
82
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
83
|
+
type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
|
|
84
|
+
phase: z.ZodEnum<typeof import("..").MatchPhase>;
|
|
85
|
+
}, z.core.$strip>], "type">>>;
|
|
86
|
+
conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
24
87
|
}, z.core.$strip>>>;
|
|
25
88
|
mode: z.ZodEnum<{
|
|
26
89
|
NEVER: "NEVER";
|
|
27
90
|
FATIGUE: "FATIGUE";
|
|
28
91
|
ALWAYS: "ALWAYS";
|
|
92
|
+
CONDITIONS: "CONDITIONS";
|
|
29
93
|
}>;
|
|
30
94
|
fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
95
|
+
conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
96
|
+
type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
|
|
97
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
98
|
+
type: z.ZodLiteral<import("..").PinchConditionType.TEAM_SET_POINT>;
|
|
99
|
+
margin: z.ZodNumber;
|
|
100
|
+
opponent: z.ZodEnum<typeof import("..").OpponentRelation>;
|
|
101
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
102
|
+
type: z.ZodLiteral<import("..").PinchConditionType.OPPONENT_SET_POINT>;
|
|
103
|
+
margin: z.ZodNumber;
|
|
104
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
105
|
+
type: z.ZodLiteral<import("..").PinchConditionType.SCORE_DIFF>;
|
|
106
|
+
direction: z.ZodEnum<typeof import("..").ScoreDirection>;
|
|
107
|
+
points: z.ZodNumber;
|
|
108
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
109
|
+
type: z.ZodLiteral<import("..").PinchConditionType.AFTER_ROTATIONS>;
|
|
110
|
+
rotations: z.ZodNumber;
|
|
111
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
112
|
+
type: z.ZodLiteral<import("..").PinchConditionType.FROM_SET>;
|
|
113
|
+
set: z.ZodNumber;
|
|
114
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
115
|
+
type: z.ZodLiteral<import("..").PinchConditionType.MIN_OWN_SCORE>;
|
|
116
|
+
score: z.ZodNumber;
|
|
117
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
118
|
+
type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
|
|
119
|
+
score: z.ZodNumber;
|
|
120
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
121
|
+
type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
|
|
122
|
+
phase: z.ZodEnum<typeof import("..").MatchPhase>;
|
|
123
|
+
}, z.core.$strip>], "type">>>;
|
|
124
|
+
conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
31
125
|
}, z.core.$strip>;
|
|
@@ -3,18 +3,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LiberoSubConfigSchema = exports.LiberoSetSubConfigSchema = exports.LiberoSubModeSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const energy_band_1 = require("../energy-band");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
//
|
|
6
|
+
const designated_sub_z_1 = require("./designated-sub.z");
|
|
7
|
+
exports.LiberoSubModeSchema = zod_1.z.enum(['NEVER', 'FATIGUE', 'ALWAYS', 'CONDITIONS']);
|
|
8
|
+
// Fields shared by the all-sets config and each per-set config. The swapped-in player is always the dedicated
|
|
9
|
+
// `secondLibero`, so there is no bench to validate; the CONDITIONS mode reuses the pinch-server condition
|
|
10
|
+
// catalog (PinchConditionSchema, which includes the libero-only PHASE condition) + ALL/ANY logic.
|
|
10
11
|
const liberoSetSubConfigShape = {
|
|
11
12
|
mode: exports.LiberoSubModeSchema,
|
|
12
13
|
// fatigue mode only (absent => the team default `substitutionBand`):
|
|
13
|
-
fatigueBand: zod_1.z.nativeEnum(energy_band_1.EnergyBand).optional()
|
|
14
|
+
fatigueBand: zod_1.z.nativeEnum(energy_band_1.EnergyBand).optional(),
|
|
15
|
+
// conditions mode only:
|
|
16
|
+
conditions: zod_1.z.array(designated_sub_z_1.PinchConditionSchema).optional(),
|
|
17
|
+
conditionLogic: designated_sub_z_1.ConditionLogicSchema.optional()
|
|
14
18
|
};
|
|
15
|
-
|
|
19
|
+
// CONDITIONS mode needs at least one condition (mirrors the designated-sub pinch refine).
|
|
20
|
+
function refineConditions(data, ctx) {
|
|
21
|
+
if (data.mode !== 'CONDITIONS')
|
|
22
|
+
return;
|
|
23
|
+
if (data.conditions == null || data.conditions.length === 0) {
|
|
24
|
+
ctx.addIssue({ code: 'custom', message: 'LIBERO_CONDITIONS_REQUIRE_A_CONDITION', path: ['conditions'] });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.LiberoSetSubConfigSchema = zod_1.z.object(liberoSetSubConfigShape).superRefine(refineConditions);
|
|
16
28
|
exports.LiberoSubConfigSchema = zod_1.z.object({
|
|
17
29
|
...liberoSetSubConfigShape,
|
|
18
30
|
// Optional per-set overrides (index 0 = set 1 ... index 4 = set 5); absent => the flat config for all sets.
|
|
19
31
|
sets: zod_1.z.array(exports.LiberoSetSubConfigSchema).max(5).optional()
|
|
32
|
+
}).superRefine((data, ctx) => {
|
|
33
|
+
// The flat config is the fallback for any set a partial `sets` array doesn't cover, so validate it whenever
|
|
34
|
+
// `sets` is absent or covers fewer than 5 sets (each present per-set config is validated by its own schema).
|
|
35
|
+
if (data.sets == null || data.sets.length < 5)
|
|
36
|
+
refineConditions(data, ctx);
|
|
20
37
|
});
|
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const globals_1 = require("@jest/globals");
|
|
4
4
|
const libero_sub_z_1 = require("./libero-sub.z");
|
|
5
5
|
const energy_band_1 = require("../energy-band");
|
|
6
|
+
const pinch_condition_1 = require("../pinch-condition");
|
|
6
7
|
(0, globals_1.describe)('LiberoSubModeSchema', () => {
|
|
7
|
-
(0, globals_1.it)('accepts NEVER, FATIGUE and
|
|
8
|
-
for (const mode of ['NEVER', 'FATIGUE', 'ALWAYS']) {
|
|
8
|
+
(0, globals_1.it)('accepts NEVER, FATIGUE, ALWAYS and CONDITIONS', () => {
|
|
9
|
+
for (const mode of ['NEVER', 'FATIGUE', 'ALWAYS', 'CONDITIONS']) {
|
|
9
10
|
(0, globals_1.expect)(libero_sub_z_1.LiberoSubModeSchema.safeParse(mode).success).toBe(true);
|
|
10
11
|
}
|
|
11
12
|
});
|
|
@@ -23,6 +24,36 @@ const energy_band_1 = require("../energy-band");
|
|
|
23
24
|
(0, globals_1.it)('rejects an unknown band', () => {
|
|
24
25
|
(0, globals_1.expect)(libero_sub_z_1.LiberoSetSubConfigSchema.safeParse({ mode: 'FATIGUE', fatigueBand: 'SLEEPY' }).success).toBe(false);
|
|
25
26
|
});
|
|
27
|
+
(0, globals_1.it)('accepts CONDITIONS with a PHASE condition (serve/receive split)', () => {
|
|
28
|
+
const res = libero_sub_z_1.LiberoSetSubConfigSchema.safeParse({
|
|
29
|
+
mode: 'CONDITIONS',
|
|
30
|
+
conditionLogic: 'ALL',
|
|
31
|
+
conditions: [{ type: pinch_condition_1.PinchConditionType.PHASE, phase: pinch_condition_1.MatchPhase.RECEIVING }]
|
|
32
|
+
});
|
|
33
|
+
(0, globals_1.expect)(res.success).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
(0, globals_1.it)('accepts CONDITIONS mixing a pinch condition and a PHASE condition', () => {
|
|
36
|
+
const res = libero_sub_z_1.LiberoSetSubConfigSchema.safeParse({
|
|
37
|
+
mode: 'CONDITIONS',
|
|
38
|
+
conditionLogic: 'ANY',
|
|
39
|
+
conditions: [
|
|
40
|
+
{ type: pinch_condition_1.PinchConditionType.MIN_OWN_SCORE, score: 20 },
|
|
41
|
+
{ type: pinch_condition_1.PinchConditionType.PHASE, phase: pinch_condition_1.MatchPhase.SERVING }
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
(0, globals_1.expect)(res.success).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
(0, globals_1.it)('rejects CONDITIONS mode with no conditions', () => {
|
|
47
|
+
(0, globals_1.expect)(libero_sub_z_1.LiberoSetSubConfigSchema.safeParse({ mode: 'CONDITIONS' }).success).toBe(false);
|
|
48
|
+
(0, globals_1.expect)(libero_sub_z_1.LiberoSetSubConfigSchema.safeParse({ mode: 'CONDITIONS', conditions: [] }).success).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
(0, globals_1.it)('rejects an invalid PHASE value', () => {
|
|
51
|
+
const res = libero_sub_z_1.LiberoSetSubConfigSchema.safeParse({
|
|
52
|
+
mode: 'CONDITIONS',
|
|
53
|
+
conditions: [{ type: pinch_condition_1.PinchConditionType.PHASE, phase: 'ATTACKING' }]
|
|
54
|
+
});
|
|
55
|
+
(0, globals_1.expect)(res.success).toBe(false);
|
|
56
|
+
});
|
|
26
57
|
});
|
|
27
58
|
(0, globals_1.describe)('LiberoSubConfigSchema', () => {
|
|
28
59
|
(0, globals_1.it)('accepts a flat config with no per-set overrides', () => {
|
|
@@ -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,8 +1,11 @@
|
|
|
1
1
|
import { EnergyBand } from './energy-band';
|
|
2
|
-
|
|
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
|
|
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";
|
|
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']);
|
|
@@ -4,14 +4,46 @@ export declare const LiberoSubModeSchema: z.ZodEnum<{
|
|
|
4
4
|
NEVER: "NEVER";
|
|
5
5
|
FATIGUE: "FATIGUE";
|
|
6
6
|
ALWAYS: "ALWAYS";
|
|
7
|
+
CONDITIONS: "CONDITIONS";
|
|
7
8
|
}>;
|
|
8
9
|
export declare const LiberoSetSubConfigSchema: z.ZodObject<{
|
|
9
10
|
mode: z.ZodEnum<{
|
|
10
11
|
NEVER: "NEVER";
|
|
11
12
|
FATIGUE: "FATIGUE";
|
|
12
13
|
ALWAYS: "ALWAYS";
|
|
14
|
+
CONDITIONS: "CONDITIONS";
|
|
13
15
|
}>;
|
|
14
16
|
fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
17
|
+
conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
18
|
+
type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
|
|
19
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
+
type: z.ZodLiteral<import("..").PinchConditionType.TEAM_SET_POINT>;
|
|
21
|
+
margin: z.ZodNumber;
|
|
22
|
+
opponent: z.ZodEnum<typeof import("..").OpponentRelation>;
|
|
23
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<import("..").PinchConditionType.OPPONENT_SET_POINT>;
|
|
25
|
+
margin: z.ZodNumber;
|
|
26
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
+
type: z.ZodLiteral<import("..").PinchConditionType.SCORE_DIFF>;
|
|
28
|
+
direction: z.ZodEnum<typeof import("..").ScoreDirection>;
|
|
29
|
+
points: z.ZodNumber;
|
|
30
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
+
type: z.ZodLiteral<import("..").PinchConditionType.AFTER_ROTATIONS>;
|
|
32
|
+
rotations: z.ZodNumber;
|
|
33
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
34
|
+
type: z.ZodLiteral<import("..").PinchConditionType.FROM_SET>;
|
|
35
|
+
set: z.ZodNumber;
|
|
36
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
37
|
+
type: z.ZodLiteral<import("..").PinchConditionType.MIN_OWN_SCORE>;
|
|
38
|
+
score: z.ZodNumber;
|
|
39
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
40
|
+
type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
|
|
41
|
+
score: z.ZodNumber;
|
|
42
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
+
type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
|
|
44
|
+
phase: z.ZodEnum<typeof import("..").MatchPhase>;
|
|
45
|
+
}, z.core.$strip>], "type">>>;
|
|
46
|
+
conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
15
47
|
}, z.core.$strip>;
|
|
16
48
|
export declare const LiberoSubConfigSchema: z.ZodObject<{
|
|
17
49
|
sets: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -19,13 +51,75 @@ export declare const LiberoSubConfigSchema: z.ZodObject<{
|
|
|
19
51
|
NEVER: "NEVER";
|
|
20
52
|
FATIGUE: "FATIGUE";
|
|
21
53
|
ALWAYS: "ALWAYS";
|
|
54
|
+
CONDITIONS: "CONDITIONS";
|
|
22
55
|
}>;
|
|
23
56
|
fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
57
|
+
conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
58
|
+
type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
|
|
59
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<import("..").PinchConditionType.TEAM_SET_POINT>;
|
|
61
|
+
margin: z.ZodNumber;
|
|
62
|
+
opponent: z.ZodEnum<typeof import("..").OpponentRelation>;
|
|
63
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
64
|
+
type: z.ZodLiteral<import("..").PinchConditionType.OPPONENT_SET_POINT>;
|
|
65
|
+
margin: z.ZodNumber;
|
|
66
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
67
|
+
type: z.ZodLiteral<import("..").PinchConditionType.SCORE_DIFF>;
|
|
68
|
+
direction: z.ZodEnum<typeof import("..").ScoreDirection>;
|
|
69
|
+
points: z.ZodNumber;
|
|
70
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
71
|
+
type: z.ZodLiteral<import("..").PinchConditionType.AFTER_ROTATIONS>;
|
|
72
|
+
rotations: z.ZodNumber;
|
|
73
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
74
|
+
type: z.ZodLiteral<import("..").PinchConditionType.FROM_SET>;
|
|
75
|
+
set: z.ZodNumber;
|
|
76
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
77
|
+
type: z.ZodLiteral<import("..").PinchConditionType.MIN_OWN_SCORE>;
|
|
78
|
+
score: z.ZodNumber;
|
|
79
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
80
|
+
type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
|
|
81
|
+
score: z.ZodNumber;
|
|
82
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
83
|
+
type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
|
|
84
|
+
phase: z.ZodEnum<typeof import("..").MatchPhase>;
|
|
85
|
+
}, z.core.$strip>], "type">>>;
|
|
86
|
+
conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
24
87
|
}, z.core.$strip>>>;
|
|
25
88
|
mode: z.ZodEnum<{
|
|
26
89
|
NEVER: "NEVER";
|
|
27
90
|
FATIGUE: "FATIGUE";
|
|
28
91
|
ALWAYS: "ALWAYS";
|
|
92
|
+
CONDITIONS: "CONDITIONS";
|
|
29
93
|
}>;
|
|
30
94
|
fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
95
|
+
conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
96
|
+
type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
|
|
97
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
98
|
+
type: z.ZodLiteral<import("..").PinchConditionType.TEAM_SET_POINT>;
|
|
99
|
+
margin: z.ZodNumber;
|
|
100
|
+
opponent: z.ZodEnum<typeof import("..").OpponentRelation>;
|
|
101
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
102
|
+
type: z.ZodLiteral<import("..").PinchConditionType.OPPONENT_SET_POINT>;
|
|
103
|
+
margin: z.ZodNumber;
|
|
104
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
105
|
+
type: z.ZodLiteral<import("..").PinchConditionType.SCORE_DIFF>;
|
|
106
|
+
direction: z.ZodEnum<typeof import("..").ScoreDirection>;
|
|
107
|
+
points: z.ZodNumber;
|
|
108
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
109
|
+
type: z.ZodLiteral<import("..").PinchConditionType.AFTER_ROTATIONS>;
|
|
110
|
+
rotations: z.ZodNumber;
|
|
111
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
112
|
+
type: z.ZodLiteral<import("..").PinchConditionType.FROM_SET>;
|
|
113
|
+
set: z.ZodNumber;
|
|
114
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
115
|
+
type: z.ZodLiteral<import("..").PinchConditionType.MIN_OWN_SCORE>;
|
|
116
|
+
score: z.ZodNumber;
|
|
117
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
118
|
+
type: z.ZodLiteral<import("..").PinchConditionType.MIN_OPPONENT_SCORE>;
|
|
119
|
+
score: z.ZodNumber;
|
|
120
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
121
|
+
type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
|
|
122
|
+
phase: z.ZodEnum<typeof import("..").MatchPhase>;
|
|
123
|
+
}, z.core.$strip>], "type">>>;
|
|
124
|
+
conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
31
125
|
}, z.core.$strip>;
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { EnergyBand } from '../energy-band';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
//
|
|
3
|
+
import { ConditionLogicSchema, PinchConditionSchema } from './designated-sub.z';
|
|
4
|
+
export const LiberoSubModeSchema = z.enum(['NEVER', 'FATIGUE', 'ALWAYS', 'CONDITIONS']);
|
|
5
|
+
// Fields shared by the all-sets config and each per-set config. The swapped-in player is always the dedicated
|
|
6
|
+
// `secondLibero`, so there is no bench to validate; the CONDITIONS mode reuses the pinch-server condition
|
|
7
|
+
// catalog (PinchConditionSchema, which includes the libero-only PHASE condition) + ALL/ANY logic.
|
|
7
8
|
const liberoSetSubConfigShape = {
|
|
8
9
|
mode: LiberoSubModeSchema,
|
|
9
10
|
// fatigue mode only (absent => the team default `substitutionBand`):
|
|
10
|
-
fatigueBand: z.nativeEnum(EnergyBand).optional()
|
|
11
|
+
fatigueBand: z.nativeEnum(EnergyBand).optional(),
|
|
12
|
+
// conditions mode only:
|
|
13
|
+
conditions: z.array(PinchConditionSchema).optional(),
|
|
14
|
+
conditionLogic: ConditionLogicSchema.optional()
|
|
11
15
|
};
|
|
12
|
-
|
|
16
|
+
// CONDITIONS mode needs at least one condition (mirrors the designated-sub pinch refine).
|
|
17
|
+
function refineConditions(data, ctx) {
|
|
18
|
+
if (data.mode !== 'CONDITIONS')
|
|
19
|
+
return;
|
|
20
|
+
if (data.conditions == null || data.conditions.length === 0) {
|
|
21
|
+
ctx.addIssue({ code: 'custom', message: 'LIBERO_CONDITIONS_REQUIRE_A_CONDITION', path: ['conditions'] });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export const LiberoSetSubConfigSchema = z.object(liberoSetSubConfigShape).superRefine(refineConditions);
|
|
13
25
|
export const LiberoSubConfigSchema = z.object({
|
|
14
26
|
...liberoSetSubConfigShape,
|
|
15
27
|
// Optional per-set overrides (index 0 = set 1 ... index 4 = set 5); absent => the flat config for all sets.
|
|
16
28
|
sets: z.array(LiberoSetSubConfigSchema).max(5).optional()
|
|
29
|
+
}).superRefine((data, ctx) => {
|
|
30
|
+
// The flat config is the fallback for any set a partial `sets` array doesn't cover, so validate it whenever
|
|
31
|
+
// `sets` is absent or covers fewer than 5 sets (each present per-set config is validated by its own schema).
|
|
32
|
+
if (data.sets == null || data.sets.length < 5)
|
|
33
|
+
refineConditions(data, ctx);
|
|
17
34
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { describe, it, expect } from '@jest/globals';
|
|
2
2
|
import { LiberoSetSubConfigSchema, LiberoSubConfigSchema, LiberoSubModeSchema } from './libero-sub.z';
|
|
3
3
|
import { EnergyBand } from '../energy-band';
|
|
4
|
+
import { MatchPhase, PinchConditionType } from '../pinch-condition';
|
|
4
5
|
describe('LiberoSubModeSchema', () => {
|
|
5
|
-
it('accepts NEVER, FATIGUE and
|
|
6
|
-
for (const mode of ['NEVER', 'FATIGUE', 'ALWAYS']) {
|
|
6
|
+
it('accepts NEVER, FATIGUE, ALWAYS and CONDITIONS', () => {
|
|
7
|
+
for (const mode of ['NEVER', 'FATIGUE', 'ALWAYS', 'CONDITIONS']) {
|
|
7
8
|
expect(LiberoSubModeSchema.safeParse(mode).success).toBe(true);
|
|
8
9
|
}
|
|
9
10
|
});
|
|
@@ -21,6 +22,36 @@ describe('LiberoSetSubConfigSchema', () => {
|
|
|
21
22
|
it('rejects an unknown band', () => {
|
|
22
23
|
expect(LiberoSetSubConfigSchema.safeParse({ mode: 'FATIGUE', fatigueBand: 'SLEEPY' }).success).toBe(false);
|
|
23
24
|
});
|
|
25
|
+
it('accepts CONDITIONS with a PHASE condition (serve/receive split)', () => {
|
|
26
|
+
const res = LiberoSetSubConfigSchema.safeParse({
|
|
27
|
+
mode: 'CONDITIONS',
|
|
28
|
+
conditionLogic: 'ALL',
|
|
29
|
+
conditions: [{ type: PinchConditionType.PHASE, phase: MatchPhase.RECEIVING }]
|
|
30
|
+
});
|
|
31
|
+
expect(res.success).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
it('accepts CONDITIONS mixing a pinch condition and a PHASE condition', () => {
|
|
34
|
+
const res = LiberoSetSubConfigSchema.safeParse({
|
|
35
|
+
mode: 'CONDITIONS',
|
|
36
|
+
conditionLogic: 'ANY',
|
|
37
|
+
conditions: [
|
|
38
|
+
{ type: PinchConditionType.MIN_OWN_SCORE, score: 20 },
|
|
39
|
+
{ type: PinchConditionType.PHASE, phase: MatchPhase.SERVING }
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
expect(res.success).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
it('rejects CONDITIONS mode with no conditions', () => {
|
|
45
|
+
expect(LiberoSetSubConfigSchema.safeParse({ mode: 'CONDITIONS' }).success).toBe(false);
|
|
46
|
+
expect(LiberoSetSubConfigSchema.safeParse({ mode: 'CONDITIONS', conditions: [] }).success).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
it('rejects an invalid PHASE value', () => {
|
|
49
|
+
const res = LiberoSetSubConfigSchema.safeParse({
|
|
50
|
+
mode: 'CONDITIONS',
|
|
51
|
+
conditions: [{ type: PinchConditionType.PHASE, phase: 'ATTACKING' }]
|
|
52
|
+
});
|
|
53
|
+
expect(res.success).toBe(false);
|
|
54
|
+
});
|
|
24
55
|
});
|
|
25
56
|
describe('LiberoSubConfigSchema', () => {
|
|
26
57
|
it('accepts a flat config with no per-set overrides', () => {
|
|
@@ -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>>;
|