volleyballsimtypes 0.0.421 → 0.0.423

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.
@@ -1,4 +1,4 @@
1
- import { BoxScore, DataProps, DeclineStatus, Division as _Division, League as _League, Match as _Match, MatchSet as _MatchSet, Player as _Player, PlayerPosition, Qualifier as _Qualifier, QualifierMatch as _QualifierMatch, Rally as _Rally, RallyEvent as _RallyEvent, Season as _Season, Standing as _Standing, Team as _Team, Tournament as _Tournament, TournamentMatch as _TournamentMatch, National as _National, NationalMatch as _NationalMatch, Country as _Country, CourtPosition, ConditionLogic, EnergyBand, LiberoSubMode, PerformanceStats, PinchCondition, RotationSystemEnum, SubBand, SubMode } from '../service';
1
+ import { BoxScore, DataProps, DeclineStatus, Division as _Division, League as _League, Match as _Match, MatchSet as _MatchSet, Player as _Player, PlayerPosition, Qualifier as _Qualifier, QualifierMatch as _QualifierMatch, Rally as _Rally, RallyEvent as _RallyEvent, RallyMetrics, Season as _Season, Standing as _Standing, Team as _Team, Tournament as _Tournament, TournamentMatch as _TournamentMatch, National as _National, NationalMatch as _NationalMatch, Country as _Country, CourtPosition, ConditionLogic, EnergyBand, LiberoSubMode, PerformanceStats, PinchCondition, RotationSystemEnum, SubBand, SubMode } from '../service';
2
2
  export type Rally = DataProps<_Rally> & {
3
3
  homePlayerPosition: PlayerPosition[];
4
4
  awayPlayerPosition: PlayerPosition[];
@@ -36,6 +36,7 @@ export type Match = Omit<DataProps<_Match>, 'sets' | 'homeTeam' | 'awayTeam' | '
36
36
  national?: National;
37
37
  results?: Results;
38
38
  competition?: MatchCompetition;
39
+ rallyMetrics?: RallyMetrics;
39
40
  };
40
41
  export type RallyEvent = DataProps<_RallyEvent> & {
41
42
  team?: Team;
@@ -5,6 +5,7 @@ export * from './match-rating';
5
5
  export * from './match-set';
6
6
  export * from './rally';
7
7
  export * from './point-breakdown';
8
+ export * from './rally-metrics';
8
9
  export * from './court-position';
9
10
  export * from './match-team';
10
11
  export * from './vper';
@@ -21,6 +21,7 @@ __exportStar(require("./match-rating"), exports);
21
21
  __exportStar(require("./match-set"), exports);
22
22
  __exportStar(require("./rally"), exports);
23
23
  __exportStar(require("./point-breakdown"), exports);
24
+ __exportStar(require("./rally-metrics"), exports);
24
25
  __exportStar(require("./court-position"), exports);
25
26
  __exportStar(require("./match-team"), exports);
26
27
  __exportStar(require("./vper"), exports);
@@ -0,0 +1,44 @@
1
+ export interface RallyMetricsEvent {
2
+ readonly eventType: number;
3
+ readonly failure?: number;
4
+ }
5
+ export interface RallyMetricsRally {
6
+ readonly servingTeamId: string;
7
+ readonly events: readonly RallyMetricsEvent[];
8
+ }
9
+ export interface RallyMetricsSet {
10
+ readonly rallies: readonly RallyMetricsRally[];
11
+ readonly homePoints: number;
12
+ readonly awayPoints: number;
13
+ readonly homeSetterStartZone: number | null;
14
+ readonly awaySetterStartZone: number | null;
15
+ }
16
+ export interface RotationMetrics {
17
+ setterZone: number | null;
18
+ rotation: number;
19
+ servePoints: number;
20
+ sideoutPoints: number;
21
+ points: number;
22
+ }
23
+ export interface TeamRallyMetrics {
24
+ serves: number;
25
+ breakpointWins: number;
26
+ breakpointPct: number;
27
+ receptions: number;
28
+ sideoutWins: number;
29
+ sideoutPct: number;
30
+ serviceErrorsReceived: number;
31
+ modReceptions: number;
32
+ modSideoutWins: number;
33
+ modSideoutPct: number;
34
+ rotations: RotationMetrics[];
35
+ }
36
+ export interface SetRallyMetrics {
37
+ home: TeamRallyMetrics;
38
+ away: TeamRallyMetrics;
39
+ }
40
+ export interface RallyMetrics {
41
+ total: SetRallyMetrics;
42
+ sets: SetRallyMetrics[];
43
+ }
44
+ export declare function computeRallyMetrics(sets: readonly RallyMetricsSet[], homeTeamId: string, awayTeamId: string): RallyMetrics;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeRallyMetrics = computeRallyMetrics;
4
+ const event_1 = require("../event");
5
+ const court_position_1 = require("./court-position");
6
+ function newAcc() {
7
+ return { serves: 0, breakpointWins: 0, receptions: 0, sideoutWins: 0, serviceErrorsReceived: 0, rotations: new Map() };
8
+ }
9
+ function isServiceError(rally) {
10
+ const serve = rally.events.find(e => e.eventType === event_1.EventTypeEnum.SERVE);
11
+ return serve != null && (serve.failure ?? 0) > 0;
12
+ }
13
+ // The setter's zone after (rotationIndex - 1) rotations from their start zone, using the engine's own
14
+ // rotatePosition (each rotation moves a player one zone: 2->1, 1->6, ...). null when no setter.
15
+ function setterZoneAt(startZone, rotationIndex) {
16
+ if (startZone == null)
17
+ return null;
18
+ let zone = startZone;
19
+ for (let r = 1; r < rotationIndex; r++)
20
+ zone = (0, court_position_1.rotatePosition)(zone);
21
+ return zone;
22
+ }
23
+ function addRotationPoint(acc, setterZone, rotation, kind) {
24
+ const key = setterZone != null ? `z${setterZone}` : `r${rotation}`;
25
+ let entry = acc.rotations.get(key);
26
+ if (entry == null) {
27
+ entry = { setterZone, rotation, servePoints: 0, sideoutPoints: 0 };
28
+ acc.rotations.set(key, entry);
29
+ }
30
+ if (kind === 'serve')
31
+ entry.servePoints++;
32
+ else
33
+ entry.sideoutPoints++;
34
+ }
35
+ // Walk one set, folding its rallies into the home/away accumulators (used for both per-set and total).
36
+ function accumulateSet(set, homeId, awayId, homeAcc, awayAcc) {
37
+ const { rallies } = set;
38
+ if (rallies.length === 0)
39
+ return;
40
+ const setWinnerId = set.homePoints > set.awayPoints ? homeId : awayId;
41
+ const rotation = { [homeId]: 1, [awayId]: 1 };
42
+ const startZone = { [homeId]: set.homeSetterStartZone, [awayId]: set.awaySetterStartZone };
43
+ const accOf = (id) => id === homeId ? homeAcc : id === awayId ? awayAcc : null;
44
+ for (let i = 0; i < rallies.length; i++) {
45
+ const servingId = rallies[i].servingTeamId;
46
+ const receivingId = servingId === homeId ? awayId : homeId;
47
+ const winnerId = i < rallies.length - 1 ? rallies[i + 1].servingTeamId : setWinnerId;
48
+ const serving = accOf(servingId);
49
+ const receiving = accOf(receivingId);
50
+ const winner = accOf(winnerId);
51
+ if (serving == null || receiving == null || winner == null)
52
+ continue;
53
+ serving.serves++;
54
+ receiving.receptions++;
55
+ if (isServiceError(rallies[i]))
56
+ receiving.serviceErrorsReceived++;
57
+ const rotIdx = rotation[winnerId];
58
+ const zone = setterZoneAt(startZone[winnerId], rotIdx);
59
+ if (winnerId === servingId) {
60
+ serving.breakpointWins++;
61
+ addRotationPoint(winner, zone, rotIdx, 'serve');
62
+ }
63
+ else {
64
+ receiving.sideoutWins++;
65
+ addRotationPoint(winner, zone, rotIdx, 'sideout');
66
+ }
67
+ // The sideout winner gains serve, so they rotate (after the point is attributed to their old rotation).
68
+ if (winnerId === receivingId)
69
+ rotation[winnerId] = (rotation[winnerId] % 6) + 1;
70
+ }
71
+ }
72
+ function finalizeTeam(acc) {
73
+ const modReceptions = acc.receptions - acc.serviceErrorsReceived;
74
+ const modSideoutWins = acc.sideoutWins - acc.serviceErrorsReceived;
75
+ const rotations = [...acc.rotations.values()]
76
+ .map(e => ({ ...e, points: e.servePoints + e.sideoutPoints }))
77
+ .sort((a, b) => (a.setterZone ?? a.rotation) - (b.setterZone ?? b.rotation));
78
+ return {
79
+ serves: acc.serves,
80
+ breakpointWins: acc.breakpointWins,
81
+ breakpointPct: acc.serves > 0 ? (acc.breakpointWins / acc.serves) * 100 : 0,
82
+ receptions: acc.receptions,
83
+ sideoutWins: acc.sideoutWins,
84
+ sideoutPct: acc.receptions > 0 ? (acc.sideoutWins / acc.receptions) * 100 : 0,
85
+ serviceErrorsReceived: acc.serviceErrorsReceived,
86
+ modReceptions,
87
+ modSideoutWins,
88
+ modSideoutPct: modReceptions > 0 ? (modSideoutWins / modReceptions) * 100 : 0,
89
+ rotations
90
+ };
91
+ }
92
+ function computeRallyMetrics(sets, homeTeamId, awayTeamId) {
93
+ const totalHome = newAcc();
94
+ const totalAway = newAcc();
95
+ const setResults = [];
96
+ for (const set of sets) {
97
+ const setHome = newAcc();
98
+ const setAway = newAcc();
99
+ accumulateSet(set, homeTeamId, awayTeamId, setHome, setAway);
100
+ accumulateSet(set, homeTeamId, awayTeamId, totalHome, totalAway);
101
+ setResults.push({ home: finalizeTeam(setHome), away: finalizeTeam(setAway) });
102
+ }
103
+ return { total: { home: finalizeTeam(totalHome), away: finalizeTeam(totalAway) }, sets: setResults };
104
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const rally_metrics_1 = require("./rally-metrics");
4
+ const event_1 = require("../event");
5
+ const serve = (failure = 0) => ({
6
+ events: [{ eventType: event_1.EventTypeEnum.SERVE, failure }]
7
+ });
8
+ const HOME = 'H';
9
+ const AWAY = 'A';
10
+ // Serving sequence H, H, A, A, H. Rally 1 (H's serve) is a service error. Final H 3 - 2 A resolves the
11
+ // last rally -> H. Winners: H, A, A, H, H. Home setter starts in zone 2, away setter in zone 1.
12
+ const set = {
13
+ homePoints: 3,
14
+ awayPoints: 2,
15
+ homeSetterStartZone: 2,
16
+ awaySetterStartZone: 1,
17
+ rallies: [
18
+ { servingTeamId: HOME, ...serve() }, // 0: H breakpoint, H setter z2
19
+ { servingTeamId: HOME, ...serve(1) }, // 1: A sideout via H service error, A setter z1
20
+ { servingTeamId: AWAY, ...serve() }, // 2: A breakpoint, A rotated to z6
21
+ { servingTeamId: AWAY, ...serve() }, // 3: H sideout, H still z2
22
+ { servingTeamId: HOME, ...serve() } // 4: H breakpoint, H rotated to z1
23
+ ]
24
+ };
25
+ const m = (0, rally_metrics_1.computeRallyMetrics)([set], HOME, AWAY);
26
+ describe('computeRallyMetrics()', () => {
27
+ it('serve / sideout / breakpoint counts and percentages', () => {
28
+ expect(m.total.home.serves).toBe(3);
29
+ expect(m.total.home.breakpointWins).toBe(2);
30
+ expect(m.total.home.breakpointPct).toBeCloseTo(66.6667, 3);
31
+ expect(m.total.home.receptions).toBe(2);
32
+ expect(m.total.home.sideoutWins).toBe(1);
33
+ expect(m.total.home.sideoutPct).toBeCloseTo(50, 5);
34
+ expect(m.total.away.serves).toBe(2);
35
+ expect(m.total.away.breakpointWins).toBe(1);
36
+ expect(m.total.away.receptions).toBe(3);
37
+ expect(m.total.away.sideoutWins).toBe(1);
38
+ expect(m.total.away.sideoutPct).toBeCloseTo(33.3333, 3);
39
+ });
40
+ it('modified sideout excludes the opponent service error', () => {
41
+ expect(m.total.away.serviceErrorsReceived).toBe(1);
42
+ expect(m.total.away.modReceptions).toBe(2);
43
+ expect(m.total.away.modSideoutWins).toBe(0);
44
+ expect(m.total.away.modSideoutPct).toBe(0);
45
+ expect(m.total.home.serviceErrorsReceived).toBe(0);
46
+ expect(m.total.home.modSideoutPct).toBeCloseTo(50, 5);
47
+ });
48
+ it('per-set rotations labeled by setter zone, split serve vs sideout', () => {
49
+ expect(m.sets).toHaveLength(1);
50
+ expect(m.sets[0].home.rotations).toEqual([
51
+ { setterZone: 1, rotation: 2, servePoints: 1, sideoutPoints: 0, points: 1 },
52
+ { setterZone: 2, rotation: 1, servePoints: 1, sideoutPoints: 1, points: 2 }
53
+ ]);
54
+ expect(m.sets[0].away.rotations).toEqual([
55
+ { setterZone: 1, rotation: 1, servePoints: 0, sideoutPoints: 1, points: 1 },
56
+ { setterZone: 6, rotation: 2, servePoints: 1, sideoutPoints: 0, points: 1 }
57
+ ]);
58
+ });
59
+ });
@@ -20,8 +20,8 @@ const decline_1 = require("./decline");
20
20
  // threshold (hard pity).
21
21
  exports.PITY_THRESHOLDS = {
22
22
  legendary: 25,
23
- mythic: 200,
24
- special: 600
23
+ mythic: 250,
24
+ special: 750
25
25
  };
26
26
  // Per-pull soft-pity step: how much a rarity's odds increase for each pull without it. Small enough
27
27
  // that base rates stay honest until the hard-pity threshold guarantees the drop.
@@ -1,4 +1,4 @@
1
- import { BoxScore, DataProps, DeclineStatus, Division as _Division, League as _League, Match as _Match, MatchSet as _MatchSet, Player as _Player, PlayerPosition, Qualifier as _Qualifier, QualifierMatch as _QualifierMatch, Rally as _Rally, RallyEvent as _RallyEvent, Season as _Season, Standing as _Standing, Team as _Team, Tournament as _Tournament, TournamentMatch as _TournamentMatch, National as _National, NationalMatch as _NationalMatch, Country as _Country, CourtPosition, ConditionLogic, EnergyBand, LiberoSubMode, PerformanceStats, PinchCondition, RotationSystemEnum, SubBand, SubMode } from '../service';
1
+ import { BoxScore, DataProps, DeclineStatus, Division as _Division, League as _League, Match as _Match, MatchSet as _MatchSet, Player as _Player, PlayerPosition, Qualifier as _Qualifier, QualifierMatch as _QualifierMatch, Rally as _Rally, RallyEvent as _RallyEvent, RallyMetrics, Season as _Season, Standing as _Standing, Team as _Team, Tournament as _Tournament, TournamentMatch as _TournamentMatch, National as _National, NationalMatch as _NationalMatch, Country as _Country, CourtPosition, ConditionLogic, EnergyBand, LiberoSubMode, PerformanceStats, PinchCondition, RotationSystemEnum, SubBand, SubMode } from '../service';
2
2
  export type Rally = DataProps<_Rally> & {
3
3
  homePlayerPosition: PlayerPosition[];
4
4
  awayPlayerPosition: PlayerPosition[];
@@ -36,6 +36,7 @@ export type Match = Omit<DataProps<_Match>, 'sets' | 'homeTeam' | 'awayTeam' | '
36
36
  national?: National;
37
37
  results?: Results;
38
38
  competition?: MatchCompetition;
39
+ rallyMetrics?: RallyMetrics;
39
40
  };
40
41
  export type RallyEvent = DataProps<_RallyEvent> & {
41
42
  team?: Team;
@@ -5,6 +5,7 @@ export * from './match-rating';
5
5
  export * from './match-set';
6
6
  export * from './rally';
7
7
  export * from './point-breakdown';
8
+ export * from './rally-metrics';
8
9
  export * from './court-position';
9
10
  export * from './match-team';
10
11
  export * from './vper';
@@ -5,6 +5,7 @@ export * from './match-rating';
5
5
  export * from './match-set';
6
6
  export * from './rally';
7
7
  export * from './point-breakdown';
8
+ export * from './rally-metrics';
8
9
  export * from './court-position';
9
10
  export * from './match-team';
10
11
  export * from './vper';
@@ -0,0 +1,44 @@
1
+ export interface RallyMetricsEvent {
2
+ readonly eventType: number;
3
+ readonly failure?: number;
4
+ }
5
+ export interface RallyMetricsRally {
6
+ readonly servingTeamId: string;
7
+ readonly events: readonly RallyMetricsEvent[];
8
+ }
9
+ export interface RallyMetricsSet {
10
+ readonly rallies: readonly RallyMetricsRally[];
11
+ readonly homePoints: number;
12
+ readonly awayPoints: number;
13
+ readonly homeSetterStartZone: number | null;
14
+ readonly awaySetterStartZone: number | null;
15
+ }
16
+ export interface RotationMetrics {
17
+ setterZone: number | null;
18
+ rotation: number;
19
+ servePoints: number;
20
+ sideoutPoints: number;
21
+ points: number;
22
+ }
23
+ export interface TeamRallyMetrics {
24
+ serves: number;
25
+ breakpointWins: number;
26
+ breakpointPct: number;
27
+ receptions: number;
28
+ sideoutWins: number;
29
+ sideoutPct: number;
30
+ serviceErrorsReceived: number;
31
+ modReceptions: number;
32
+ modSideoutWins: number;
33
+ modSideoutPct: number;
34
+ rotations: RotationMetrics[];
35
+ }
36
+ export interface SetRallyMetrics {
37
+ home: TeamRallyMetrics;
38
+ away: TeamRallyMetrics;
39
+ }
40
+ export interface RallyMetrics {
41
+ total: SetRallyMetrics;
42
+ sets: SetRallyMetrics[];
43
+ }
44
+ export declare function computeRallyMetrics(sets: readonly RallyMetricsSet[], homeTeamId: string, awayTeamId: string): RallyMetrics;
@@ -0,0 +1,101 @@
1
+ import { EventTypeEnum } from '../event';
2
+ import { rotatePosition } from './court-position';
3
+ function newAcc() {
4
+ return { serves: 0, breakpointWins: 0, receptions: 0, sideoutWins: 0, serviceErrorsReceived: 0, rotations: new Map() };
5
+ }
6
+ function isServiceError(rally) {
7
+ const serve = rally.events.find(e => e.eventType === EventTypeEnum.SERVE);
8
+ return serve != null && (serve.failure ?? 0) > 0;
9
+ }
10
+ // The setter's zone after (rotationIndex - 1) rotations from their start zone, using the engine's own
11
+ // rotatePosition (each rotation moves a player one zone: 2->1, 1->6, ...). null when no setter.
12
+ function setterZoneAt(startZone, rotationIndex) {
13
+ if (startZone == null)
14
+ return null;
15
+ let zone = startZone;
16
+ for (let r = 1; r < rotationIndex; r++)
17
+ zone = rotatePosition(zone);
18
+ return zone;
19
+ }
20
+ function addRotationPoint(acc, setterZone, rotation, kind) {
21
+ const key = setterZone != null ? `z${setterZone}` : `r${rotation}`;
22
+ let entry = acc.rotations.get(key);
23
+ if (entry == null) {
24
+ entry = { setterZone, rotation, servePoints: 0, sideoutPoints: 0 };
25
+ acc.rotations.set(key, entry);
26
+ }
27
+ if (kind === 'serve')
28
+ entry.servePoints++;
29
+ else
30
+ entry.sideoutPoints++;
31
+ }
32
+ // Walk one set, folding its rallies into the home/away accumulators (used for both per-set and total).
33
+ function accumulateSet(set, homeId, awayId, homeAcc, awayAcc) {
34
+ const { rallies } = set;
35
+ if (rallies.length === 0)
36
+ return;
37
+ const setWinnerId = set.homePoints > set.awayPoints ? homeId : awayId;
38
+ const rotation = { [homeId]: 1, [awayId]: 1 };
39
+ const startZone = { [homeId]: set.homeSetterStartZone, [awayId]: set.awaySetterStartZone };
40
+ const accOf = (id) => id === homeId ? homeAcc : id === awayId ? awayAcc : null;
41
+ for (let i = 0; i < rallies.length; i++) {
42
+ const servingId = rallies[i].servingTeamId;
43
+ const receivingId = servingId === homeId ? awayId : homeId;
44
+ const winnerId = i < rallies.length - 1 ? rallies[i + 1].servingTeamId : setWinnerId;
45
+ const serving = accOf(servingId);
46
+ const receiving = accOf(receivingId);
47
+ const winner = accOf(winnerId);
48
+ if (serving == null || receiving == null || winner == null)
49
+ continue;
50
+ serving.serves++;
51
+ receiving.receptions++;
52
+ if (isServiceError(rallies[i]))
53
+ receiving.serviceErrorsReceived++;
54
+ const rotIdx = rotation[winnerId];
55
+ const zone = setterZoneAt(startZone[winnerId], rotIdx);
56
+ if (winnerId === servingId) {
57
+ serving.breakpointWins++;
58
+ addRotationPoint(winner, zone, rotIdx, 'serve');
59
+ }
60
+ else {
61
+ receiving.sideoutWins++;
62
+ addRotationPoint(winner, zone, rotIdx, 'sideout');
63
+ }
64
+ // The sideout winner gains serve, so they rotate (after the point is attributed to their old rotation).
65
+ if (winnerId === receivingId)
66
+ rotation[winnerId] = (rotation[winnerId] % 6) + 1;
67
+ }
68
+ }
69
+ function finalizeTeam(acc) {
70
+ const modReceptions = acc.receptions - acc.serviceErrorsReceived;
71
+ const modSideoutWins = acc.sideoutWins - acc.serviceErrorsReceived;
72
+ const rotations = [...acc.rotations.values()]
73
+ .map(e => ({ ...e, points: e.servePoints + e.sideoutPoints }))
74
+ .sort((a, b) => (a.setterZone ?? a.rotation) - (b.setterZone ?? b.rotation));
75
+ return {
76
+ serves: acc.serves,
77
+ breakpointWins: acc.breakpointWins,
78
+ breakpointPct: acc.serves > 0 ? (acc.breakpointWins / acc.serves) * 100 : 0,
79
+ receptions: acc.receptions,
80
+ sideoutWins: acc.sideoutWins,
81
+ sideoutPct: acc.receptions > 0 ? (acc.sideoutWins / acc.receptions) * 100 : 0,
82
+ serviceErrorsReceived: acc.serviceErrorsReceived,
83
+ modReceptions,
84
+ modSideoutWins,
85
+ modSideoutPct: modReceptions > 0 ? (modSideoutWins / modReceptions) * 100 : 0,
86
+ rotations
87
+ };
88
+ }
89
+ export function computeRallyMetrics(sets, homeTeamId, awayTeamId) {
90
+ const totalHome = newAcc();
91
+ const totalAway = newAcc();
92
+ const setResults = [];
93
+ for (const set of sets) {
94
+ const setHome = newAcc();
95
+ const setAway = newAcc();
96
+ accumulateSet(set, homeTeamId, awayTeamId, setHome, setAway);
97
+ accumulateSet(set, homeTeamId, awayTeamId, totalHome, totalAway);
98
+ setResults.push({ home: finalizeTeam(setHome), away: finalizeTeam(setAway) });
99
+ }
100
+ return { total: { home: finalizeTeam(totalHome), away: finalizeTeam(totalAway) }, sets: setResults };
101
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,57 @@
1
+ import { computeRallyMetrics } from './rally-metrics';
2
+ import { EventTypeEnum } from '../event';
3
+ const serve = (failure = 0) => ({
4
+ events: [{ eventType: EventTypeEnum.SERVE, failure }]
5
+ });
6
+ const HOME = 'H';
7
+ const AWAY = 'A';
8
+ // Serving sequence H, H, A, A, H. Rally 1 (H's serve) is a service error. Final H 3 - 2 A resolves the
9
+ // last rally -> H. Winners: H, A, A, H, H. Home setter starts in zone 2, away setter in zone 1.
10
+ const set = {
11
+ homePoints: 3,
12
+ awayPoints: 2,
13
+ homeSetterStartZone: 2,
14
+ awaySetterStartZone: 1,
15
+ rallies: [
16
+ { servingTeamId: HOME, ...serve() }, // 0: H breakpoint, H setter z2
17
+ { servingTeamId: HOME, ...serve(1) }, // 1: A sideout via H service error, A setter z1
18
+ { servingTeamId: AWAY, ...serve() }, // 2: A breakpoint, A rotated to z6
19
+ { servingTeamId: AWAY, ...serve() }, // 3: H sideout, H still z2
20
+ { servingTeamId: HOME, ...serve() } // 4: H breakpoint, H rotated to z1
21
+ ]
22
+ };
23
+ const m = computeRallyMetrics([set], HOME, AWAY);
24
+ describe('computeRallyMetrics()', () => {
25
+ it('serve / sideout / breakpoint counts and percentages', () => {
26
+ expect(m.total.home.serves).toBe(3);
27
+ expect(m.total.home.breakpointWins).toBe(2);
28
+ expect(m.total.home.breakpointPct).toBeCloseTo(66.6667, 3);
29
+ expect(m.total.home.receptions).toBe(2);
30
+ expect(m.total.home.sideoutWins).toBe(1);
31
+ expect(m.total.home.sideoutPct).toBeCloseTo(50, 5);
32
+ expect(m.total.away.serves).toBe(2);
33
+ expect(m.total.away.breakpointWins).toBe(1);
34
+ expect(m.total.away.receptions).toBe(3);
35
+ expect(m.total.away.sideoutWins).toBe(1);
36
+ expect(m.total.away.sideoutPct).toBeCloseTo(33.3333, 3);
37
+ });
38
+ it('modified sideout excludes the opponent service error', () => {
39
+ expect(m.total.away.serviceErrorsReceived).toBe(1);
40
+ expect(m.total.away.modReceptions).toBe(2);
41
+ expect(m.total.away.modSideoutWins).toBe(0);
42
+ expect(m.total.away.modSideoutPct).toBe(0);
43
+ expect(m.total.home.serviceErrorsReceived).toBe(0);
44
+ expect(m.total.home.modSideoutPct).toBeCloseTo(50, 5);
45
+ });
46
+ it('per-set rotations labeled by setter zone, split serve vs sideout', () => {
47
+ expect(m.sets).toHaveLength(1);
48
+ expect(m.sets[0].home.rotations).toEqual([
49
+ { setterZone: 1, rotation: 2, servePoints: 1, sideoutPoints: 0, points: 1 },
50
+ { setterZone: 2, rotation: 1, servePoints: 1, sideoutPoints: 1, points: 2 }
51
+ ]);
52
+ expect(m.sets[0].away.rotations).toEqual([
53
+ { setterZone: 1, rotation: 1, servePoints: 0, sideoutPoints: 1, points: 1 },
54
+ { setterZone: 6, rotation: 2, servePoints: 1, sideoutPoints: 0, points: 1 }
55
+ ]);
56
+ });
57
+ });
@@ -14,8 +14,8 @@ import { declineProfiles } from './decline';
14
14
  // threshold (hard pity).
15
15
  export const PITY_THRESHOLDS = {
16
16
  legendary: 25,
17
- mythic: 200,
18
- special: 600
17
+ mythic: 250,
18
+ special: 750
19
19
  };
20
20
  // Per-pull soft-pity step: how much a rarity's odds increase for each pull without it. Small enough
21
21
  // that base rates stay honest until the hard-pity threshold guarantees the drop.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.421",
3
+ "version": "0.0.423",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",