volleyballsimtypes 0.0.418 → 0.0.419
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/service/match/point-breakdown.d.ts +9 -3
- package/dist/cjs/src/service/match/point-breakdown.js +3 -5
- package/dist/cjs/src/service/match/point-breakdown.test.js +6 -7
- package/dist/esm/src/service/match/point-breakdown.d.ts +9 -3
- package/dist/esm/src/service/match/point-breakdown.js +3 -5
- package/dist/esm/src/service/match/point-breakdown.test.js +6 -7
- package/package.json +1 -1
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
export interface RallyEventLike {
|
|
2
|
+
readonly eventType: number;
|
|
3
|
+
readonly playerId: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RallyLike {
|
|
6
|
+
readonly events: readonly RallyEventLike[];
|
|
7
|
+
}
|
|
2
8
|
export interface TeamBlockTally {
|
|
3
9
|
blockPoints: number;
|
|
4
10
|
blockSolo: number;
|
|
5
11
|
blockAssists: number;
|
|
6
12
|
}
|
|
7
|
-
export declare function tallyBlockPoints(rallies:
|
|
13
|
+
export declare function tallyBlockPoints(rallies: readonly RallyLike[], teamOf: (playerId: string) => string | null): Map<string, TeamBlockTally>;
|
|
8
14
|
export interface TeamPointBreakdown {
|
|
9
15
|
kills: number;
|
|
10
16
|
aces: number;
|
|
@@ -16,7 +22,7 @@ export interface PointBreakdown {
|
|
|
16
22
|
away: TeamPointBreakdown;
|
|
17
23
|
}
|
|
18
24
|
export interface PointBreakdownInput {
|
|
19
|
-
rallies:
|
|
25
|
+
rallies: readonly RallyLike[];
|
|
20
26
|
homeTeamId: string;
|
|
21
27
|
awayTeamId: string;
|
|
22
28
|
teamOf: (playerId: string) => string | null;
|
|
@@ -7,11 +7,9 @@ const event_1 = require("../event");
|
|
|
7
7
|
// and the block landed in-court, i.e. target >= 7). Each such rally is ONE block point regardless of how
|
|
8
8
|
// many blockers were on it; the box score records it as one `block_assists` per blocker (or one
|
|
9
9
|
// `block_solo`), which is why summing solo+assists over-counts block points. We rebuild the true count
|
|
10
|
-
// from the rallies.
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// `teamOf(playerId)` returns the team id of a player (or null if unknown). The scoring team is the
|
|
14
|
-
// blockers' team.
|
|
10
|
+
// from the rallies. blockSolo / blockAssists must reconstruct box.block.solo and box.block.assists
|
|
11
|
+
// exactly (the correctness gate). `teamOf(playerId)` returns a player's team id (or null); the scoring
|
|
12
|
+
// team is the blockers' team.
|
|
15
13
|
function tallyBlockPoints(rallies, teamOf) {
|
|
16
14
|
const out = new Map();
|
|
17
15
|
const tallyFor = (team) => {
|
|
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const globals_1 = require("@jest/globals");
|
|
4
4
|
const event_1 = require("../event");
|
|
5
5
|
const point_breakdown_1 = require("./point-breakdown");
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const rally = (events) => ({ id: 'r', order: 0, servingTeamId: 'HOME', events });
|
|
6
|
+
const blockEvent = (playerId, target, blockers) => ({ eventType: event_1.EventTypeEnum.BLOCK, playerId, target, blockers });
|
|
7
|
+
const receptionEvent = (playerId, failure) => ({ eventType: event_1.EventTypeEnum.RECEPTION, playerId, failure });
|
|
8
|
+
const serveEvent = (playerId) => ({ eventType: event_1.EventTypeEnum.SERVE, playerId });
|
|
9
|
+
const spikeEvent = (playerId) => ({ eventType: event_1.EventTypeEnum.SPIKE, playerId });
|
|
10
|
+
const rally = (events) => ({ events });
|
|
12
11
|
const teamOf = (id) => id.startsWith('h') ? 'HOME' : id.startsWith('a') ? 'AWAY' : null;
|
|
13
12
|
(0, globals_1.describe)('tallyBlockPoints', () => {
|
|
14
13
|
(0, globals_1.it)('counts an assisted block point once, recording each blocker as an assist', () => {
|
|
@@ -24,7 +23,7 @@ const teamOf = (id) => id.startsWith('h') ? 'HOME' : id.startsWith('a') ? 'AWAY'
|
|
|
24
23
|
(0, globals_1.expect)(t.size).toBe(0);
|
|
25
24
|
});
|
|
26
25
|
(0, globals_1.it)('does NOT count an ace (reception fail after serve)', () => {
|
|
27
|
-
const t = (0, point_breakdown_1.tallyBlockPoints)([rally([serveEvent('h1'
|
|
26
|
+
const t = (0, point_breakdown_1.tallyBlockPoints)([rally([serveEvent('h1'), receptionEvent('a3', 1)])], teamOf);
|
|
28
27
|
(0, globals_1.expect)(t.size).toBe(0);
|
|
29
28
|
});
|
|
30
29
|
(0, globals_1.it)('does NOT count a successful dig (reception failure 0)', () => {
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
export interface RallyEventLike {
|
|
2
|
+
readonly eventType: number;
|
|
3
|
+
readonly playerId: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RallyLike {
|
|
6
|
+
readonly events: readonly RallyEventLike[];
|
|
7
|
+
}
|
|
2
8
|
export interface TeamBlockTally {
|
|
3
9
|
blockPoints: number;
|
|
4
10
|
blockSolo: number;
|
|
5
11
|
blockAssists: number;
|
|
6
12
|
}
|
|
7
|
-
export declare function tallyBlockPoints(rallies:
|
|
13
|
+
export declare function tallyBlockPoints(rallies: readonly RallyLike[], teamOf: (playerId: string) => string | null): Map<string, TeamBlockTally>;
|
|
8
14
|
export interface TeamPointBreakdown {
|
|
9
15
|
kills: number;
|
|
10
16
|
aces: number;
|
|
@@ -16,7 +22,7 @@ export interface PointBreakdown {
|
|
|
16
22
|
away: TeamPointBreakdown;
|
|
17
23
|
}
|
|
18
24
|
export interface PointBreakdownInput {
|
|
19
|
-
rallies:
|
|
25
|
+
rallies: readonly RallyLike[];
|
|
20
26
|
homeTeamId: string;
|
|
21
27
|
awayTeamId: string;
|
|
22
28
|
teamOf: (playerId: string) => string | null;
|
|
@@ -3,11 +3,9 @@ import { EventTypeEnum } from '../event';
|
|
|
3
3
|
// and the block landed in-court, i.e. target >= 7). Each such rally is ONE block point regardless of how
|
|
4
4
|
// many blockers were on it; the box score records it as one `block_assists` per blocker (or one
|
|
5
5
|
// `block_solo`), which is why summing solo+assists over-counts block points. We rebuild the true count
|
|
6
|
-
// from the rallies.
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// `teamOf(playerId)` returns the team id of a player (or null if unknown). The scoring team is the
|
|
10
|
-
// blockers' team.
|
|
6
|
+
// from the rallies. blockSolo / blockAssists must reconstruct box.block.solo and box.block.assists
|
|
7
|
+
// exactly (the correctness gate). `teamOf(playerId)` returns a player's team id (or null); the scoring
|
|
8
|
+
// team is the blockers' team.
|
|
11
9
|
export function tallyBlockPoints(rallies, teamOf) {
|
|
12
10
|
const out = new Map();
|
|
13
11
|
const tallyFor = (team) => {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { describe, expect, it } from '@jest/globals';
|
|
2
2
|
import { EventTypeEnum } from '../event';
|
|
3
3
|
import { computePointBreakdown, tallyBlockPoints } from './point-breakdown';
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const rally = (events) => ({ id: 'r', order: 0, servingTeamId: 'HOME', events });
|
|
4
|
+
const blockEvent = (playerId, target, blockers) => ({ eventType: EventTypeEnum.BLOCK, playerId, target, blockers });
|
|
5
|
+
const receptionEvent = (playerId, failure) => ({ eventType: EventTypeEnum.RECEPTION, playerId, failure });
|
|
6
|
+
const serveEvent = (playerId) => ({ eventType: EventTypeEnum.SERVE, playerId });
|
|
7
|
+
const spikeEvent = (playerId) => ({ eventType: EventTypeEnum.SPIKE, playerId });
|
|
8
|
+
const rally = (events) => ({ events });
|
|
10
9
|
const teamOf = (id) => id.startsWith('h') ? 'HOME' : id.startsWith('a') ? 'AWAY' : null;
|
|
11
10
|
describe('tallyBlockPoints', () => {
|
|
12
11
|
it('counts an assisted block point once, recording each blocker as an assist', () => {
|
|
@@ -22,7 +21,7 @@ describe('tallyBlockPoints', () => {
|
|
|
22
21
|
expect(t.size).toBe(0);
|
|
23
22
|
});
|
|
24
23
|
it('does NOT count an ace (reception fail after serve)', () => {
|
|
25
|
-
const t = tallyBlockPoints([rally([serveEvent('h1'
|
|
24
|
+
const t = tallyBlockPoints([rally([serveEvent('h1'), receptionEvent('a3', 1)])], teamOf);
|
|
26
25
|
expect(t.size).toBe(0);
|
|
27
26
|
});
|
|
28
27
|
it('does NOT count a successful dig (reception failure 0)', () => {
|