volleyballsimtypes 0.0.418 → 0.0.420

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.
@@ -40,7 +40,7 @@ export type Match = Omit<DataProps<_Match>, 'sets' | 'homeTeam' | 'awayTeam' | '
40
40
  export type RallyEvent = DataProps<_RallyEvent> & {
41
41
  team?: Team;
42
42
  };
43
- export type Player = Omit<DataProps<_Player>, 'stats' | 'birthAge' | 'birthIteration' | 'declineProfile'> & {
43
+ export type Player = Omit<DataProps<_Player>, 'stats' | 'birthAge' | 'birthIteration' | 'declineProfile' | 'nickname'> & {
44
44
  -readonly [K in 'birthAge' | 'birthIteration' | 'declineProfile']?: DataProps<_Player>[K];
45
45
  } & {
46
46
  stats?: PerformanceStats;
@@ -48,6 +48,7 @@ export type Player = Omit<DataProps<_Player>, 'stats' | 'birthAge' | 'birthItera
48
48
  jerseyNumber: number;
49
49
  locked?: boolean;
50
50
  declineStatus?: DeclineStatus;
51
+ nickname?: string;
51
52
  };
52
53
  export interface StartingLineup {
53
54
  [CourtPosition.LEFT_FRONT]: string;
@@ -9,6 +9,7 @@ export interface PlayerAttributes {
9
9
  rarity: Rarity;
10
10
  first_name: string;
11
11
  last_name: string;
12
+ nickname?: string | null;
12
13
  country_id: string;
13
14
  birth_age: number;
14
15
  birth_iteration: number;
@@ -27,6 +28,7 @@ export declare class PlayerModel extends Model<PlayerAttributes, PlayerCreationA
27
28
  rarity: Rarity;
28
29
  first_name: string;
29
30
  last_name: string;
31
+ nickname: string | null;
30
32
  country_id: string;
31
33
  birth_age: number;
32
34
  birth_iteration: number;
@@ -32,6 +32,10 @@ class PlayerModel extends sequelize_1.Model {
32
32
  type: sequelize_1.DataTypes.STRING,
33
33
  allowNull: false
34
34
  },
35
+ nickname: {
36
+ type: sequelize_1.DataTypes.STRING(16),
37
+ allowNull: true
38
+ },
35
39
  country_id: {
36
40
  type: sequelize_1.DataTypes.UUID,
37
41
  allowNull: false,
@@ -17,6 +17,7 @@ function transformToAttributes(player) {
17
17
  country_id: player.country.id,
18
18
  first_name: player.name.first,
19
19
  last_name: player.name.last,
20
+ nickname: player.nickname ?? null,
20
21
  roles: player.roles,
21
22
  traits: player.traits,
22
23
  PerformanceStat: (0, _1.transformFromPerformanceStats)(player.stats, player.id),
@@ -80,6 +81,7 @@ function transformToObject(model, currentIteration) {
80
81
  first: model.first_name,
81
82
  last: model.last_name
82
83
  },
84
+ nickname: model.nickname ?? undefined,
83
85
  country: (0, _1.transformToCountry)(model.country),
84
86
  roles: model.roles,
85
87
  traits: model.traits,
@@ -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)', () => {
@@ -25,6 +25,7 @@ export declare class Name {
25
25
  export declare class Player {
26
26
  readonly id: string;
27
27
  readonly name: Name;
28
+ readonly nickname?: string;
28
29
  readonly country: Country;
29
30
  readonly stats: PerformanceStats;
30
31
  readonly roles: Role[];
@@ -54,9 +54,10 @@ class Player {
54
54
  stats: performance_stats_1.PerformanceStats.create(result.data.stats)
55
55
  });
56
56
  }
57
- constructor({ id, name, country, stats, roles, traits, rarity, age, birthAge, birthIteration, declineProfile, boxScores, boxScoreTotals }) {
57
+ constructor({ id, name, nickname, country, stats, roles, traits, rarity, age, birthAge, birthIteration, declineProfile, boxScores, boxScoreTotals }) {
58
58
  this.id = id;
59
59
  this.name = name;
60
+ this.nickname = nickname;
60
61
  this.country = country;
61
62
  this.stats = stats;
62
63
  this.roles = roles;
@@ -14,6 +14,7 @@ export declare const PlayerInputSchema: z.ZodObject<{
14
14
  first: z.ZodString;
15
15
  last: z.ZodString;
16
16
  }, z.core.$strip>;
17
+ nickname: z.ZodOptional<z.ZodString>;
17
18
  country: z.ZodCustom<Country, Country>;
18
19
  stats: z.ZodObject<{
19
20
  attack: z.ZodNumber;
@@ -28,6 +28,7 @@ const BoxScoreTotalsInputSchema = zod_1.z.object({
28
28
  exports.PlayerInputSchema = zod_1.z.object({
29
29
  id: zod_1.z.uuid(),
30
30
  name: exports.NameInputSchema,
31
+ nickname: zod_1.z.string().max(16).optional(),
31
32
  country: countrySchema,
32
33
  stats: performance_stats_z_1.PerformanceStatsInputSchema,
33
34
  roles: zod_1.z.array(zod_1.z.enum(Object.values(role_1.RoleEnum))).min(1),
@@ -40,7 +40,7 @@ export type Match = Omit<DataProps<_Match>, 'sets' | 'homeTeam' | 'awayTeam' | '
40
40
  export type RallyEvent = DataProps<_RallyEvent> & {
41
41
  team?: Team;
42
42
  };
43
- export type Player = Omit<DataProps<_Player>, 'stats' | 'birthAge' | 'birthIteration' | 'declineProfile'> & {
43
+ export type Player = Omit<DataProps<_Player>, 'stats' | 'birthAge' | 'birthIteration' | 'declineProfile' | 'nickname'> & {
44
44
  -readonly [K in 'birthAge' | 'birthIteration' | 'declineProfile']?: DataProps<_Player>[K];
45
45
  } & {
46
46
  stats?: PerformanceStats;
@@ -48,6 +48,7 @@ export type Player = Omit<DataProps<_Player>, 'stats' | 'birthAge' | 'birthItera
48
48
  jerseyNumber: number;
49
49
  locked?: boolean;
50
50
  declineStatus?: DeclineStatus;
51
+ nickname?: string;
51
52
  };
52
53
  export interface StartingLineup {
53
54
  [CourtPosition.LEFT_FRONT]: string;
@@ -9,6 +9,7 @@ export interface PlayerAttributes {
9
9
  rarity: Rarity;
10
10
  first_name: string;
11
11
  last_name: string;
12
+ nickname?: string | null;
12
13
  country_id: string;
13
14
  birth_age: number;
14
15
  birth_iteration: number;
@@ -27,6 +28,7 @@ export declare class PlayerModel extends Model<PlayerAttributes, PlayerCreationA
27
28
  rarity: Rarity;
28
29
  first_name: string;
29
30
  last_name: string;
31
+ nickname: string | null;
30
32
  country_id: string;
31
33
  birth_age: number;
32
34
  birth_iteration: number;
@@ -29,6 +29,10 @@ export class PlayerModel extends Model {
29
29
  type: DataTypes.STRING,
30
30
  allowNull: false
31
31
  },
32
+ nickname: {
33
+ type: DataTypes.STRING(16),
34
+ allowNull: true
35
+ },
32
36
  country_id: {
33
37
  type: DataTypes.UUID,
34
38
  allowNull: false,
@@ -13,6 +13,7 @@ function transformToAttributes(player) {
13
13
  country_id: player.country.id,
14
14
  first_name: player.name.first,
15
15
  last_name: player.name.last,
16
+ nickname: player.nickname ?? null,
16
17
  roles: player.roles,
17
18
  traits: player.traits,
18
19
  PerformanceStat: transformFromPerformanceStats(player.stats, player.id),
@@ -76,6 +77,7 @@ function transformToObject(model, currentIteration) {
76
77
  first: model.first_name,
77
78
  last: model.last_name
78
79
  },
80
+ nickname: model.nickname ?? undefined,
79
81
  country: transformToCountry(model.country),
80
82
  roles: model.roles,
81
83
  traits: model.traits,
@@ -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)', () => {
@@ -25,6 +25,7 @@ export declare class Name {
25
25
  export declare class Player {
26
26
  readonly id: string;
27
27
  readonly name: Name;
28
+ readonly nickname?: string;
28
29
  readonly country: Country;
29
30
  readonly stats: PerformanceStats;
30
31
  readonly roles: Role[];
@@ -49,9 +49,10 @@ export class Player {
49
49
  stats: PerformanceStats.create(result.data.stats)
50
50
  });
51
51
  }
52
- constructor({ id, name, country, stats, roles, traits, rarity, age, birthAge, birthIteration, declineProfile, boxScores, boxScoreTotals }) {
52
+ constructor({ id, name, nickname, country, stats, roles, traits, rarity, age, birthAge, birthIteration, declineProfile, boxScores, boxScoreTotals }) {
53
53
  this.id = id;
54
54
  this.name = name;
55
+ this.nickname = nickname;
55
56
  this.country = country;
56
57
  this.stats = stats;
57
58
  this.roles = roles;
@@ -14,6 +14,7 @@ export declare const PlayerInputSchema: z.ZodObject<{
14
14
  first: z.ZodString;
15
15
  last: z.ZodString;
16
16
  }, z.core.$strip>;
17
+ nickname: z.ZodOptional<z.ZodString>;
17
18
  country: z.ZodCustom<Country, Country>;
18
19
  stats: z.ZodObject<{
19
20
  attack: z.ZodNumber;
@@ -25,6 +25,7 @@ const BoxScoreTotalsInputSchema = z.object({
25
25
  export const PlayerInputSchema = z.object({
26
26
  id: z.uuid(),
27
27
  name: NameInputSchema,
28
+ nickname: z.string().max(16).optional(),
28
29
  country: countrySchema,
29
30
  stats: PerformanceStatsInputSchema,
30
31
  roles: z.array(z.enum(Object.values(RoleEnum))).min(1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.418",
3
+ "version": "0.0.420",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",