volleyballsimtypes 0.0.437 → 0.0.438
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.
|
@@ -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
|
|
@@ -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
|