volleyballsimtypes 0.0.482 → 0.0.485
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 +3 -17
- package/dist/cjs/src/data/models/tactics.d.ts +7 -17
- package/dist/cjs/src/data/transformers/match-preset-override.test.js +10 -1
- package/dist/cjs/src/data/transformers/rally-event.d.ts +2 -1
- package/dist/cjs/src/data/transformers/rally-event.js +12 -0
- package/dist/cjs/src/data/transformers/rally.js +2 -0
- package/dist/cjs/src/data/transformers/rally.test.d.ts +1 -0
- package/dist/cjs/src/data/transformers/rally.test.js +62 -0
- package/dist/cjs/src/data/transformers/tactics.js +26 -54
- package/dist/cjs/src/data/transformers/tactics.test.js +16 -11
- package/dist/cjs/src/service/competition/season.d.ts +2 -3
- package/dist/cjs/src/service/competition/season.js +0 -11
- package/dist/cjs/src/service/event/block.d.ts +0 -1
- package/dist/cjs/src/service/event/block.js +0 -6
- package/dist/cjs/src/service/event/free-ball.d.ts +0 -1
- package/dist/cjs/src/service/event/free-ball.js +0 -5
- package/dist/cjs/src/service/event/in-play-event.d.ts +0 -1
- package/dist/cjs/src/service/event/in-play-event.js +0 -8
- package/dist/cjs/src/service/event/libero-replacement.d.ts +0 -1
- package/dist/cjs/src/service/event/libero-replacement.js +0 -7
- package/dist/cjs/src/service/event/rally-event.d.ts +0 -1
- package/dist/cjs/src/service/event/reception.d.ts +0 -1
- package/dist/cjs/src/service/event/reception.js +0 -5
- package/dist/cjs/src/service/event/serve.d.ts +0 -1
- package/dist/cjs/src/service/event/serve.js +0 -5
- package/dist/cjs/src/service/event/set.d.ts +0 -1
- package/dist/cjs/src/service/event/set.js +0 -6
- package/dist/cjs/src/service/event/spike.d.ts +0 -1
- package/dist/cjs/src/service/event/spike.js +0 -5
- package/dist/cjs/src/service/event/substitution.d.ts +0 -1
- package/dist/cjs/src/service/event/substitution.js +0 -7
- package/dist/cjs/src/service/player/improvement.d.ts +0 -1
- package/dist/cjs/src/service/player/improvement.js +0 -9
- package/dist/cjs/src/service/player/improvement.test.js +0 -15
- package/dist/cjs/src/service/team/designated-sub.d.ts +2 -4
- package/dist/cjs/src/service/team/energy-band.d.ts +0 -1
- package/dist/cjs/src/service/team/energy-band.js +1 -2
- package/dist/cjs/src/service/team/formation.d.ts +0 -1
- package/dist/cjs/src/service/team/formation.js +0 -3
- package/dist/cjs/src/service/team/index.d.ts +1 -0
- package/dist/cjs/src/service/team/index.js +1 -0
- package/dist/cjs/src/service/team/libero-sub.d.ts +0 -4
- package/dist/cjs/src/service/team/pinch-condition.d.ts +11 -3
- package/dist/cjs/src/service/team/pinch-condition.js +9 -4
- package/dist/cjs/src/service/team/schemas/designated-sub.z.d.ts +30 -32
- package/dist/cjs/src/service/team/schemas/designated-sub.z.js +27 -23
- package/dist/cjs/src/service/team/schemas/designated-sub.z.test.js +4 -2
- package/dist/cjs/src/service/team/schemas/libero-sub.z.d.ts +15 -34
- package/dist/cjs/src/service/team/schemas/libero-sub.z.js +10 -26
- package/dist/cjs/src/service/team/schemas/libero-sub.z.test.js +74 -35
- package/dist/cjs/src/service/team/schemas/tactics.z.d.ts +28 -36
- package/dist/cjs/src/service/team/schemas/tactics.z.js +4 -3
- package/dist/cjs/src/service/team/schemas/team.z.d.ts +28 -36
- package/dist/cjs/src/service/team/sub-config-convert.d.ts +13 -0
- package/dist/cjs/src/service/team/sub-config-convert.js +91 -0
- package/dist/cjs/src/service/team/sub-config-convert.test.d.ts +1 -0
- package/dist/cjs/src/service/team/sub-config-convert.test.js +84 -0
- package/dist/cjs/src/service/utils/object-utils.d.ts +0 -1
- package/dist/cjs/src/service/utils/object-utils.js +0 -2
- package/dist/esm/src/api/index.d.ts +3 -17
- package/dist/esm/src/data/models/tactics.d.ts +7 -17
- package/dist/esm/src/data/transformers/match-preset-override.test.js +10 -1
- package/dist/esm/src/data/transformers/rally-event.d.ts +2 -1
- package/dist/esm/src/data/transformers/rally-event.js +12 -1
- package/dist/esm/src/data/transformers/rally.js +4 -2
- package/dist/esm/src/data/transformers/rally.test.d.ts +1 -0
- package/dist/esm/src/data/transformers/rally.test.js +60 -0
- package/dist/esm/src/data/transformers/tactics.js +27 -55
- package/dist/esm/src/data/transformers/tactics.test.js +16 -11
- package/dist/esm/src/service/competition/season.d.ts +2 -3
- package/dist/esm/src/service/competition/season.js +0 -11
- package/dist/esm/src/service/event/block.d.ts +0 -1
- package/dist/esm/src/service/event/block.js +0 -6
- package/dist/esm/src/service/event/free-ball.d.ts +0 -1
- package/dist/esm/src/service/event/free-ball.js +0 -5
- package/dist/esm/src/service/event/in-play-event.d.ts +0 -1
- package/dist/esm/src/service/event/in-play-event.js +0 -8
- package/dist/esm/src/service/event/libero-replacement.d.ts +0 -1
- package/dist/esm/src/service/event/libero-replacement.js +0 -7
- package/dist/esm/src/service/event/rally-event.d.ts +0 -1
- package/dist/esm/src/service/event/reception.d.ts +0 -1
- package/dist/esm/src/service/event/reception.js +0 -5
- package/dist/esm/src/service/event/serve.d.ts +0 -1
- package/dist/esm/src/service/event/serve.js +0 -5
- package/dist/esm/src/service/event/set.d.ts +0 -1
- package/dist/esm/src/service/event/set.js +0 -6
- package/dist/esm/src/service/event/spike.d.ts +0 -1
- package/dist/esm/src/service/event/spike.js +0 -5
- package/dist/esm/src/service/event/substitution.d.ts +0 -1
- package/dist/esm/src/service/event/substitution.js +0 -7
- package/dist/esm/src/service/player/improvement.d.ts +0 -1
- package/dist/esm/src/service/player/improvement.js +0 -8
- package/dist/esm/src/service/player/improvement.test.js +1 -16
- package/dist/esm/src/service/team/designated-sub.d.ts +2 -4
- package/dist/esm/src/service/team/energy-band.d.ts +0 -1
- package/dist/esm/src/service/team/energy-band.js +0 -1
- package/dist/esm/src/service/team/formation.d.ts +0 -1
- package/dist/esm/src/service/team/formation.js +0 -3
- package/dist/esm/src/service/team/index.d.ts +1 -0
- package/dist/esm/src/service/team/index.js +1 -0
- package/dist/esm/src/service/team/libero-sub.d.ts +0 -4
- package/dist/esm/src/service/team/pinch-condition.d.ts +11 -3
- package/dist/esm/src/service/team/pinch-condition.js +9 -4
- package/dist/esm/src/service/team/schemas/designated-sub.z.d.ts +30 -32
- package/dist/esm/src/service/team/schemas/designated-sub.z.js +26 -22
- package/dist/esm/src/service/team/schemas/designated-sub.z.test.js +4 -2
- package/dist/esm/src/service/team/schemas/libero-sub.z.d.ts +15 -34
- package/dist/esm/src/service/team/schemas/libero-sub.z.js +9 -25
- package/dist/esm/src/service/team/schemas/libero-sub.z.test.js +75 -36
- package/dist/esm/src/service/team/schemas/tactics.z.d.ts +28 -36
- package/dist/esm/src/service/team/schemas/tactics.z.js +4 -3
- package/dist/esm/src/service/team/schemas/team.z.d.ts +28 -36
- package/dist/esm/src/service/team/sub-config-convert.d.ts +13 -0
- package/dist/esm/src/service/team/sub-config-convert.js +85 -0
- package/dist/esm/src/service/team/sub-config-convert.test.d.ts +1 -0
- package/dist/esm/src/service/team/sub-config-convert.test.js +82 -0
- package/dist/esm/src/service/utils/object-utils.d.ts +0 -1
- package/dist/esm/src/service/utils/object-utils.js +1 -1
- package/package.json +1 -1
|
@@ -37,9 +37,4 @@ export class Spike extends InPlayEvent {
|
|
|
37
37
|
this.type = type;
|
|
38
38
|
this.failure = failure;
|
|
39
39
|
}
|
|
40
|
-
toString() {
|
|
41
|
-
const failure = `"failure":${this.failure}`;
|
|
42
|
-
const type = `"type":${this.type}`;
|
|
43
|
-
return `{${this._toString()},${failure},${type}}`;
|
|
44
|
-
}
|
|
45
40
|
}
|
|
@@ -19,11 +19,4 @@ export class Substitution extends RallyEvent {
|
|
|
19
19
|
this.playerOut = playerOut;
|
|
20
20
|
this.injury = injury;
|
|
21
21
|
}
|
|
22
|
-
toString() {
|
|
23
|
-
const playerId = `"playerId":"${this.playerId}"`;
|
|
24
|
-
const playerOut = `"playerOut":"${this.playerOut}"`;
|
|
25
|
-
const eventType = `"eventType":${this.eventType}`;
|
|
26
|
-
const injury = this.injury === true ? ',"injury":true' : '';
|
|
27
|
-
return `{${playerId},${playerOut},${eventType}${injury}}`;
|
|
28
|
-
}
|
|
29
22
|
}
|
|
@@ -3,7 +3,6 @@ import { Stats } from './stats';
|
|
|
3
3
|
import { DeclineProfile } from './decline';
|
|
4
4
|
export type TrainingFocus = Stats;
|
|
5
5
|
export declare function getStatCap(rarity: Rarity): number;
|
|
6
|
-
export declare function getRarityMultiplier(rarity: Rarity): number;
|
|
7
6
|
export declare function getImprovementFloor(rarity: Rarity): number;
|
|
8
7
|
export declare function getImprovementThreshold(statTotal: number, rarity: Rarity): number;
|
|
9
8
|
export declare function getCoachMultiplier(rarity: Rarity): number;
|
|
@@ -30,14 +30,6 @@ export function getStatCap(rarity) {
|
|
|
30
30
|
throw new Error(`UNKNOWN_RARITY: ${rarity}`);
|
|
31
31
|
return entry.cap;
|
|
32
32
|
}
|
|
33
|
-
// Retained for config/reference. No longer used by the improvement curve -- superseded by IMPROVEMENT_FLOOR,
|
|
34
|
-
// which is the per-rarity adjustment now.
|
|
35
|
-
export function getRarityMultiplier(rarity) {
|
|
36
|
-
const entry = statCaps.find(e => e.rarity === rarity);
|
|
37
|
-
if (entry == null)
|
|
38
|
-
throw new Error(`UNKNOWN_RARITY: ${rarity}`);
|
|
39
|
-
return entry.rarityMultiplier;
|
|
40
|
-
}
|
|
41
33
|
export function getImprovementFloor(rarity) {
|
|
42
34
|
const floor = IMPROVEMENT_FLOOR[rarity];
|
|
43
35
|
if (floor == null)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from '@jest/globals';
|
|
2
2
|
import { RarityEnum } from './rarity';
|
|
3
|
-
import { getStatCap,
|
|
3
|
+
import { getStatCap, getImprovementFloor, getImprovementThreshold, getCoachMultiplier, selectImprovableStat, matchExperience, experienceGained } from './improvement';
|
|
4
4
|
import { StatsEnum } from './stats';
|
|
5
5
|
import { DeclineProfileEnum } from './decline';
|
|
6
6
|
// ─── getStatCap ───────────────────────────────────────────────────────────────
|
|
@@ -18,21 +18,6 @@ describe('getStatCap()', () => {
|
|
|
18
18
|
expect(() => getStatCap('DIVINE')).toThrow('UNKNOWN_RARITY');
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
|
-
// ─── getRarityMultiplier ──────────────────────────────────────────────────────
|
|
22
|
-
describe('getRarityMultiplier()', () => {
|
|
23
|
-
it.each([
|
|
24
|
-
[RarityEnum.COMMON, 1.0],
|
|
25
|
-
[RarityEnum.RARE, 1.15],
|
|
26
|
-
[RarityEnum.LEGENDARY, 1.3],
|
|
27
|
-
[RarityEnum.MYTHIC, 1.5],
|
|
28
|
-
[RarityEnum.SPECIAL, 1.75]
|
|
29
|
-
])('%s → multiplier %f', (rarity, expected) => {
|
|
30
|
-
expect(getRarityMultiplier(rarity)).toBeCloseTo(expected, 5);
|
|
31
|
-
});
|
|
32
|
-
it('throws UNKNOWN_RARITY for an unrecognised rarity string', () => {
|
|
33
|
-
expect(() => getRarityMultiplier('DIVINE')).toThrow('UNKNOWN_RARITY');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
21
|
// ─── getImprovementThreshold ──────────────────────────────────────────────────
|
|
37
22
|
describe('getImprovementThreshold()', () => {
|
|
38
23
|
it('at or below the floor the threshold is CURVE_BASE (180) — the fastest pace', () => {
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { Player } from '../player';
|
|
2
|
-
import { EnergyBand
|
|
2
|
+
import { EnergyBand } from './energy-band';
|
|
3
3
|
import { ConditionLogic, PinchCondition } from './pinch-condition';
|
|
4
4
|
export type SubBackMode = 'FATIGUE' | 'CONDITIONS';
|
|
5
5
|
export interface SetSubConfig {
|
|
6
|
-
readonly mode: SubMode;
|
|
7
6
|
readonly bench?: Player;
|
|
8
|
-
readonly fatigueBand?: EnergyBand;
|
|
9
|
-
readonly benchFatigueBand?: EnergyBand;
|
|
10
7
|
readonly conditions?: PinchCondition[];
|
|
11
8
|
readonly conditionLogic?: ConditionLogic;
|
|
12
9
|
readonly pinchServer?: boolean;
|
|
10
|
+
readonly benchFatigueBand?: EnergyBand;
|
|
13
11
|
readonly subBackMode?: SubBackMode;
|
|
14
12
|
readonly subBackConditions?: PinchCondition[];
|
|
15
13
|
readonly subBackConditionLogic?: ConditionLogic;
|
|
@@ -8,7 +8,6 @@ export var EnergyBand;
|
|
|
8
8
|
EnergyBand["TIRED"] = "TIRED";
|
|
9
9
|
EnergyBand["EXHAUSTED"] = "EXHAUSTED";
|
|
10
10
|
})(EnergyBand || (EnergyBand = {}));
|
|
11
|
-
export const SUB_MODES = ['FATIGUE', 'PINCH', 'NEVER'];
|
|
12
11
|
// Ordered best -> worst. Used to compare "is this player at-or-below the configured sub band".
|
|
13
12
|
export const ENERGY_BAND_ORDER = [
|
|
14
13
|
EnergyBand.ENERGETIC,
|
|
@@ -7,6 +7,7 @@ export * from './energy-band';
|
|
|
7
7
|
export * from './pinch-condition';
|
|
8
8
|
export * from './designated-sub';
|
|
9
9
|
export * from './libero-sub';
|
|
10
|
+
export * from './sub-config-convert';
|
|
10
11
|
export * from './rotation-system';
|
|
11
12
|
export * from './lineup-function';
|
|
12
13
|
export * from './base-position';
|
|
@@ -7,6 +7,7 @@ export * from './energy-band';
|
|
|
7
7
|
export * from './pinch-condition';
|
|
8
8
|
export * from './designated-sub';
|
|
9
9
|
export * from './libero-sub';
|
|
10
|
+
export * from './sub-config-convert';
|
|
10
11
|
export * from './rotation-system';
|
|
11
12
|
export * from './lineup-function';
|
|
12
13
|
export * from './base-position';
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { EnergyBand } from './energy-band';
|
|
2
1
|
import { ConditionLogic, PinchCondition } from './pinch-condition';
|
|
3
|
-
export type LiberoSubMode = 'NEVER' | 'FATIGUE' | 'ALWAYS' | 'CONDITIONS';
|
|
4
2
|
export interface LiberoSetSubConfig {
|
|
5
|
-
readonly mode: LiberoSubMode;
|
|
6
|
-
readonly fatigueBand?: EnergyBand;
|
|
7
3
|
readonly conditions?: PinchCondition[];
|
|
8
4
|
readonly conditionLogic?: ConditionLogic;
|
|
9
5
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { EnergyBand, SubBand } from './energy-band';
|
|
1
2
|
export declare enum PinchConditionType {
|
|
2
|
-
ASAP = "ASAP",//
|
|
3
|
+
ASAP = "ASAP",// unconditionally true (pinch server: every serve gain; libero rule: "Always")
|
|
3
4
|
TEAM_SET_POINT = "TEAM_SET_POINT",// team within `margin` of winning the set
|
|
4
5
|
OPPONENT_SET_POINT = "OPPONENT_SET_POINT",// opponent within `margin` of winning the set
|
|
5
6
|
SCORE_DIFF = "SCORE_DIFF",// team trailing/leading by at least `points`
|
|
@@ -7,7 +8,8 @@ export declare enum PinchConditionType {
|
|
|
7
8
|
FROM_SET = "FROM_SET",// only set N or later
|
|
8
9
|
MIN_OWN_SCORE = "MIN_OWN_SCORE",// only once own score >= N
|
|
9
10
|
MIN_OPPONENT_SCORE = "MIN_OPPONENT_SCORE",// only once opponent score >= N
|
|
10
|
-
PHASE = "PHASE"
|
|
11
|
+
PHASE = "PHASE",// the team is serving or receiving this rally (used by the libero deployment rule)
|
|
12
|
+
FATIGUE = "FATIGUE"
|
|
11
13
|
}
|
|
12
14
|
export declare enum MatchPhase {
|
|
13
15
|
SERVING = "SERVING",
|
|
@@ -66,7 +68,11 @@ export interface PhaseCondition {
|
|
|
66
68
|
readonly type: PinchConditionType.PHASE;
|
|
67
69
|
readonly phase: MatchPhase;
|
|
68
70
|
}
|
|
69
|
-
export
|
|
71
|
+
export interface FatigueCondition {
|
|
72
|
+
readonly type: PinchConditionType.FATIGUE;
|
|
73
|
+
readonly band?: EnergyBand;
|
|
74
|
+
}
|
|
75
|
+
export type PinchCondition = AsapCondition | TeamSetPointCondition | OpponentSetPointCondition | ScoreDiffCondition | AfterRotationsCondition | FromSetCondition | MinOwnScoreCondition | MinOpponentScoreCondition | PhaseCondition | FatigueCondition;
|
|
70
76
|
export type ConditionLogic = 'ALL' | 'ANY';
|
|
71
77
|
export interface PinchSetState {
|
|
72
78
|
readonly ownScore: number;
|
|
@@ -75,4 +81,6 @@ export interface PinchSetState {
|
|
|
75
81
|
readonly setNumber: number;
|
|
76
82
|
readonly ownServeTurns: number;
|
|
77
83
|
readonly phase: MatchPhase;
|
|
84
|
+
readonly subjectBand?: EnergyBand;
|
|
85
|
+
readonly defaultBand?: SubBand;
|
|
78
86
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// state
|
|
1
|
+
// The ONE condition vocabulary of the substitution engine (owner 2026-07-11): designated substitutions,
|
|
2
|
+
// pinch servers, sub-backs, and the libero deployment rule all evaluate the same catalog against the live
|
|
3
|
+
// set state, combined with ALL (every condition must hold) or ANY (one is enough). A config with NO
|
|
4
|
+
// conditions never fires.
|
|
4
5
|
export var PinchConditionType;
|
|
5
6
|
(function (PinchConditionType) {
|
|
6
7
|
PinchConditionType["ASAP"] = "ASAP";
|
|
@@ -11,7 +12,11 @@ export var PinchConditionType;
|
|
|
11
12
|
PinchConditionType["FROM_SET"] = "FROM_SET";
|
|
12
13
|
PinchConditionType["MIN_OWN_SCORE"] = "MIN_OWN_SCORE";
|
|
13
14
|
PinchConditionType["MIN_OPPONENT_SCORE"] = "MIN_OPPONENT_SCORE";
|
|
14
|
-
PinchConditionType["PHASE"] = "PHASE";
|
|
15
|
+
PinchConditionType["PHASE"] = "PHASE";
|
|
16
|
+
// The SUBJECT player's energy is at-or-worse than `band` (absent band = the team `substitutionBand`). The
|
|
17
|
+
// subject comes from the evaluation context, never from the condition: sub-in conditions judge the STARTER
|
|
18
|
+
// on court, sub-back conditions judge the SUBSTITUTE on court, the libero rule judges the STARTING libero.
|
|
19
|
+
PinchConditionType["FATIGUE"] = "FATIGUE";
|
|
15
20
|
})(PinchConditionType || (PinchConditionType = {}));
|
|
16
21
|
// Which side of the rally the team is on. Known at each dead ball: the serving team is SERVING, the other
|
|
17
22
|
// RECEIVING. Consumed by the PHASE condition (libero deployment); pinch servers always evaluate while SERVING.
|
|
@@ -34,26 +34,17 @@ export declare const PinchConditionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
34
34
|
}, z.core.$strip>, z.ZodObject<{
|
|
35
35
|
type: z.ZodLiteral<PinchConditionType.PHASE>;
|
|
36
36
|
phase: z.ZodEnum<typeof MatchPhase>;
|
|
37
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
38
|
+
type: z.ZodLiteral<PinchConditionType.FATIGUE>;
|
|
39
|
+
band: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
37
40
|
}, z.core.$strip>], "type">;
|
|
38
41
|
export declare const ConditionLogicSchema: z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>;
|
|
39
|
-
export declare const SubModeSchema: z.ZodEnum<{
|
|
40
|
-
NEVER: "NEVER";
|
|
41
|
-
FATIGUE: "FATIGUE";
|
|
42
|
-
PINCH: "PINCH";
|
|
43
|
-
}>;
|
|
44
42
|
export declare const SubBackModeSchema: z.ZodEnum<{
|
|
45
43
|
FATIGUE: "FATIGUE";
|
|
46
44
|
CONDITIONS: "CONDITIONS";
|
|
47
45
|
}>;
|
|
48
|
-
export declare const SetSubConfigSchema: z.ZodObject<{
|
|
49
|
-
mode: z.ZodEnum<{
|
|
50
|
-
NEVER: "NEVER";
|
|
51
|
-
FATIGUE: "FATIGUE";
|
|
52
|
-
PINCH: "PINCH";
|
|
53
|
-
}>;
|
|
46
|
+
export declare const SetSubConfigSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
54
47
|
bench: z.ZodOptional<z.ZodCustom<Player, Player>>;
|
|
55
|
-
fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
56
|
-
benchFatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
57
48
|
conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
58
49
|
type: z.ZodLiteral<PinchConditionType.ASAP>;
|
|
59
50
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -85,9 +76,13 @@ export declare const SetSubConfigSchema: z.ZodObject<{
|
|
|
85
76
|
}, z.core.$strip>, z.ZodObject<{
|
|
86
77
|
type: z.ZodLiteral<PinchConditionType.PHASE>;
|
|
87
78
|
phase: z.ZodEnum<typeof MatchPhase>;
|
|
79
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
80
|
+
type: z.ZodLiteral<PinchConditionType.FATIGUE>;
|
|
81
|
+
band: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
88
82
|
}, z.core.$strip>], "type">>>;
|
|
89
83
|
conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
90
84
|
pinchServer: z.ZodOptional<z.ZodBoolean>;
|
|
85
|
+
benchFatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
91
86
|
subBackMode: z.ZodOptional<z.ZodEnum<{
|
|
92
87
|
FATIGUE: "FATIGUE";
|
|
93
88
|
CONDITIONS: "CONDITIONS";
|
|
@@ -123,19 +118,15 @@ export declare const SetSubConfigSchema: z.ZodObject<{
|
|
|
123
118
|
}, z.core.$strip>, z.ZodObject<{
|
|
124
119
|
type: z.ZodLiteral<PinchConditionType.PHASE>;
|
|
125
120
|
phase: z.ZodEnum<typeof MatchPhase>;
|
|
121
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
122
|
+
type: z.ZodLiteral<PinchConditionType.FATIGUE>;
|
|
123
|
+
band: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
126
124
|
}, z.core.$strip>], "type">>>;
|
|
127
125
|
subBackConditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
128
|
-
}, z.core.$strip
|
|
129
|
-
export declare const DesignatedSubSchema: z.ZodObject<{
|
|
130
|
-
sets: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
131
|
-
mode: z.ZodEnum<{
|
|
132
|
-
NEVER: "NEVER";
|
|
133
|
-
FATIGUE: "FATIGUE";
|
|
134
|
-
PINCH: "PINCH";
|
|
135
|
-
}>;
|
|
126
|
+
}, z.core.$strip>>;
|
|
127
|
+
export declare const DesignatedSubSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
128
|
+
sets: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
136
129
|
bench: z.ZodOptional<z.ZodCustom<Player, Player>>;
|
|
137
|
-
fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
138
|
-
benchFatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
139
130
|
conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
140
131
|
type: z.ZodLiteral<PinchConditionType.ASAP>;
|
|
141
132
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -167,9 +158,13 @@ export declare const DesignatedSubSchema: z.ZodObject<{
|
|
|
167
158
|
}, z.core.$strip>, z.ZodObject<{
|
|
168
159
|
type: z.ZodLiteral<PinchConditionType.PHASE>;
|
|
169
160
|
phase: z.ZodEnum<typeof MatchPhase>;
|
|
161
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
162
|
+
type: z.ZodLiteral<PinchConditionType.FATIGUE>;
|
|
163
|
+
band: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
170
164
|
}, z.core.$strip>], "type">>>;
|
|
171
165
|
conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
172
166
|
pinchServer: z.ZodOptional<z.ZodBoolean>;
|
|
167
|
+
benchFatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
173
168
|
subBackMode: z.ZodOptional<z.ZodEnum<{
|
|
174
169
|
FATIGUE: "FATIGUE";
|
|
175
170
|
CONDITIONS: "CONDITIONS";
|
|
@@ -205,17 +200,13 @@ export declare const DesignatedSubSchema: z.ZodObject<{
|
|
|
205
200
|
}, z.core.$strip>, z.ZodObject<{
|
|
206
201
|
type: z.ZodLiteral<PinchConditionType.PHASE>;
|
|
207
202
|
phase: z.ZodEnum<typeof MatchPhase>;
|
|
203
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
204
|
+
type: z.ZodLiteral<PinchConditionType.FATIGUE>;
|
|
205
|
+
band: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
208
206
|
}, z.core.$strip>], "type">>>;
|
|
209
207
|
subBackConditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
210
|
-
}, z.core.$strip
|
|
211
|
-
mode: z.ZodEnum<{
|
|
212
|
-
NEVER: "NEVER";
|
|
213
|
-
FATIGUE: "FATIGUE";
|
|
214
|
-
PINCH: "PINCH";
|
|
215
|
-
}>;
|
|
208
|
+
}, z.core.$strip>>>>;
|
|
216
209
|
bench: z.ZodOptional<z.ZodCustom<Player, Player>>;
|
|
217
|
-
fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
218
|
-
benchFatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
219
210
|
conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
220
211
|
type: z.ZodLiteral<PinchConditionType.ASAP>;
|
|
221
212
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -247,9 +238,13 @@ export declare const DesignatedSubSchema: z.ZodObject<{
|
|
|
247
238
|
}, z.core.$strip>, z.ZodObject<{
|
|
248
239
|
type: z.ZodLiteral<PinchConditionType.PHASE>;
|
|
249
240
|
phase: z.ZodEnum<typeof MatchPhase>;
|
|
241
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
242
|
+
type: z.ZodLiteral<PinchConditionType.FATIGUE>;
|
|
243
|
+
band: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
250
244
|
}, z.core.$strip>], "type">>>;
|
|
251
245
|
conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
252
246
|
pinchServer: z.ZodOptional<z.ZodBoolean>;
|
|
247
|
+
benchFatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
253
248
|
subBackMode: z.ZodOptional<z.ZodEnum<{
|
|
254
249
|
FATIGUE: "FATIGUE";
|
|
255
250
|
CONDITIONS: "CONDITIONS";
|
|
@@ -285,7 +280,10 @@ export declare const DesignatedSubSchema: z.ZodObject<{
|
|
|
285
280
|
}, z.core.$strip>, z.ZodObject<{
|
|
286
281
|
type: z.ZodLiteral<PinchConditionType.PHASE>;
|
|
287
282
|
phase: z.ZodEnum<typeof MatchPhase>;
|
|
283
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
284
|
+
type: z.ZodLiteral<PinchConditionType.FATIGUE>;
|
|
285
|
+
band: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
288
286
|
}, z.core.$strip>], "type">>>;
|
|
289
287
|
subBackConditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
290
288
|
starter: z.ZodCustom<Player, Player>;
|
|
291
|
-
}, z.core.$strip
|
|
289
|
+
}, z.core.$strip>>;
|
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { Player } from '../../player';
|
|
3
3
|
import { EnergyBand } from '../energy-band';
|
|
4
4
|
import { Comparison, MatchPhase, OpponentRelation, PinchConditionType, ScoreDirection } from '../pinch-condition';
|
|
5
|
+
import { convertLegacyDesignatedSub, convertLegacySetSubConfig } from '../sub-config-convert';
|
|
5
6
|
const playerInstanceSchema = z.custom((v) => v instanceof Player, {
|
|
6
7
|
message: 'INVALID_PLAYER_INSTANCE'
|
|
7
8
|
});
|
|
@@ -18,44 +19,47 @@ export const PinchConditionSchema = z.discriminatedUnion('type', [
|
|
|
18
19
|
z.object({ type: z.literal(PinchConditionType.MIN_OWN_SCORE), score: z.number().int().min(0).max(40), comparison: z.nativeEnum(Comparison).optional() }),
|
|
19
20
|
z.object({ type: z.literal(PinchConditionType.MIN_OPPONENT_SCORE), score: z.number().int().min(0).max(40), comparison: z.nativeEnum(Comparison).optional() }),
|
|
20
21
|
// PHASE is used by the libero deployment rule (which reuses this schema); pinch servers never offer it.
|
|
21
|
-
z.object({ type: z.literal(PinchConditionType.PHASE), phase: z.nativeEnum(MatchPhase) })
|
|
22
|
+
z.object({ type: z.literal(PinchConditionType.PHASE), phase: z.nativeEnum(MatchPhase) }),
|
|
23
|
+
// The subject player's energy is at-or-worse than `band` (absent = the team `substitutionBand`); the
|
|
24
|
+
// subject comes from the evaluation context (starter / substitute / starting libero).
|
|
25
|
+
z.object({ type: z.literal(PinchConditionType.FATIGUE), band: z.nativeEnum(EnergyBand).optional() })
|
|
22
26
|
]);
|
|
23
27
|
export const ConditionLogicSchema = z.union([z.literal('ALL'), z.literal('ANY')]);
|
|
24
|
-
export const SubModeSchema = z.enum(['FATIGUE', 'PINCH', 'NEVER']);
|
|
25
28
|
export const SubBackModeSchema = z.enum(['FATIGUE', 'CONDITIONS']);
|
|
26
|
-
// Fields shared by the all-sets config and each per-set config.
|
|
29
|
+
// Fields shared by the all-sets config and each per-set config. Pure condition engine (owner 2026-07-11):
|
|
30
|
+
// no mode; `conditions` is the sub-in trigger and an EMPTY/absent list means the starter is never substituted
|
|
31
|
+
// by this rule. Legacy mode-shaped inputs are auto-converted by the preprocess below.
|
|
27
32
|
const setSubConfigShape = {
|
|
28
|
-
mode: SubModeSchema,
|
|
29
33
|
bench: playerInstanceSchema.optional(),
|
|
30
|
-
fatigueBand: z.nativeEnum(EnergyBand).optional(),
|
|
31
|
-
benchFatigueBand: z.nativeEnum(EnergyBand).optional(),
|
|
32
34
|
conditions: z.array(PinchConditionSchema).optional(),
|
|
33
35
|
conditionLogic: ConditionLogicSchema.optional(),
|
|
34
|
-
//
|
|
36
|
+
// true = serve-and-return pinch server; false/absent = regular conditional sub (stays until sub-back).
|
|
35
37
|
pinchServer: z.boolean().optional(),
|
|
36
|
-
//
|
|
38
|
+
// The substitute's own pull band for FATIGUE sub-backs (absent = the team `substitutionBand`).
|
|
39
|
+
benchFatigueBand: z.nativeEnum(EnergyBand).optional(),
|
|
37
40
|
subBackMode: SubBackModeSchema.optional(),
|
|
38
41
|
subBackConditions: z.array(PinchConditionSchema).optional(),
|
|
39
42
|
subBackConditionLogic: ConditionLogicSchema.optional()
|
|
40
43
|
};
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
// A pinch server needs a designated bench player and at least one sub-in condition. A regular conditional sub
|
|
45
|
+
// with a CONDITIONS sub-back needs at least one sub-back condition. Empty sub-in conditions are otherwise
|
|
46
|
+
// VALID (= never fires).
|
|
47
|
+
function refineSubConfig(data, ctx) {
|
|
48
|
+
if (data.pinchServer === true) {
|
|
49
|
+
if (data.bench == null) {
|
|
50
|
+
ctx.addIssue({ code: 'custom', message: 'PINCH_SERVER_REQUIRES_BENCH', path: ['bench'] });
|
|
51
|
+
}
|
|
52
|
+
if (data.conditions == null || data.conditions.length === 0) {
|
|
53
|
+
ctx.addIssue({ code: 'custom', message: 'PINCH_SERVER_REQUIRES_CONDITIONS', path: ['conditions'] });
|
|
54
|
+
}
|
|
51
55
|
}
|
|
52
56
|
if (data.pinchServer !== true && data.subBackMode === 'CONDITIONS' &&
|
|
53
57
|
(data.subBackConditions == null || data.subBackConditions.length === 0)) {
|
|
54
58
|
ctx.addIssue({ code: 'custom', message: 'CONDITIONAL_SUB_BACK_REQUIRES_CONDITIONS', path: ['subBackConditions'] });
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
|
-
export const SetSubConfigSchema = z.object(setSubConfigShape).superRefine(
|
|
58
|
-
export const DesignatedSubSchema = z.object({
|
|
61
|
+
export const SetSubConfigSchema = z.preprocess(convertLegacySetSubConfig, z.object(setSubConfigShape).superRefine(refineSubConfig));
|
|
62
|
+
export const DesignatedSubSchema = z.preprocess(convertLegacyDesignatedSub, z.object({
|
|
59
63
|
starter: playerInstanceSchema,
|
|
60
64
|
...setSubConfigShape,
|
|
61
65
|
// Optional per-set overrides (index 0 = set 1 ... index 4 = set 5); absent => the flat config for all sets.
|
|
@@ -64,5 +68,5 @@ export const DesignatedSubSchema = z.object({
|
|
|
64
68
|
// The flat config is the fallback for any set a partial `sets` array doesn't cover, so validate it whenever
|
|
65
69
|
// `sets` is absent or covers fewer than 5 sets (each present per-set config is validated by SetSubConfigSchema).
|
|
66
70
|
if (data.sets == null || data.sets.length < 5)
|
|
67
|
-
|
|
68
|
-
});
|
|
71
|
+
refineSubConfig(data, ctx);
|
|
72
|
+
}));
|
|
@@ -114,12 +114,14 @@ describe('DesignatedSubSchema', () => {
|
|
|
114
114
|
});
|
|
115
115
|
expect(res.success).toBe(true);
|
|
116
116
|
});
|
|
117
|
-
it('
|
|
117
|
+
it('heals an unknown legacy mode by stripping it (lenient conversion, config stays valid)', () => {
|
|
118
118
|
const res = DesignatedSubSchema.safeParse({
|
|
119
119
|
starter,
|
|
120
120
|
mode: 'SOMETIMES'
|
|
121
121
|
});
|
|
122
|
-
expect(res.success).toBe(
|
|
122
|
+
expect(res.success).toBe(true);
|
|
123
|
+
if (res.success)
|
|
124
|
+
expect(res.data.mode).toBeUndefined();
|
|
123
125
|
});
|
|
124
126
|
it('accepts a pinch-mode entry with a bench server and conditions', () => {
|
|
125
127
|
const res = DesignatedSubSchema.safeParse({
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
export declare const LiberoSubModeSchema: z.ZodEnum<{
|
|
4
|
-
NEVER: "NEVER";
|
|
5
|
-
FATIGUE: "FATIGUE";
|
|
6
|
-
CONDITIONS: "CONDITIONS";
|
|
7
|
-
ALWAYS: "ALWAYS";
|
|
8
|
-
}>;
|
|
9
|
-
export declare const LiberoSetSubConfigSchema: z.ZodObject<{
|
|
10
|
-
mode: z.ZodEnum<{
|
|
11
|
-
NEVER: "NEVER";
|
|
12
|
-
FATIGUE: "FATIGUE";
|
|
13
|
-
CONDITIONS: "CONDITIONS";
|
|
14
|
-
ALWAYS: "ALWAYS";
|
|
15
|
-
}>;
|
|
16
|
-
fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
2
|
+
export declare const LiberoSetSubConfigSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
17
3
|
conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
18
4
|
type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
|
|
19
5
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -45,18 +31,14 @@ export declare const LiberoSetSubConfigSchema: z.ZodObject<{
|
|
|
45
31
|
}, z.core.$strip>, z.ZodObject<{
|
|
46
32
|
type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
|
|
47
33
|
phase: z.ZodEnum<typeof import("..").MatchPhase>;
|
|
34
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
35
|
+
type: z.ZodLiteral<import("..").PinchConditionType.FATIGUE>;
|
|
36
|
+
band: z.ZodOptional<z.ZodEnum<typeof import("..").EnergyBand>>;
|
|
48
37
|
}, z.core.$strip>], "type">>>;
|
|
49
38
|
conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
50
|
-
}, z.core.$strip
|
|
51
|
-
export declare const LiberoSubConfigSchema: z.ZodObject<{
|
|
52
|
-
sets: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
53
|
-
mode: z.ZodEnum<{
|
|
54
|
-
NEVER: "NEVER";
|
|
55
|
-
FATIGUE: "FATIGUE";
|
|
56
|
-
CONDITIONS: "CONDITIONS";
|
|
57
|
-
ALWAYS: "ALWAYS";
|
|
58
|
-
}>;
|
|
59
|
-
fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
export declare const LiberoSubConfigSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
41
|
+
sets: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
60
42
|
conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
61
43
|
type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
|
|
62
44
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -88,16 +70,12 @@ export declare const LiberoSubConfigSchema: z.ZodObject<{
|
|
|
88
70
|
}, z.core.$strip>, z.ZodObject<{
|
|
89
71
|
type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
|
|
90
72
|
phase: z.ZodEnum<typeof import("..").MatchPhase>;
|
|
73
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
74
|
+
type: z.ZodLiteral<import("..").PinchConditionType.FATIGUE>;
|
|
75
|
+
band: z.ZodOptional<z.ZodEnum<typeof import("..").EnergyBand>>;
|
|
91
76
|
}, z.core.$strip>], "type">>>;
|
|
92
77
|
conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
93
|
-
}, z.core.$strip
|
|
94
|
-
mode: z.ZodEnum<{
|
|
95
|
-
NEVER: "NEVER";
|
|
96
|
-
FATIGUE: "FATIGUE";
|
|
97
|
-
CONDITIONS: "CONDITIONS";
|
|
98
|
-
ALWAYS: "ALWAYS";
|
|
99
|
-
}>;
|
|
100
|
-
fatigueBand: z.ZodOptional<z.ZodEnum<typeof EnergyBand>>;
|
|
78
|
+
}, z.core.$strip>>>>;
|
|
101
79
|
conditions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
102
80
|
type: z.ZodLiteral<import("..").PinchConditionType.ASAP>;
|
|
103
81
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -129,6 +107,9 @@ export declare const LiberoSubConfigSchema: z.ZodObject<{
|
|
|
129
107
|
}, z.core.$strip>, z.ZodObject<{
|
|
130
108
|
type: z.ZodLiteral<import("..").PinchConditionType.PHASE>;
|
|
131
109
|
phase: z.ZodEnum<typeof import("..").MatchPhase>;
|
|
110
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
111
|
+
type: z.ZodLiteral<import("..").PinchConditionType.FATIGUE>;
|
|
112
|
+
band: z.ZodOptional<z.ZodEnum<typeof import("..").EnergyBand>>;
|
|
132
113
|
}, z.core.$strip>], "type">>>;
|
|
133
114
|
conditionLogic: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ALL">, z.ZodLiteral<"ANY">]>>;
|
|
134
|
-
}, z.core.$strip
|
|
115
|
+
}, z.core.$strip>>;
|
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { convertLegacyLiberoSetSubConfig, convertLegacyLiberoSubConfig } from '../sub-config-convert';
|
|
3
3
|
import { ConditionLogicSchema, PinchConditionSchema } from './designated-sub.z';
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
4
|
+
// Pure condition engine (owner 2026-07-11): the second libero is active while `conditions` hold (combined
|
|
5
|
+
// per `conditionLogic`, default ALL; the STARTING libero is the FATIGUE-condition subject). No conditions =
|
|
6
|
+
// the starting libero always plays; [{ASAP}] = always the second libero (the old ALWAYS). The swapped-in
|
|
7
|
+
// player is always the dedicated `secondLibero`, so there is no bench to validate. Legacy mode-shaped
|
|
8
|
+
// configs (NEVER/FATIGUE/ALWAYS/CONDITIONS) are auto-converted by the preprocess.
|
|
8
9
|
const liberoSetSubConfigShape = {
|
|
9
|
-
mode: LiberoSubModeSchema,
|
|
10
|
-
// fatigue mode only (absent => the team default `substitutionBand`):
|
|
11
|
-
fatigueBand: z.nativeEnum(EnergyBand).optional(),
|
|
12
|
-
// conditions mode only:
|
|
13
10
|
conditions: z.array(PinchConditionSchema).optional(),
|
|
14
11
|
conditionLogic: ConditionLogicSchema.optional()
|
|
15
12
|
};
|
|
16
|
-
|
|
17
|
-
|
|
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);
|
|
25
|
-
export const LiberoSubConfigSchema = z.object({
|
|
13
|
+
export const LiberoSetSubConfigSchema = z.preprocess(convertLegacyLiberoSetSubConfig, z.object(liberoSetSubConfigShape));
|
|
14
|
+
export const LiberoSubConfigSchema = z.preprocess(convertLegacyLiberoSubConfig, z.object({
|
|
26
15
|
...liberoSetSubConfigShape,
|
|
27
16
|
// Optional per-set overrides (index 0 = set 1 ... index 4 = set 5); absent => the flat config for all sets.
|
|
28
17
|
sets: z.array(LiberoSetSubConfigSchema).max(5).optional()
|
|
29
|
-
})
|
|
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);
|
|
34
|
-
});
|
|
18
|
+
}));
|