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.
@@ -1,10 +1,16 @@
1
- import { type Rally } from './rally';
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: Rally[], teamOf: (playerId: string) => string | null): Map<string, TeamBlockTally>;
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: Rally[];
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. The blockSolo / blockAssists tallies must reconstruct box.block.solo and
11
- // box.block.assists exactly (the correctness gate).
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
- // Minimal event/rally builders - the tally only reads eventType, failure, target, blockers, playerId.
7
- const blockEvent = (playerId, target, blockers) => ({ eventType: event_1.EventTypeEnum.BLOCK, playerId, target, blockers, failure: 0, type: blockers.length, score: 0, activeTraits: [] });
8
- const receptionEvent = (playerId, failure) => ({ eventType: event_1.EventTypeEnum.RECEPTION, playerId, failure, target: 0, type: 0, score: 0, activeTraits: [] });
9
- const serveEvent = (playerId, failure) => ({ eventType: event_1.EventTypeEnum.SERVE, playerId, failure });
10
- const spikeEvent = (playerId) => ({ eventType: event_1.EventTypeEnum.SPIKE, playerId, failure: 0 });
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', 0), receptionEvent('a3', 1)])], teamOf);
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
- import { type Rally } from './rally';
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: Rally[], teamOf: (playerId: string) => string | null): Map<string, TeamBlockTally>;
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: Rally[];
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. The blockSolo / blockAssists tallies must reconstruct box.block.solo and
7
- // box.block.assists exactly (the correctness gate).
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
- // Minimal event/rally builders - the tally only reads eventType, failure, target, blockers, playerId.
5
- const blockEvent = (playerId, target, blockers) => ({ eventType: EventTypeEnum.BLOCK, playerId, target, blockers, failure: 0, type: blockers.length, score: 0, activeTraits: [] });
6
- const receptionEvent = (playerId, failure) => ({ eventType: EventTypeEnum.RECEPTION, playerId, failure, target: 0, type: 0, score: 0, activeTraits: [] });
7
- const serveEvent = (playerId, failure) => ({ eventType: EventTypeEnum.SERVE, playerId, failure });
8
- const spikeEvent = (playerId) => ({ eventType: EventTypeEnum.SPIKE, playerId, failure: 0 });
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', 0), receptionEvent('a3', 1)])], teamOf);
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)', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.418",
3
+ "version": "0.0.419",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",