volleyballsimtypes 0.0.123 → 0.0.125

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.
Files changed (51) hide show
  1. package/dist/cjs/src/data/init-models.d.ts +1 -35
  2. package/dist/cjs/src/data/models/coach.js +2 -2
  3. package/dist/cjs/src/data/models/player-team.d.ts +1 -2
  4. package/dist/cjs/src/data/models/rally.js +1 -1
  5. package/dist/cjs/src/data/transformers/coach.js +2 -2
  6. package/dist/cjs/src/data/transformers/draft.js +3 -2
  7. package/dist/cjs/src/data/transformers/league.js +6 -4
  8. package/dist/cjs/src/data/transformers/match-set-stats.js +1 -1
  9. package/dist/cjs/src/data/transformers/match-set.js +20 -11
  10. package/dist/cjs/src/data/transformers/match.js +7 -5
  11. package/dist/cjs/src/data/transformers/player.js +6 -4
  12. package/dist/cjs/src/data/transformers/rally.js +20 -1
  13. package/dist/cjs/src/data/transformers/season.js +41 -30
  14. package/dist/cjs/src/data/transformers/team.js +3 -3
  15. package/dist/cjs/src/data/transformers/tournament.js +6 -4
  16. package/dist/cjs/src/data/transformers/trait.js +5 -1
  17. package/dist/cjs/src/service/coach/coach.d.ts +2 -2
  18. package/dist/cjs/src/service/event/block.d.ts +1 -1
  19. package/dist/cjs/src/service/event/libero-replacement.d.ts +1 -1
  20. package/dist/cjs/src/service/event/reception.d.ts +1 -1
  21. package/dist/cjs/src/service/event/serve.d.ts +1 -1
  22. package/dist/cjs/src/service/event/set.d.ts +1 -1
  23. package/dist/cjs/src/service/event/spike.d.ts +1 -1
  24. package/dist/cjs/src/service/event/substitution.d.ts +1 -1
  25. package/dist/cjs/src/service/team/team.js +3 -0
  26. package/dist/esm/src/data/init-models.d.ts +1 -35
  27. package/dist/esm/src/data/models/coach.js +2 -2
  28. package/dist/esm/src/data/models/player-team.d.ts +1 -2
  29. package/dist/esm/src/data/models/rally.js +1 -1
  30. package/dist/esm/src/data/transformers/coach.js +2 -2
  31. package/dist/esm/src/data/transformers/draft.js +3 -2
  32. package/dist/esm/src/data/transformers/league.js +6 -4
  33. package/dist/esm/src/data/transformers/match-set-stats.js +1 -1
  34. package/dist/esm/src/data/transformers/match-set.js +20 -11
  35. package/dist/esm/src/data/transformers/match.js +7 -5
  36. package/dist/esm/src/data/transformers/player.js +6 -4
  37. package/dist/esm/src/data/transformers/rally.js +21 -2
  38. package/dist/esm/src/data/transformers/season.js +41 -30
  39. package/dist/esm/src/data/transformers/team.js +3 -3
  40. package/dist/esm/src/data/transformers/tournament.js +6 -4
  41. package/dist/esm/src/data/transformers/trait.js +5 -1
  42. package/dist/esm/src/service/coach/coach.d.ts +2 -2
  43. package/dist/esm/src/service/event/block.d.ts +1 -1
  44. package/dist/esm/src/service/event/libero-replacement.d.ts +1 -1
  45. package/dist/esm/src/service/event/reception.d.ts +1 -1
  46. package/dist/esm/src/service/event/serve.d.ts +1 -1
  47. package/dist/esm/src/service/event/set.d.ts +1 -1
  48. package/dist/esm/src/service/event/spike.d.ts +1 -1
  49. package/dist/esm/src/service/event/substitution.d.ts +1 -1
  50. package/dist/esm/src/service/team/team.js +3 -0
  51. package/package.json +3 -3
@@ -1,36 +1,2 @@
1
1
  import type { Sequelize } from 'sequelize';
2
- import { CoachModel, CompetitionChampionModel, CompetitionMatchModel, CompetitionModel, CompetitionTeamsModel, CountryModel, DraftModel, DraftPickModel, IterationModel, LeagueModel, LeagueSeasonModel, MatchModel, MatchRatingModel, MatchSetModel, MatchSetStatsModel, PerformanceStatsModel, PlayerModel, PlayerTeamModel, PlayerTraitModel, RallyModel, SetPositionModel, TeamModel, TraitModel, UserModel } from './models';
3
- export declare function initModels(sequelize: Sequelize): {
4
- Coach: typeof CoachModel;
5
- Competition: typeof CompetitionModel;
6
- CompetitionChampion: typeof CompetitionChampionModel;
7
- CompetitionMatch: typeof CompetitionMatchModel;
8
- CompetitionTeams: typeof CompetitionTeamsModel;
9
- Country: typeof CountryModel;
10
- Draft: typeof DraftModel;
11
- DraftPick: typeof DraftPickModel;
12
- Event: {
13
- new (type: string, eventInitDict?: EventInit | undefined): Event;
14
- prototype: Event;
15
- readonly AT_TARGET: number;
16
- readonly BUBBLING_PHASE: number;
17
- readonly CAPTURING_PHASE: number;
18
- readonly NONE: number;
19
- };
20
- Iteration: typeof IterationModel;
21
- League: typeof LeagueModel;
22
- LeagueSeason: typeof LeagueSeasonModel;
23
- Match: typeof MatchModel;
24
- MatchRating: typeof MatchRatingModel;
25
- MatchSet: typeof MatchSetModel;
26
- MatchSetStats: typeof MatchSetStatsModel;
27
- PerformanceStats: typeof PerformanceStatsModel;
28
- Player: typeof PlayerModel;
29
- PlayerTeam: typeof PlayerTeamModel;
30
- PlayerTrait: typeof PlayerTraitModel;
31
- Rally: typeof RallyModel;
32
- SetPosition: typeof SetPositionModel;
33
- Team: typeof TeamModel;
34
- Trait: typeof TraitModel;
35
- User: typeof UserModel;
36
- };
2
+ export declare function initModels(sequelize: Sequelize): any;
@@ -45,9 +45,9 @@ class CoachModel extends sequelize_1.Model {
45
45
  name: 'Coach_pk',
46
46
  unique: true,
47
47
  fields: [
48
- { name: 'coach_id' },
48
+ { name: 'coach_id' }
49
49
  ]
50
- },
50
+ }
51
51
  ]
52
52
  });
53
53
  }
@@ -1,7 +1,6 @@
1
1
  import * as Sequelize from 'sequelize';
2
2
  import { Model, Optional } from 'sequelize';
3
- import { PlayerId, PlayerModel } from '.';
4
- import { TeamId, TeamModel } from '.';
3
+ import { PlayerId, PlayerModel, TeamId, TeamModel } from '.';
5
4
  export interface PlayerTeamAttributes {
6
5
  player_id: string;
7
6
  team_id: string;
@@ -33,7 +33,7 @@ class RallyModel extends sequelize_1.Model {
33
33
  events: {
34
34
  type: sequelize_1.DataTypes.STRING,
35
35
  allowNull: false
36
- },
36
+ }
37
37
  }, {
38
38
  sequelize,
39
39
  tableName: 'Rally',
@@ -9,7 +9,7 @@ function transformToAttributes(coach) {
9
9
  country_id: coach.country.id,
10
10
  first_name: coach.name.first,
11
11
  last_name: coach.name.last,
12
- substitution_tolerance: coach.substitutionTolerance,
12
+ substitution_tolerance: coach.substitutionTolerance != null ? coach.substitutionTolerance : 0,
13
13
  formation: (0, _1.transformFromFormation)(coach.formation)
14
14
  };
15
15
  }
@@ -22,7 +22,7 @@ function transformToObject(model) {
22
22
  last: model.last_name
23
23
  },
24
24
  country: (0, _1.transformToCountry)(model.country),
25
- substitutionTolerance: model.substitution_tolerance != null ? model.substitution_tolerance : undefined,
25
+ substitutionTolerance: model.substitution_tolerance,
26
26
  formation: (0, _1.transformToFormation)(model.formation)
27
27
  });
28
28
  }
@@ -13,8 +13,9 @@ function transformToAttributes(draft) {
13
13
  }
14
14
  exports.transformFromDraft = transformToAttributes;
15
15
  function transformToObject(model) {
16
- const picks = model.DraftPicks != null ?
17
- model.DraftPicks.map(draft_pick_1.transformToDraftPick) : [];
16
+ const picks = model.DraftPicks != null
17
+ ? model.DraftPicks.map(draft_pick_1.transformToDraftPick)
18
+ : [];
18
19
  return new service_1.Draft({
19
20
  id: model.draft_id,
20
21
  start: new Date(model.start_date),
@@ -4,10 +4,12 @@ exports.transformFromLeague = exports.transformToAPILeague = exports.transformTo
4
4
  const service_1 = require("../../service");
5
5
  const _1 = require(".");
6
6
  function transformToAttributes(league) {
7
- const LeagueSeasons = league.seasons != null ? league.seasons.map(season => ({
8
- league_id: league.id,
9
- competition_id: season.id
10
- })) : undefined;
7
+ const LeagueSeasons = league.seasons != null
8
+ ? league.seasons.map(season => ({
9
+ league_id: league.id,
10
+ competition_id: season.id
11
+ }))
12
+ : undefined;
11
13
  return {
12
14
  league_id: league.id,
13
15
  country_id: league.country.id,
@@ -89,7 +89,7 @@ function transformToAPIObject(model, order) {
89
89
  ralliesPlayed: model.rallies_played,
90
90
  attempts: model.attempts,
91
91
  playerId: model.player_id,
92
- order: order
92
+ order
93
93
  };
94
94
  }
95
95
  exports.transformToAPIMatchSetStats = transformToAPIObject;
@@ -20,10 +20,14 @@ function transformToAttributes(set, matchId) {
20
20
  }
21
21
  exports.transformFromMatchSet = transformToAttributes;
22
22
  function transformToObject(model) {
23
- const homePlayerPosition = model.SetPositions != null ? model.SetPositions.filter(p => p.side === 'Home')
24
- .map(_1.transformToPlayerPosition) : [];
25
- const awayPlayerPosition = model.SetPositions != null ? model.SetPositions.filter(p => p.side === 'Away')
26
- .map(_1.transformToPlayerPosition) : [];
23
+ const homePlayerPosition = model.SetPositions != null
24
+ ? model.SetPositions.filter(p => p.side === 'Home')
25
+ .map(_1.transformToPlayerPosition)
26
+ : [];
27
+ const awayPlayerPosition = model.SetPositions != null
28
+ ? model.SetPositions.filter(p => p.side === 'Away')
29
+ .map(_1.transformToPlayerPosition)
30
+ : [];
27
31
  const stats = model.MatchSetStats != null ? model.MatchSetStats.map(_1.transformToMatchSetStats) : [];
28
32
  const rallies = model.Rallies != null ? model.Rallies.map(_1.transformToRally) : [];
29
33
  rallies.sort((r1, r2) => r1.order - r2.order);
@@ -43,19 +47,24 @@ exports.transformToMatchSet = transformToObject;
43
47
  function transformToAPIObject(model) {
44
48
  const rallies = model.Rallies != null ? model.Rallies.map(_1.transformToAPIRally) : [];
45
49
  rallies.sort((r1, r2) => r1.order - r2.order);
46
- const homePlayerPosition = model.SetPositions != null ? model.SetPositions.filter(p => p.side === 'Home')
47
- .map(_1.transformToPlayerPosition) : [];
48
- const awayPlayerPosition = model.SetPositions != null ? model.SetPositions.filter(p => p.side === 'Away')
49
- .map(_1.transformToPlayerPosition) : [];
50
- const stats = model.MatchSetStats != null ?
51
- model.MatchSetStats.map(stats => (0, _1.transformToAPIMatchSetStats)(stats, model.order)) : [];
50
+ const homePlayerPosition = model.SetPositions != null
51
+ ? model.SetPositions.filter(p => p.side === 'Home')
52
+ .map(_1.transformToPlayerPosition)
53
+ : [];
54
+ const awayPlayerPosition = model.SetPositions != null
55
+ ? model.SetPositions.filter(p => p.side === 'Away')
56
+ .map(_1.transformToPlayerPosition)
57
+ : [];
58
+ const stats = model.MatchSetStats != null
59
+ ? model.MatchSetStats.map(stats => (0, _1.transformToAPIMatchSetStats)(stats, model.order))
60
+ : [];
52
61
  return {
53
62
  id: model.match_id,
54
63
  order: model.order,
55
64
  homeScore: model.home_score,
56
65
  awayScore: model.away_score,
57
66
  isTieBreak: model.is_tie_break,
58
- rallies: rallies,
67
+ rallies,
59
68
  homePlayerPosition,
60
69
  awayPlayerPosition,
61
70
  stats
@@ -15,22 +15,24 @@ function transformToAttributes(match) {
15
15
  exports.transformFromMatch = transformToAttributes;
16
16
  function transformToObject(model) {
17
17
  const sets = model.MatchSets == null || model.MatchSets.length < 1
18
- ? [] : model.MatchSets.map(_1.transformToMatchSet)
19
- .sort((s1, s2) => s1.order - s2.order);
18
+ ? []
19
+ : model.MatchSets.map(_1.transformToMatchSet)
20
+ .sort((s1, s2) => s1.order - s2.order);
20
21
  return new service_1.Match({
21
22
  id: model.match_id,
22
23
  homeTeam: (0, _1.transformToTeam)(model.HomeTeam),
23
24
  awayTeam: (0, _1.transformToTeam)(model.AwayTeam),
24
25
  scheduledDate: new Date(model.scheduled_date),
25
- sets: sets,
26
+ sets,
26
27
  isSimulated: model.is_simulated
27
28
  });
28
29
  }
29
30
  exports.transformToMatch = transformToObject;
30
31
  function transformToAPIObject(match, competition) {
31
32
  const sets = match.MatchSets == null || match.MatchSets.length < 1
32
- ? [] : match.MatchSets.map(_1.transformToAPIMatchSet)
33
- .sort((s1, s2) => s1.order - s2.order);
33
+ ? []
34
+ : match.MatchSets.map(_1.transformToAPIMatchSet)
35
+ .sort((s1, s2) => s1.order - s2.order);
34
36
  return {
35
37
  id: match.match_id,
36
38
  homeTeam: (0, _1.transformToAPITeam)(match.HomeTeam),
@@ -29,10 +29,12 @@ function transformToObject(model) {
29
29
  }
30
30
  exports.transformToPlayer = transformToObject;
31
31
  function transformToAPIObject(model, team, jerseyNumber) {
32
- const generalStats = model.PerformanceStat != null ? service_1.GeneralStat.getStats().map(stat => ({
33
- name: stat,
34
- value: service_1.GeneralStat.calculateScore((0, _1.transformToPerformanceStats)(model.PerformanceStat), stat)
35
- })) : [];
32
+ const generalStats = model.PerformanceStat != null
33
+ ? service_1.GeneralStat.getStats().map(stat => ({
34
+ name: stat,
35
+ value: service_1.GeneralStat.calculateScore((0, _1.transformToPerformanceStats)(model.PerformanceStat), stat)
36
+ }))
37
+ : [];
36
38
  const gameStats = model.MatchSetStats != null ? model.MatchSetStats.map(_1.transformToAPIMatchSetStats) : [];
37
39
  if (gameStats.length > 0) {
38
40
  gameStats.push(calculateMatchStats(gameStats));
@@ -5,7 +5,26 @@ const service_1 = require("../../service");
5
5
  const _1 = require(".");
6
6
  const lz_string_1 = require("lz-string");
7
7
  function transformToAttributes(rally, setId) {
8
- const events = `[${rally.events.map(e => e.toString()).join(',')}]`;
8
+ const events = `[${rally.events.map(e => {
9
+ switch (e.eventType) {
10
+ case service_1.EventTypeEnum.BLOCK:
11
+ return e.toString();
12
+ case service_1.EventTypeEnum.LIBERO_REPLACEMENT:
13
+ return e.toString();
14
+ case service_1.EventTypeEnum.SET:
15
+ return e.toString();
16
+ case service_1.EventTypeEnum.SERVE:
17
+ return e.toString();
18
+ case service_1.EventTypeEnum.SPIKE:
19
+ return e.toString();
20
+ case service_1.EventTypeEnum.RECEPTION:
21
+ return e.toString();
22
+ case service_1.EventTypeEnum.SUBSTITUTION:
23
+ return e.toString();
24
+ default:
25
+ throw new Error('UNKNOWN_EVENT_TYPE');
26
+ }
27
+ }).join(',')}]`;
9
28
  return {
10
29
  rally_id: rally.id,
11
30
  match_set_id: setId,
@@ -4,16 +4,19 @@ exports.transformFromSeason = exports.transformToAPISeason = exports.transformTo
4
4
  const _1 = require(".");
5
5
  const service_1 = require("../../service");
6
6
  function transformToAttributes(season, leagueId) {
7
- const matches = season.matches != null ?
8
- season.matches.map((match, index) => (0, _1.transformFromSeasonMatch)(season.id, match, index)) : [];
7
+ const matches = season.matches != null
8
+ ? season.matches.map((match, index) => (0, _1.transformFromSeasonMatch)(season.id, match, index))
9
+ : [];
9
10
  const teams = season.teams.map(team => ({
10
11
  competition_id: season.id,
11
12
  team_id: team.id
12
13
  }));
13
- const champion = season.champion != null ? {
14
- competition_id: season.id,
15
- team_id: season.champion?.id
16
- } : undefined;
14
+ const champion = season.champion != null
15
+ ? {
16
+ competition_id: season.id,
17
+ team_id: season.champion?.id
18
+ }
19
+ : undefined;
17
20
  return {
18
21
  competition_id: season.id,
19
22
  type: 'LEAGUE',
@@ -26,8 +29,9 @@ function transformToAttributes(season, leagueId) {
26
29
  }
27
30
  exports.transformFromSeason = transformToAttributes;
28
31
  function transformToObject(model) {
29
- const matches = model.CompetitionMatches != null ?
30
- model.CompetitionMatches.map(matches => (0, _1.transformToMatch)(matches.Match)) : [];
32
+ const matches = model.CompetitionMatches != null
33
+ ? model.CompetitionMatches.map(matches => (0, _1.transformToMatch)(matches.Match))
34
+ : [];
31
35
  return new service_1.Season({
32
36
  id: model.competition_id,
33
37
  matches,
@@ -39,31 +43,38 @@ function transformToObject(model) {
39
43
  exports.transformToSeason = transformToObject;
40
44
  function transformToAPIObject(model) {
41
45
  const season = transformToObject(model);
42
- const matches = model.CompetitionMatches != null ?
43
- model.CompetitionMatches.map(matches => (0, _1.transformToAPIMatch)(matches.Match)) : [];
46
+ const matches = model.CompetitionMatches != null
47
+ ? model.CompetitionMatches.map(matches => (0, _1.transformToAPIMatch)(matches.Match))
48
+ : [];
44
49
  const teams = model.Teams != null ? model.Teams.map(_1.transformToAPITeam) : [];
45
- const standings = season.standings.map(standing => ({
46
- team: teams.find(t => standing.team.id === t.id),
47
- lost03: standing.lost03,
48
- lost13: standing.lost13,
49
- lost23: standing.lost23,
50
- matchesLost: standing.matchesLost,
51
- matchesWon: standing.matchesWon,
52
- points: standing.points,
53
- pointsLost: standing.pointsLost,
54
- pointsRatio: standing.pointsRatio,
55
- pointsWon: standing.pointsWon,
56
- setsLost: standing.setsLost,
57
- setsRatio: standing.setsRatio,
58
- setsWon: standing.setsWon,
59
- won30: standing.won30,
60
- won31: standing.won31,
61
- won32: standing.won32,
62
- totalMatches: standing.totalMatches
63
- }));
50
+ const standings = season.standings.map(standing => {
51
+ const team = teams.find(t => standing.team.id === t.id);
52
+ if (team == null) {
53
+ throw new Error('TEAM_NOT_FOUND');
54
+ }
55
+ return {
56
+ team,
57
+ lost03: standing.lost03,
58
+ lost13: standing.lost13,
59
+ lost23: standing.lost23,
60
+ matchesLost: standing.matchesLost,
61
+ matchesWon: standing.matchesWon,
62
+ points: standing.points,
63
+ pointsLost: standing.pointsLost,
64
+ pointsRatio: standing.pointsRatio,
65
+ pointsWon: standing.pointsWon,
66
+ setsLost: standing.setsLost,
67
+ setsRatio: standing.setsRatio,
68
+ setsWon: standing.setsWon,
69
+ won30: standing.won30,
70
+ won31: standing.won31,
71
+ won32: standing.won32,
72
+ totalMatches: standing.totalMatches
73
+ };
74
+ });
64
75
  return {
65
76
  id: model.competition_id,
66
- matches: matches,
77
+ matches,
67
78
  iteration: model.iteration,
68
79
  league: model.LeagueSeason?.league != null ? (0, _1.transformToAPILeague)(model.LeagueSeason.league) : undefined,
69
80
  champion: model.CompetitionChampion != null ? (0, _1.transformToAPITeam)(model.CompetitionChampion.team) : undefined,
@@ -8,9 +8,9 @@ function transformToAttributes(team) {
8
8
  team_id: team.id,
9
9
  name: team.name,
10
10
  short_name: team.shortName,
11
- coach_id: team.coach?.id,
12
- country_id: team.country?.id,
13
- league_id: team.league?.id,
11
+ coach_id: team.coach != null ? team.coach.id : undefined,
12
+ country_id: team.country != null ? team.country.id : undefined,
13
+ league_id: team.league != null ? team.league.id : undefined,
14
14
  coach: team.coach != null ? (0, _1.transformFromCoach)(team.coach) : undefined,
15
15
  rating: team.rating
16
16
  };
@@ -9,10 +9,12 @@ function transformToAttributes(tournament) {
9
9
  competition_id: tournament.id,
10
10
  team_id: team.id
11
11
  }));
12
- const champion = tournament.champion != null ? {
13
- competition_id: tournament.id,
14
- team_id: tournament.champion?.id
15
- } : undefined;
12
+ const champion = tournament.champion != null
13
+ ? {
14
+ competition_id: tournament.id,
15
+ team_id: tournament.champion?.id
16
+ }
17
+ : undefined;
16
18
  return {
17
19
  competition_id: tournament.id,
18
20
  type: 'TOURNAMENT',
@@ -32,6 +32,10 @@ function transformToAPIObject(model) {
32
32
  }
33
33
  exports.transformToAPITrait = transformToAPIObject;
34
34
  function transformToObject(model) {
35
- return service_1.Trait.getTraits().find(trait => trait.id === model.trait_id);
35
+ const trait = service_1.Trait.getTraits().find(trait => trait.id === model.trait_id);
36
+ if (trait == null) {
37
+ throw new Error('TRAIT_NOT_FOUND');
38
+ }
39
+ return trait;
36
40
  }
37
41
  exports.transformToTrait = transformToObject;
@@ -6,14 +6,14 @@ interface CoachOpts {
6
6
  readonly name: Name;
7
7
  readonly country: Country;
8
8
  readonly formation: Formation;
9
- readonly substitutionTolerance?: number;
9
+ readonly substitutionTolerance: number;
10
10
  }
11
11
  export declare class Coach {
12
12
  readonly id: string;
13
13
  readonly name: Name;
14
14
  readonly country: Country;
15
15
  readonly formation: Formation;
16
- readonly substitutionTolerance?: number;
16
+ readonly substitutionTolerance: number;
17
17
  constructor({ id, name, country, formation, substitutionTolerance }: CoachOpts);
18
18
  }
19
19
  export {};
@@ -25,6 +25,6 @@ export declare class Block extends InPlayEvent {
25
25
  readonly blockers: string[];
26
26
  constructor({ order, score, player, target, failure, type, modifier, eventType, blockers, activeTraits }: BlockOpts);
27
27
  static getScore(blockers: Player[], modifier: number, activeTraits: Trait[]): number;
28
- protected toString(): string;
28
+ toString(): string;
29
29
  }
30
30
  export {};
@@ -13,6 +13,6 @@ export declare class LiberoReplacement extends RallyEvent {
13
13
  readonly type: LiberoReplacementTypeEnum;
14
14
  readonly libero: string;
15
15
  constructor({ order, player, type, libero, eventType }: LiberoReplacementOpts);
16
- protected toString(): string;
16
+ toString(): string;
17
17
  }
18
18
  export {};
@@ -22,6 +22,6 @@ export declare class Reception extends InPlayEvent {
22
22
  readonly type: ReceptionTypeEnum;
23
23
  constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: ReceptionOpts);
24
24
  static getScore(stats: PerformanceStats, type: ReceptionTypeEnum, modifier: number, activeTraits: Trait[]): number;
25
- protected toString(): string;
25
+ toString(): string;
26
26
  }
27
27
  export {};
@@ -23,6 +23,6 @@ export declare class Serve extends InPlayEvent {
23
23
  readonly type: ServeTypeEnum;
24
24
  constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: ServeOpts);
25
25
  static getScore(stats: PerformanceStats, type: ServeTypeEnum, modifier: number, activeTraits: Trait[]): number;
26
- protected toString(): string;
26
+ toString(): string;
27
27
  }
28
28
  export {};
@@ -22,6 +22,6 @@ export declare class Set extends InPlayEvent {
22
22
  readonly type: SetTypeEnum;
23
23
  constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: SetOpts);
24
24
  static getScore(stats: PerformanceStats, type: SetTypeEnum, modifier: number, activeTraits: Trait[]): number;
25
- protected toString(): string;
25
+ toString(): string;
26
26
  }
27
27
  export {};
@@ -24,6 +24,6 @@ export declare class Spike extends InPlayEvent {
24
24
  readonly type: SpikeTypeEnum;
25
25
  constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: SpikeOpts);
26
26
  static getScore(player: Player, type: SpikeTypeEnum, modifier: number, isBackRow: boolean, activeTraits: Trait[]): number;
27
- protected toString(): string;
27
+ toString(): string;
28
28
  }
29
29
  export {};
@@ -6,6 +6,6 @@ interface SubstitutionOpts extends RallyEventOpts {
6
6
  export declare class Substitution extends RallyEvent {
7
7
  readonly playerOut: string;
8
8
  constructor({ order, playerOut, player, eventType }: SubstitutionOpts);
9
- protected toString(): string;
9
+ toString(): string;
10
10
  }
11
11
  export {};
@@ -25,6 +25,9 @@ class Team {
25
25
  return this.roster.some(p => p.id === player.id);
26
26
  }
27
27
  toString() {
28
+ if (this.country == null) {
29
+ throw new Error('UNKNOWN_COUNTRY');
30
+ }
28
31
  return `${this.name} [${this.shortName}] (${this.country?.name}) ELO=${this._rating}`;
29
32
  }
30
33
  updateRating(ratingChange) {
@@ -1,36 +1,2 @@
1
1
  import type { Sequelize } from 'sequelize';
2
- import { CoachModel, CompetitionChampionModel, CompetitionMatchModel, CompetitionModel, CompetitionTeamsModel, CountryModel, DraftModel, DraftPickModel, IterationModel, LeagueModel, LeagueSeasonModel, MatchModel, MatchRatingModel, MatchSetModel, MatchSetStatsModel, PerformanceStatsModel, PlayerModel, PlayerTeamModel, PlayerTraitModel, RallyModel, SetPositionModel, TeamModel, TraitModel, UserModel } from './models';
3
- export declare function initModels(sequelize: Sequelize): {
4
- Coach: typeof CoachModel;
5
- Competition: typeof CompetitionModel;
6
- CompetitionChampion: typeof CompetitionChampionModel;
7
- CompetitionMatch: typeof CompetitionMatchModel;
8
- CompetitionTeams: typeof CompetitionTeamsModel;
9
- Country: typeof CountryModel;
10
- Draft: typeof DraftModel;
11
- DraftPick: typeof DraftPickModel;
12
- Event: {
13
- new (type: string, eventInitDict?: EventInit | undefined): Event;
14
- prototype: Event;
15
- readonly AT_TARGET: number;
16
- readonly BUBBLING_PHASE: number;
17
- readonly CAPTURING_PHASE: number;
18
- readonly NONE: number;
19
- };
20
- Iteration: typeof IterationModel;
21
- League: typeof LeagueModel;
22
- LeagueSeason: typeof LeagueSeasonModel;
23
- Match: typeof MatchModel;
24
- MatchRating: typeof MatchRatingModel;
25
- MatchSet: typeof MatchSetModel;
26
- MatchSetStats: typeof MatchSetStatsModel;
27
- PerformanceStats: typeof PerformanceStatsModel;
28
- Player: typeof PlayerModel;
29
- PlayerTeam: typeof PlayerTeamModel;
30
- PlayerTrait: typeof PlayerTraitModel;
31
- Rally: typeof RallyModel;
32
- SetPosition: typeof SetPositionModel;
33
- Team: typeof TeamModel;
34
- Trait: typeof TraitModel;
35
- User: typeof UserModel;
36
- };
2
+ export declare function initModels(sequelize: Sequelize): any;
@@ -42,9 +42,9 @@ export class CoachModel extends Model {
42
42
  name: 'Coach_pk',
43
43
  unique: true,
44
44
  fields: [
45
- { name: 'coach_id' },
45
+ { name: 'coach_id' }
46
46
  ]
47
- },
47
+ }
48
48
  ]
49
49
  });
50
50
  }
@@ -1,7 +1,6 @@
1
1
  import * as Sequelize from 'sequelize';
2
2
  import { Model, Optional } from 'sequelize';
3
- import { PlayerId, PlayerModel } from '.';
4
- import { TeamId, TeamModel } from '.';
3
+ import { PlayerId, PlayerModel, TeamId, TeamModel } from '.';
5
4
  export interface PlayerTeamAttributes {
6
5
  player_id: string;
7
6
  team_id: string;
@@ -30,7 +30,7 @@ export class RallyModel extends Model {
30
30
  events: {
31
31
  type: DataTypes.STRING,
32
32
  allowNull: false
33
- },
33
+ }
34
34
  }, {
35
35
  sequelize,
36
36
  tableName: 'Rally',
@@ -6,7 +6,7 @@ function transformToAttributes(coach) {
6
6
  country_id: coach.country.id,
7
7
  first_name: coach.name.first,
8
8
  last_name: coach.name.last,
9
- substitution_tolerance: coach.substitutionTolerance,
9
+ substitution_tolerance: coach.substitutionTolerance != null ? coach.substitutionTolerance : 0,
10
10
  formation: transformFromFormation(coach.formation)
11
11
  };
12
12
  }
@@ -18,7 +18,7 @@ function transformToObject(model) {
18
18
  last: model.last_name
19
19
  },
20
20
  country: transformToCountry(model.country),
21
- substitutionTolerance: model.substitution_tolerance != null ? model.substitution_tolerance : undefined,
21
+ substitutionTolerance: model.substitution_tolerance,
22
22
  formation: transformToFormation(model.formation)
23
23
  });
24
24
  }
@@ -9,8 +9,9 @@ function transformToAttributes(draft) {
9
9
  };
10
10
  }
11
11
  function transformToObject(model) {
12
- const picks = model.DraftPicks != null ?
13
- model.DraftPicks.map(transformToDraftPick) : [];
12
+ const picks = model.DraftPicks != null
13
+ ? model.DraftPicks.map(transformToDraftPick)
14
+ : [];
14
15
  return new Draft({
15
16
  id: model.draft_id,
16
17
  start: new Date(model.start_date),
@@ -1,10 +1,12 @@
1
1
  import { League } from '../../service';
2
2
  import { transformToCountry, transformToSeason } from '.';
3
3
  function transformToAttributes(league) {
4
- const LeagueSeasons = league.seasons != null ? league.seasons.map(season => ({
5
- league_id: league.id,
6
- competition_id: season.id
7
- })) : undefined;
4
+ const LeagueSeasons = league.seasons != null
5
+ ? league.seasons.map(season => ({
6
+ league_id: league.id,
7
+ competition_id: season.id
8
+ }))
9
+ : undefined;
8
10
  return {
9
11
  league_id: league.id,
10
12
  country_id: league.country.id,
@@ -84,7 +84,7 @@ function transformToAPIObject(model, order) {
84
84
  ralliesPlayed: model.rallies_played,
85
85
  attempts: model.attempts,
86
86
  playerId: model.player_id,
87
- order: order
87
+ order
88
88
  };
89
89
  }
90
90
  export { transformToObject as transformToMatchSetStats, transformToAPIObject as transformToAPIMatchSetStats, transformToAttributes as transformFromMatchSetStats };
@@ -16,10 +16,14 @@ function transformToAttributes(set, matchId) {
16
16
  };
17
17
  }
18
18
  function transformToObject(model) {
19
- const homePlayerPosition = model.SetPositions != null ? model.SetPositions.filter(p => p.side === 'Home')
20
- .map(transformToPlayerPosition) : [];
21
- const awayPlayerPosition = model.SetPositions != null ? model.SetPositions.filter(p => p.side === 'Away')
22
- .map(transformToPlayerPosition) : [];
19
+ const homePlayerPosition = model.SetPositions != null
20
+ ? model.SetPositions.filter(p => p.side === 'Home')
21
+ .map(transformToPlayerPosition)
22
+ : [];
23
+ const awayPlayerPosition = model.SetPositions != null
24
+ ? model.SetPositions.filter(p => p.side === 'Away')
25
+ .map(transformToPlayerPosition)
26
+ : [];
23
27
  const stats = model.MatchSetStats != null ? model.MatchSetStats.map(transformToMatchSetStats) : [];
24
28
  const rallies = model.Rallies != null ? model.Rallies.map(transformToRally) : [];
25
29
  rallies.sort((r1, r2) => r1.order - r2.order);
@@ -38,19 +42,24 @@ function transformToObject(model) {
38
42
  function transformToAPIObject(model) {
39
43
  const rallies = model.Rallies != null ? model.Rallies.map(transformToAPIRally) : [];
40
44
  rallies.sort((r1, r2) => r1.order - r2.order);
41
- const homePlayerPosition = model.SetPositions != null ? model.SetPositions.filter(p => p.side === 'Home')
42
- .map(transformToPlayerPosition) : [];
43
- const awayPlayerPosition = model.SetPositions != null ? model.SetPositions.filter(p => p.side === 'Away')
44
- .map(transformToPlayerPosition) : [];
45
- const stats = model.MatchSetStats != null ?
46
- model.MatchSetStats.map(stats => transformToAPIMatchSetStats(stats, model.order)) : [];
45
+ const homePlayerPosition = model.SetPositions != null
46
+ ? model.SetPositions.filter(p => p.side === 'Home')
47
+ .map(transformToPlayerPosition)
48
+ : [];
49
+ const awayPlayerPosition = model.SetPositions != null
50
+ ? model.SetPositions.filter(p => p.side === 'Away')
51
+ .map(transformToPlayerPosition)
52
+ : [];
53
+ const stats = model.MatchSetStats != null
54
+ ? model.MatchSetStats.map(stats => transformToAPIMatchSetStats(stats, model.order))
55
+ : [];
47
56
  return {
48
57
  id: model.match_id,
49
58
  order: model.order,
50
59
  homeScore: model.home_score,
51
60
  awayScore: model.away_score,
52
61
  isTieBreak: model.is_tie_break,
53
- rallies: rallies,
62
+ rallies,
54
63
  homePlayerPosition,
55
64
  awayPlayerPosition,
56
65
  stats
@@ -11,21 +11,23 @@ function transformToAttributes(match) {
11
11
  }
12
12
  function transformToObject(model) {
13
13
  const sets = model.MatchSets == null || model.MatchSets.length < 1
14
- ? [] : model.MatchSets.map(transformToMatchSet)
15
- .sort((s1, s2) => s1.order - s2.order);
14
+ ? []
15
+ : model.MatchSets.map(transformToMatchSet)
16
+ .sort((s1, s2) => s1.order - s2.order);
16
17
  return new Match({
17
18
  id: model.match_id,
18
19
  homeTeam: transformToTeam(model.HomeTeam),
19
20
  awayTeam: transformToTeam(model.AwayTeam),
20
21
  scheduledDate: new Date(model.scheduled_date),
21
- sets: sets,
22
+ sets,
22
23
  isSimulated: model.is_simulated
23
24
  });
24
25
  }
25
26
  function transformToAPIObject(match, competition) {
26
27
  const sets = match.MatchSets == null || match.MatchSets.length < 1
27
- ? [] : match.MatchSets.map(transformToAPIMatchSet)
28
- .sort((s1, s2) => s1.order - s2.order);
28
+ ? []
29
+ : match.MatchSets.map(transformToAPIMatchSet)
30
+ .sort((s1, s2) => s1.order - s2.order);
29
31
  return {
30
32
  id: match.match_id,
31
33
  homeTeam: transformToAPITeam(match.HomeTeam),
@@ -24,10 +24,12 @@ function transformToObject(model) {
24
24
  });
25
25
  }
26
26
  function transformToAPIObject(model, team, jerseyNumber) {
27
- const generalStats = model.PerformanceStat != null ? GeneralStat.getStats().map(stat => ({
28
- name: stat,
29
- value: GeneralStat.calculateScore(transformToPerformanceStats(model.PerformanceStat), stat)
30
- })) : [];
27
+ const generalStats = model.PerformanceStat != null
28
+ ? GeneralStat.getStats().map(stat => ({
29
+ name: stat,
30
+ value: GeneralStat.calculateScore(transformToPerformanceStats(model.PerformanceStat), stat)
31
+ }))
32
+ : [];
31
33
  const gameStats = model.MatchSetStats != null ? model.MatchSetStats.map(transformToAPIMatchSetStats) : [];
32
34
  if (gameStats.length > 0) {
33
35
  gameStats.push(calculateMatchStats(gameStats));
@@ -1,8 +1,27 @@
1
- import { Rally } from '../../service';
1
+ import { EventTypeEnum, Rally } from '../../service';
2
2
  import { transformToAPIBlock, transformToAPILiberoReplacement, transformToAPIReception, transformToAPIServe, transformToAPISet, transformToAPISpike, transformToAPISubstitution, transformToTeam } from '.';
3
3
  import { compressToBase64, decompressFromBase64 } from 'lz-string';
4
4
  function transformToAttributes(rally, setId) {
5
- const events = `[${rally.events.map(e => e.toString()).join(',')}]`;
5
+ const events = `[${rally.events.map(e => {
6
+ switch (e.eventType) {
7
+ case EventTypeEnum.BLOCK:
8
+ return e.toString();
9
+ case EventTypeEnum.LIBERO_REPLACEMENT:
10
+ return e.toString();
11
+ case EventTypeEnum.SET:
12
+ return e.toString();
13
+ case EventTypeEnum.SERVE:
14
+ return e.toString();
15
+ case EventTypeEnum.SPIKE:
16
+ return e.toString();
17
+ case EventTypeEnum.RECEPTION:
18
+ return e.toString();
19
+ case EventTypeEnum.SUBSTITUTION:
20
+ return e.toString();
21
+ default:
22
+ throw new Error('UNKNOWN_EVENT_TYPE');
23
+ }
24
+ }).join(',')}]`;
6
25
  return {
7
26
  rally_id: rally.id,
8
27
  match_set_id: setId,
@@ -1,16 +1,19 @@
1
1
  import { transformFromSeasonMatch, transformToAPILeague, transformToAPIMatch, transformToAPITeam, transformToIteration, transformToMatch, transformToTeam } from '.';
2
2
  import { Season } from '../../service';
3
3
  function transformToAttributes(season, leagueId) {
4
- const matches = season.matches != null ?
5
- season.matches.map((match, index) => transformFromSeasonMatch(season.id, match, index)) : [];
4
+ const matches = season.matches != null
5
+ ? season.matches.map((match, index) => transformFromSeasonMatch(season.id, match, index))
6
+ : [];
6
7
  const teams = season.teams.map(team => ({
7
8
  competition_id: season.id,
8
9
  team_id: team.id
9
10
  }));
10
- const champion = season.champion != null ? {
11
- competition_id: season.id,
12
- team_id: season.champion?.id
13
- } : undefined;
11
+ const champion = season.champion != null
12
+ ? {
13
+ competition_id: season.id,
14
+ team_id: season.champion?.id
15
+ }
16
+ : undefined;
14
17
  return {
15
18
  competition_id: season.id,
16
19
  type: 'LEAGUE',
@@ -22,8 +25,9 @@ function transformToAttributes(season, leagueId) {
22
25
  };
23
26
  }
24
27
  function transformToObject(model) {
25
- const matches = model.CompetitionMatches != null ?
26
- model.CompetitionMatches.map(matches => transformToMatch(matches.Match)) : [];
28
+ const matches = model.CompetitionMatches != null
29
+ ? model.CompetitionMatches.map(matches => transformToMatch(matches.Match))
30
+ : [];
27
31
  return new Season({
28
32
  id: model.competition_id,
29
33
  matches,
@@ -34,31 +38,38 @@ function transformToObject(model) {
34
38
  }
35
39
  function transformToAPIObject(model) {
36
40
  const season = transformToObject(model);
37
- const matches = model.CompetitionMatches != null ?
38
- model.CompetitionMatches.map(matches => transformToAPIMatch(matches.Match)) : [];
41
+ const matches = model.CompetitionMatches != null
42
+ ? model.CompetitionMatches.map(matches => transformToAPIMatch(matches.Match))
43
+ : [];
39
44
  const teams = model.Teams != null ? model.Teams.map(transformToAPITeam) : [];
40
- const standings = season.standings.map(standing => ({
41
- team: teams.find(t => standing.team.id === t.id),
42
- lost03: standing.lost03,
43
- lost13: standing.lost13,
44
- lost23: standing.lost23,
45
- matchesLost: standing.matchesLost,
46
- matchesWon: standing.matchesWon,
47
- points: standing.points,
48
- pointsLost: standing.pointsLost,
49
- pointsRatio: standing.pointsRatio,
50
- pointsWon: standing.pointsWon,
51
- setsLost: standing.setsLost,
52
- setsRatio: standing.setsRatio,
53
- setsWon: standing.setsWon,
54
- won30: standing.won30,
55
- won31: standing.won31,
56
- won32: standing.won32,
57
- totalMatches: standing.totalMatches
58
- }));
45
+ const standings = season.standings.map(standing => {
46
+ const team = teams.find(t => standing.team.id === t.id);
47
+ if (team == null) {
48
+ throw new Error('TEAM_NOT_FOUND');
49
+ }
50
+ return {
51
+ team,
52
+ lost03: standing.lost03,
53
+ lost13: standing.lost13,
54
+ lost23: standing.lost23,
55
+ matchesLost: standing.matchesLost,
56
+ matchesWon: standing.matchesWon,
57
+ points: standing.points,
58
+ pointsLost: standing.pointsLost,
59
+ pointsRatio: standing.pointsRatio,
60
+ pointsWon: standing.pointsWon,
61
+ setsLost: standing.setsLost,
62
+ setsRatio: standing.setsRatio,
63
+ setsWon: standing.setsWon,
64
+ won30: standing.won30,
65
+ won31: standing.won31,
66
+ won32: standing.won32,
67
+ totalMatches: standing.totalMatches
68
+ };
69
+ });
59
70
  return {
60
71
  id: model.competition_id,
61
- matches: matches,
72
+ matches,
62
73
  iteration: model.iteration,
63
74
  league: model.LeagueSeason?.league != null ? transformToAPILeague(model.LeagueSeason.league) : undefined,
64
75
  champion: model.CompetitionChampion != null ? transformToAPITeam(model.CompetitionChampion.team) : undefined,
@@ -5,9 +5,9 @@ function transformToAttributes(team) {
5
5
  team_id: team.id,
6
6
  name: team.name,
7
7
  short_name: team.shortName,
8
- coach_id: team.coach?.id,
9
- country_id: team.country?.id,
10
- league_id: team.league?.id,
8
+ coach_id: team.coach != null ? team.coach.id : undefined,
9
+ country_id: team.country != null ? team.country.id : undefined,
10
+ league_id: team.league != null ? team.league.id : undefined,
11
11
  coach: team.coach != null ? transformFromCoach(team.coach) : undefined,
12
12
  rating: team.rating
13
13
  };
@@ -6,10 +6,12 @@ function transformToAttributes(tournament) {
6
6
  competition_id: tournament.id,
7
7
  team_id: team.id
8
8
  }));
9
- const champion = tournament.champion != null ? {
10
- competition_id: tournament.id,
11
- team_id: tournament.champion?.id
12
- } : undefined;
9
+ const champion = tournament.champion != null
10
+ ? {
11
+ competition_id: tournament.id,
12
+ team_id: tournament.champion?.id
13
+ }
14
+ : undefined;
13
15
  return {
14
16
  competition_id: tournament.id,
15
17
  type: 'TOURNAMENT',
@@ -27,6 +27,10 @@ function transformToAPIObject(model) {
27
27
  }
28
28
  }
29
29
  function transformToObject(model) {
30
- return Trait.getTraits().find(trait => trait.id === model.trait_id);
30
+ const trait = Trait.getTraits().find(trait => trait.id === model.trait_id);
31
+ if (trait == null) {
32
+ throw new Error('TRAIT_NOT_FOUND');
33
+ }
34
+ return trait;
31
35
  }
32
36
  export { transformToObject as transformToTrait, transformToAPIObject as transformToAPITrait, transformToAttributes as transformFromTrait };
@@ -6,14 +6,14 @@ interface CoachOpts {
6
6
  readonly name: Name;
7
7
  readonly country: Country;
8
8
  readonly formation: Formation;
9
- readonly substitutionTolerance?: number;
9
+ readonly substitutionTolerance: number;
10
10
  }
11
11
  export declare class Coach {
12
12
  readonly id: string;
13
13
  readonly name: Name;
14
14
  readonly country: Country;
15
15
  readonly formation: Formation;
16
- readonly substitutionTolerance?: number;
16
+ readonly substitutionTolerance: number;
17
17
  constructor({ id, name, country, formation, substitutionTolerance }: CoachOpts);
18
18
  }
19
19
  export {};
@@ -25,6 +25,6 @@ export declare class Block extends InPlayEvent {
25
25
  readonly blockers: string[];
26
26
  constructor({ order, score, player, target, failure, type, modifier, eventType, blockers, activeTraits }: BlockOpts);
27
27
  static getScore(blockers: Player[], modifier: number, activeTraits: Trait[]): number;
28
- protected toString(): string;
28
+ toString(): string;
29
29
  }
30
30
  export {};
@@ -13,6 +13,6 @@ export declare class LiberoReplacement extends RallyEvent {
13
13
  readonly type: LiberoReplacementTypeEnum;
14
14
  readonly libero: string;
15
15
  constructor({ order, player, type, libero, eventType }: LiberoReplacementOpts);
16
- protected toString(): string;
16
+ toString(): string;
17
17
  }
18
18
  export {};
@@ -22,6 +22,6 @@ export declare class Reception extends InPlayEvent {
22
22
  readonly type: ReceptionTypeEnum;
23
23
  constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: ReceptionOpts);
24
24
  static getScore(stats: PerformanceStats, type: ReceptionTypeEnum, modifier: number, activeTraits: Trait[]): number;
25
- protected toString(): string;
25
+ toString(): string;
26
26
  }
27
27
  export {};
@@ -23,6 +23,6 @@ export declare class Serve extends InPlayEvent {
23
23
  readonly type: ServeTypeEnum;
24
24
  constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: ServeOpts);
25
25
  static getScore(stats: PerformanceStats, type: ServeTypeEnum, modifier: number, activeTraits: Trait[]): number;
26
- protected toString(): string;
26
+ toString(): string;
27
27
  }
28
28
  export {};
@@ -22,6 +22,6 @@ export declare class Set extends InPlayEvent {
22
22
  readonly type: SetTypeEnum;
23
23
  constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: SetOpts);
24
24
  static getScore(stats: PerformanceStats, type: SetTypeEnum, modifier: number, activeTraits: Trait[]): number;
25
- protected toString(): string;
25
+ toString(): string;
26
26
  }
27
27
  export {};
@@ -24,6 +24,6 @@ export declare class Spike extends InPlayEvent {
24
24
  readonly type: SpikeTypeEnum;
25
25
  constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: SpikeOpts);
26
26
  static getScore(player: Player, type: SpikeTypeEnum, modifier: number, isBackRow: boolean, activeTraits: Trait[]): number;
27
- protected toString(): string;
27
+ toString(): string;
28
28
  }
29
29
  export {};
@@ -6,6 +6,6 @@ interface SubstitutionOpts extends RallyEventOpts {
6
6
  export declare class Substitution extends RallyEvent {
7
7
  readonly playerOut: string;
8
8
  constructor({ order, playerOut, player, eventType }: SubstitutionOpts);
9
- protected toString(): string;
9
+ toString(): string;
10
10
  }
11
11
  export {};
@@ -22,6 +22,9 @@ export class Team {
22
22
  return this.roster.some(p => p.id === player.id);
23
23
  }
24
24
  toString() {
25
+ if (this.country == null) {
26
+ throw new Error('UNKNOWN_COUNTRY');
27
+ }
25
28
  return `${this.name} [${this.shortName}] (${this.country?.name}) ELO=${this._rating}`;
26
29
  }
27
30
  updateRating(ratingChange) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.123",
3
+ "version": "0.0.125",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",
@@ -11,9 +11,9 @@
11
11
  "madge": "npx madge --warning --circular --extensions ts ./",
12
12
  "standard": "npx ts-standard --fix",
13
13
  "clean": "rimraf dist",
14
- "prebuild": "npm run clean",
14
+ "validate": "npm run standard && npm run madge",
15
15
  "build": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json",
16
- "preversion": "npm run build",
16
+ "preversion": "npm run validate && npm run build",
17
17
  "postversion": "git push --follow-tags"
18
18
  },
19
19
  "author": "Francisco Farias <fariasfranciscoe@gmail.com>",