volleyballsimtypes 0.0.436 → 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.
@@ -2,6 +2,7 @@ import * as Sequelize from 'sequelize';
2
2
  import { Model } from 'sequelize';
3
3
  import { Status } from '../common';
4
4
  import { CompetitionMatchId, CompetitionMatchModel, MatchRatingId, MatchRatingModel, MatchResultId, MatchResultModel, MatchSetAttributes, MatchSetId, MatchSetModel, VPERAttributes, VPERId, VPERModel, TeamId, TeamModel } from '.';
5
+ import { MatchRallyAggregates } from '../../service';
5
6
  export interface MatchAttributes {
6
7
  match_id: string;
7
8
  home_team: string;
@@ -11,6 +12,7 @@ export interface MatchAttributes {
11
12
  created_at?: Date;
12
13
  in_progress_at?: Date;
13
14
  complete_at?: Date;
15
+ rally_aggregates?: MatchRallyAggregates | null;
14
16
  MatchSets?: MatchSetAttributes[];
15
17
  VPERs?: VPERAttributes[];
16
18
  }
@@ -26,6 +28,7 @@ export declare class MatchModel extends Model<MatchAttributes, MatchCreationAttr
26
28
  created_at?: Date;
27
29
  in_progress_at?: Date;
28
30
  complete_at?: Date;
31
+ rally_aggregates?: MatchRallyAggregates | null;
29
32
  CompetitionMatch: CompetitionMatchModel;
30
33
  getCompetitionMatch: Sequelize.HasOneGetAssociationMixin<CompetitionMatchModel>;
31
34
  setCompetitionMatch: Sequelize.HasOneSetAssociationMixin<CompetitionMatchModel, CompetitionMatchId>;
@@ -47,6 +47,10 @@ class MatchModel extends sequelize_1.Model {
47
47
  complete_at: {
48
48
  type: sequelize_1.DataTypes.DATE,
49
49
  allowNull: true
50
+ },
51
+ rally_aggregates: {
52
+ type: sequelize_1.DataTypes.JSONB,
53
+ allowNull: true
50
54
  }
51
55
  }, {
52
56
  sequelize,
@@ -1,3 +1,40 @@
1
+ import { RallyMetrics } from './rally-metrics';
2
+ export interface MatchRallyAggregates {
3
+ rallyMetrics: RallyMetrics;
4
+ breakdown: PointBreakdown;
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;
1
38
  export interface RallyEventLike {
2
39
  readonly eventType: number;
3
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
@@ -2,6 +2,7 @@ import * as Sequelize from 'sequelize';
2
2
  import { Model } from 'sequelize';
3
3
  import { Status } from '../common';
4
4
  import { CompetitionMatchId, CompetitionMatchModel, MatchRatingId, MatchRatingModel, MatchResultId, MatchResultModel, MatchSetAttributes, MatchSetId, MatchSetModel, VPERAttributes, VPERId, VPERModel, TeamId, TeamModel } from '.';
5
+ import { MatchRallyAggregates } from '../../service';
5
6
  export interface MatchAttributes {
6
7
  match_id: string;
7
8
  home_team: string;
@@ -11,6 +12,7 @@ export interface MatchAttributes {
11
12
  created_at?: Date;
12
13
  in_progress_at?: Date;
13
14
  complete_at?: Date;
15
+ rally_aggregates?: MatchRallyAggregates | null;
14
16
  MatchSets?: MatchSetAttributes[];
15
17
  VPERs?: VPERAttributes[];
16
18
  }
@@ -26,6 +28,7 @@ export declare class MatchModel extends Model<MatchAttributes, MatchCreationAttr
26
28
  created_at?: Date;
27
29
  in_progress_at?: Date;
28
30
  complete_at?: Date;
31
+ rally_aggregates?: MatchRallyAggregates | null;
29
32
  CompetitionMatch: CompetitionMatchModel;
30
33
  getCompetitionMatch: Sequelize.HasOneGetAssociationMixin<CompetitionMatchModel>;
31
34
  setCompetitionMatch: Sequelize.HasOneSetAssociationMixin<CompetitionMatchModel, CompetitionMatchId>;
@@ -44,6 +44,10 @@ export class MatchModel extends Model {
44
44
  complete_at: {
45
45
  type: DataTypes.DATE,
46
46
  allowNull: true
47
+ },
48
+ rally_aggregates: {
49
+ type: DataTypes.JSONB,
50
+ allowNull: true
47
51
  }
48
52
  }, {
49
53
  sequelize,
@@ -1,3 +1,40 @@
1
+ import { RallyMetrics } from './rally-metrics';
2
+ export interface MatchRallyAggregates {
3
+ rallyMetrics: RallyMetrics;
4
+ breakdown: PointBreakdown;
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;
1
38
  export interface RallyEventLike {
2
39
  readonly eventType: number;
3
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.436",
3
+ "version": "0.0.438",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",