volleyballsimtypes 0.0.437 → 0.0.439

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, 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';
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, PointBreakdown, 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[];
@@ -44,6 +44,7 @@ export type Match = Omit<DataProps<_Match>, 'sets' | 'homeTeam' | 'awayTeam' | '
44
44
  results?: Results;
45
45
  competition?: MatchCompetition;
46
46
  rallyMetrics?: RallyMetrics;
47
+ breakdown?: PointBreakdown;
47
48
  homeForm?: MatchForm[];
48
49
  awayForm?: MatchForm[];
49
50
  };
@@ -3,6 +3,38 @@ export interface MatchRallyAggregates {
3
3
  rallyMetrics: RallyMetrics;
4
4
  breakdown: PointBreakdown;
5
5
  }
6
+ export interface MatchRallyAggregatesInput {
7
+ readonly sets: ReadonlyArray<{
8
+ readonly rallies: ReadonlyArray<{
9
+ readonly servingTeamId: string;
10
+ readonly events: ReadonlyArray<{
11
+ readonly eventType: number;
12
+ readonly failure?: number;
13
+ readonly playerId: string;
14
+ }>;
15
+ }>;
16
+ readonly homePoints: number;
17
+ readonly awayPoints: number;
18
+ readonly homePlayerPosition?: ReadonlyArray<{
19
+ readonly playerId: string;
20
+ readonly position: number;
21
+ }>;
22
+ readonly awayPlayerPosition?: ReadonlyArray<{
23
+ readonly playerId: string;
24
+ readonly position: number;
25
+ }>;
26
+ }>;
27
+ readonly homeTeamId: string;
28
+ readonly awayTeamId: string;
29
+ readonly homeSetterId: string | null;
30
+ readonly awaySetterId: string | null;
31
+ readonly teamOf: (playerId: string) => string | null;
32
+ readonly homeKills: number;
33
+ readonly awayKills: number;
34
+ readonly homeAces: number;
35
+ readonly awayAces: number;
36
+ }
37
+ export declare function computeMatchRallyAggregates(input: MatchRallyAggregatesInput): MatchRallyAggregates;
6
38
  export interface RallyEventLike {
7
39
  readonly eventType: number;
8
40
  readonly playerId: string;
@@ -1,8 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeMatchRallyAggregates = computeMatchRallyAggregates;
3
4
  exports.tallyBlockPoints = tallyBlockPoints;
4
5
  exports.computePointBreakdown = computePointBreakdown;
5
6
  const event_1 = require("../event");
7
+ const rally_metrics_1 = require("./rally-metrics");
8
+ function computeMatchRallyAggregates(input) {
9
+ const setterZoneOf = (positions, setterId) => {
10
+ if (setterId == null)
11
+ return null;
12
+ const pos = positions?.find(p => p.playerId === setterId)?.position;
13
+ return pos != null && pos >= 1 && pos <= 6 ? pos : null;
14
+ };
15
+ const rallyMetrics = (0, rally_metrics_1.computeRallyMetrics)(input.sets.map(s => ({
16
+ rallies: s.rallies,
17
+ homePoints: s.homePoints,
18
+ awayPoints: s.awayPoints,
19
+ homeSetterStartZone: setterZoneOf(s.homePlayerPosition, input.homeSetterId),
20
+ awaySetterStartZone: setterZoneOf(s.awayPlayerPosition, input.awaySetterId)
21
+ })), input.homeTeamId, input.awayTeamId);
22
+ const homeTotalPoints = input.sets.reduce((a, s) => a + s.homePoints, 0);
23
+ const awayTotalPoints = input.sets.reduce((a, s) => a + s.awayPoints, 0);
24
+ const breakdown = computePointBreakdown({
25
+ rallies: input.sets.flatMap(s => s.rallies),
26
+ homeTeamId: input.homeTeamId,
27
+ awayTeamId: input.awayTeamId,
28
+ teamOf: input.teamOf,
29
+ homeKills: input.homeKills,
30
+ awayKills: input.awayKills,
31
+ homeAces: input.homeAces,
32
+ awayAces: input.awayAces,
33
+ homeTotalPoints,
34
+ awayTotalPoints
35
+ });
36
+ return { rallyMetrics, breakdown };
37
+ }
6
38
  // A block scores a point in exactly ONE place in the sim (reception-simulator: a dig of a block fails
7
39
  // and the block landed in-court, i.e. target >= 7). Each such rally is ONE block point regardless of how
8
40
  // many blockers were on it; the box score records it as one `block_assists` per blocker (or one
@@ -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, 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';
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, PointBreakdown, 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[];
@@ -44,6 +44,7 @@ export type Match = Omit<DataProps<_Match>, 'sets' | 'homeTeam' | 'awayTeam' | '
44
44
  results?: Results;
45
45
  competition?: MatchCompetition;
46
46
  rallyMetrics?: RallyMetrics;
47
+ breakdown?: PointBreakdown;
47
48
  homeForm?: MatchForm[];
48
49
  awayForm?: MatchForm[];
49
50
  };
@@ -3,6 +3,38 @@ export interface MatchRallyAggregates {
3
3
  rallyMetrics: RallyMetrics;
4
4
  breakdown: PointBreakdown;
5
5
  }
6
+ export interface MatchRallyAggregatesInput {
7
+ readonly sets: ReadonlyArray<{
8
+ readonly rallies: ReadonlyArray<{
9
+ readonly servingTeamId: string;
10
+ readonly events: ReadonlyArray<{
11
+ readonly eventType: number;
12
+ readonly failure?: number;
13
+ readonly playerId: string;
14
+ }>;
15
+ }>;
16
+ readonly homePoints: number;
17
+ readonly awayPoints: number;
18
+ readonly homePlayerPosition?: ReadonlyArray<{
19
+ readonly playerId: string;
20
+ readonly position: number;
21
+ }>;
22
+ readonly awayPlayerPosition?: ReadonlyArray<{
23
+ readonly playerId: string;
24
+ readonly position: number;
25
+ }>;
26
+ }>;
27
+ readonly homeTeamId: string;
28
+ readonly awayTeamId: string;
29
+ readonly homeSetterId: string | null;
30
+ readonly awaySetterId: string | null;
31
+ readonly teamOf: (playerId: string) => string | null;
32
+ readonly homeKills: number;
33
+ readonly awayKills: number;
34
+ readonly homeAces: number;
35
+ readonly awayAces: number;
36
+ }
37
+ export declare function computeMatchRallyAggregates(input: MatchRallyAggregatesInput): MatchRallyAggregates;
6
38
  export interface RallyEventLike {
7
39
  readonly eventType: number;
8
40
  readonly playerId: string;
@@ -1,4 +1,35 @@
1
1
  import { EventTypeEnum } from '../event';
2
+ import { computeRallyMetrics } from './rally-metrics';
3
+ export function computeMatchRallyAggregates(input) {
4
+ const setterZoneOf = (positions, setterId) => {
5
+ if (setterId == null)
6
+ return null;
7
+ const pos = positions?.find(p => p.playerId === setterId)?.position;
8
+ return pos != null && pos >= 1 && pos <= 6 ? pos : null;
9
+ };
10
+ const rallyMetrics = computeRallyMetrics(input.sets.map(s => ({
11
+ rallies: s.rallies,
12
+ homePoints: s.homePoints,
13
+ awayPoints: s.awayPoints,
14
+ homeSetterStartZone: setterZoneOf(s.homePlayerPosition, input.homeSetterId),
15
+ awaySetterStartZone: setterZoneOf(s.awayPlayerPosition, input.awaySetterId)
16
+ })), input.homeTeamId, input.awayTeamId);
17
+ const homeTotalPoints = input.sets.reduce((a, s) => a + s.homePoints, 0);
18
+ const awayTotalPoints = input.sets.reduce((a, s) => a + s.awayPoints, 0);
19
+ const breakdown = computePointBreakdown({
20
+ rallies: input.sets.flatMap(s => s.rallies),
21
+ homeTeamId: input.homeTeamId,
22
+ awayTeamId: input.awayTeamId,
23
+ teamOf: input.teamOf,
24
+ homeKills: input.homeKills,
25
+ awayKills: input.awayKills,
26
+ homeAces: input.homeAces,
27
+ awayAces: input.awayAces,
28
+ homeTotalPoints,
29
+ awayTotalPoints
30
+ });
31
+ return { rallyMetrics, breakdown };
32
+ }
2
33
  // A block scores a point in exactly ONE place in the sim (reception-simulator: a dig of a block fails
3
34
  // and the block landed in-court, i.e. target >= 7). Each such rally is ONE block point regardless of how
4
35
  // many blockers were on it; the box score records it as one `block_assists` per blocker (or one
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.437",
3
+ "version": "0.0.439",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",