volleyballsimtypes 0.0.133 → 0.0.135

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 (33) hide show
  1. package/dist/cjs/data/role.formula.json +6 -6
  2. package/dist/cjs/data/stat.formula.json +4 -4
  3. package/dist/cjs/src/data/transformers/match-set.js +2 -2
  4. package/dist/cjs/src/service/coach/formation.d.ts +6 -6
  5. package/dist/cjs/src/service/coach/formation.js +18 -18
  6. package/dist/cjs/src/service/country/country.d.ts +1 -0
  7. package/dist/cjs/src/service/country/country.js +9 -0
  8. package/dist/cjs/src/service/match/match-set.d.ts +4 -4
  9. package/dist/cjs/src/service/match/match-set.js +8 -8
  10. package/dist/cjs/src/service/player/player.d.ts +17 -6
  11. package/dist/cjs/src/service/player/player.js +32 -1
  12. package/dist/cjs/src/service/player/role.d.ts +1 -0
  13. package/dist/cjs/src/service/player/role.js +3 -0
  14. package/dist/cjs/src/service/player/trait.d.ts +1 -0
  15. package/dist/cjs/src/service/player/trait.js +10 -0
  16. package/dist/cjs/src/service/team/team.d.ts +3 -3
  17. package/dist/esm/data/role.formula.json +6 -6
  18. package/dist/esm/data/stat.formula.json +4 -4
  19. package/dist/esm/src/data/transformers/match-set.js +2 -2
  20. package/dist/esm/src/service/coach/formation.d.ts +6 -6
  21. package/dist/esm/src/service/coach/formation.js +18 -18
  22. package/dist/esm/src/service/country/country.d.ts +1 -0
  23. package/dist/esm/src/service/country/country.js +9 -0
  24. package/dist/esm/src/service/match/match-set.d.ts +4 -4
  25. package/dist/esm/src/service/match/match-set.js +8 -8
  26. package/dist/esm/src/service/player/player.d.ts +17 -6
  27. package/dist/esm/src/service/player/player.js +29 -0
  28. package/dist/esm/src/service/player/role.d.ts +1 -0
  29. package/dist/esm/src/service/player/role.js +3 -0
  30. package/dist/esm/src/service/player/trait.d.ts +1 -0
  31. package/dist/esm/src/service/player/trait.js +10 -0
  32. package/dist/esm/src/service/team/team.d.ts +3 -3
  33. package/package.json +3 -2
@@ -1,6 +1,6 @@
1
1
  [
2
2
  {
3
- "role": "Setter",
3
+ "role": "SETTER",
4
4
  "weight": {
5
5
  "serve": 0.2,
6
6
  "setting": 0.2475,
@@ -16,7 +16,7 @@
16
16
  }
17
17
  },
18
18
  {
19
- "role": "Libero",
19
+ "role": "LIBERO",
20
20
  "weight": {
21
21
  "serve": 0.02,
22
22
  "setting": 0.045,
@@ -32,7 +32,7 @@
32
32
  }
33
33
  },
34
34
  {
35
- "role": "Outside Hitter",
35
+ "role": "OUTSIDE_HITTER",
36
36
  "weight": {
37
37
  "serve": 0.2,
38
38
  "setting": 0,
@@ -48,7 +48,7 @@
48
48
  }
49
49
  },
50
50
  {
51
- "role": "Opposite Hitter",
51
+ "role": "OPPOSITE_HITTER",
52
52
  "weight": {
53
53
  "serve": 0.2,
54
54
  "setting": 0,
@@ -64,7 +64,7 @@
64
64
  }
65
65
  },
66
66
  {
67
- "role": "Middle Blocker",
67
+ "role": "MIDDLE_BLOCKER",
68
68
  "weight": {
69
69
  "serve": 0.2,
70
70
  "setting": 0,
@@ -80,7 +80,7 @@
80
80
  }
81
81
  },
82
82
  {
83
- "role": "Defensive Specialist",
83
+ "role": "DEFENSIVE_SPECIALIST",
84
84
  "weight": {
85
85
  "serve": 0.005,
86
86
  "setting": 0.025,
@@ -1,6 +1,6 @@
1
1
  [
2
2
  {
3
- "statName": "Attack",
3
+ "statName": "ATTACK",
4
4
  "weight": {
5
5
  "serve": 0,
6
6
  "setting": 0.2,
@@ -16,7 +16,7 @@
16
16
  }
17
17
  },
18
18
  {
19
- "statName": "Defense",
19
+ "statName": "DEFENSE",
20
20
  "weight": {
21
21
  "serve": 0,
22
22
  "setting": 0.02,
@@ -32,7 +32,7 @@
32
32
  }
33
33
  },
34
34
  {
35
- "statName": "Physical",
35
+ "statName": "PHYSICAL",
36
36
  "weight": {
37
37
  "serve": 0,
38
38
  "setting": 0,
@@ -48,7 +48,7 @@
48
48
  }
49
49
  },
50
50
  {
51
- "statName": "Serve",
51
+ "statName": "SERVE",
52
52
  "weight": {
53
53
  "serve": 0.9,
54
54
  "setting": 0,
@@ -11,8 +11,8 @@ function transformToAttributes(set, matchId) {
11
11
  match_id: matchId,
12
12
  order: set.order,
13
13
  is_tie_break: set.isTieBreak,
14
- home_score: set.getHomeScore(),
15
- away_score: set.getAwayScore(),
14
+ home_score: set.homeScore,
15
+ away_score: set.awayScore,
16
16
  SetPositions: [...homeSetPositions, ...awaySetPositions],
17
17
  MatchSetStats: set.stats != null ? set.stats.map(stats => (0, _1.transformFromMatchSetStats)(stats, set.id)) : undefined,
18
18
  Rallies: set.rallies != null ? set.rallies.map(rally => (0, _1.transformFromRally)(rally, set.id)) : undefined
@@ -9,12 +9,12 @@ interface PositionRole {
9
9
  readonly [CourtPosition.RIGHT_BACK]: Role[];
10
10
  }
11
11
  export interface SubPriority {
12
- readonly 'Middle Blocker': number;
13
- readonly 'Outside Hitter': number;
14
- readonly 'Opposite Hitter': number;
15
- readonly 'Defensive Specialist': number;
16
- readonly Setter: number;
17
- readonly Libero: number;
12
+ readonly MIDDLE_BLOCKER: number;
13
+ readonly OUTSIDE_HITTER: number;
14
+ readonly OPPOSITE_HITTER: number;
15
+ readonly DEFENSIVE_SPECIALIST: number;
16
+ readonly SETTER: number;
17
+ readonly LIBERO: number;
18
18
  }
19
19
  export declare class Formation {
20
20
  static readonly '5-1': Formation;
@@ -44,12 +44,12 @@ Formation['5-1'] = new Formation({
44
44
  [player_1.Role.LIBERO]
45
45
  ],
46
46
  liberoSubPriority: {
47
- 'Middle Blocker': 1,
48
- 'Outside Hitter': 10,
49
- 'Opposite Hitter': 100,
50
- 'Defensive Specialist': 1000,
51
- Setter: 10000,
52
- Libero: 100000
47
+ MIDDLE_BLOCKER: 1,
48
+ OUTSIDE_HITTER: 10,
49
+ OPPOSITE_HITTER: 100,
50
+ DEFENSIVE_SPECIALIST: 1000,
51
+ SETTER: 10000,
52
+ LIBERO: 100000
53
53
  }
54
54
  });
55
55
  Formation['4-2'] = new Formation({
@@ -80,12 +80,12 @@ Formation['4-2'] = new Formation({
80
80
  [player_1.Role.LIBERO]
81
81
  ],
82
82
  liberoSubPriority: {
83
- 'Middle Blocker': 1,
84
- 'Outside Hitter': 10,
85
- 'Opposite Hitter': 100,
86
- 'Defensive Specialist': 1000,
87
- Setter: 10000,
88
- Libero: 100000
83
+ MIDDLE_BLOCKER: 1,
84
+ OUTSIDE_HITTER: 10,
85
+ OPPOSITE_HITTER: 100,
86
+ DEFENSIVE_SPECIALIST: 1000,
87
+ SETTER: 10000,
88
+ LIBERO: 100000
89
89
  }
90
90
  });
91
91
  Formation['6-2'] = new Formation({
@@ -116,11 +116,11 @@ Formation['6-2'] = new Formation({
116
116
  [player_1.Role.LIBERO]
117
117
  ],
118
118
  liberoSubPriority: {
119
- 'Middle Blocker': 1,
120
- 'Outside Hitter': 10,
121
- 'Opposite Hitter': 100,
122
- 'Defensive Specialist': 1000,
123
- Setter: 10000,
124
- Libero: 100000
119
+ MIDDLE_BLOCKER: 1,
120
+ OUTSIDE_HITTER: 10,
121
+ OPPOSITE_HITTER: 100,
122
+ DEFENSIVE_SPECIALIST: 1000,
123
+ SETTER: 10000,
124
+ LIBERO: 100000
125
125
  }
126
126
  });
@@ -12,5 +12,6 @@ export declare class Country {
12
12
  readonly language?: string;
13
13
  readonly league?: string;
14
14
  constructor({ id, name, short, language, league }: CountryOpts);
15
+ toString(): string;
15
16
  }
16
17
  export {};
@@ -9,5 +9,14 @@ class Country {
9
9
  this.language = language;
10
10
  this.league = league;
11
11
  }
12
+ toString() {
13
+ return JSON.stringify({
14
+ id: this.id,
15
+ name: this.name,
16
+ short: this.short,
17
+ language: this.language,
18
+ league: this.league
19
+ });
20
+ }
12
21
  }
13
22
  exports.Country = Country;
@@ -44,11 +44,11 @@ export declare class MatchSet implements MatchSetParams {
44
44
  readonly stats: SetStatistics[];
45
45
  readonly rallies: Rally[];
46
46
  readonly scoreThreshold: ScoreThreshold;
47
- homeScore: number;
48
- awayScore: number;
47
+ private _homeScore;
48
+ private _awayScore;
49
49
  constructor({ id, order, isTieBreak, homePlayerPosition, awayPlayerPosition, stats, rallies, homeScore, awayScore }: MatchSetParams);
50
- getHomeScore(): number;
51
- getAwayScore(): number;
50
+ get homeScore(): number;
51
+ get awayScore(): number;
52
52
  increaseScore(team: MatchTeam): void;
53
53
  addRally(rally: Rally): void;
54
54
  /**
@@ -13,8 +13,8 @@ class MatchSet {
13
13
  (0, utils_1.validateUUID)(id);
14
14
  this.id = id;
15
15
  this.order = order;
16
- this.homeScore = homeScore;
17
- this.awayScore = awayScore;
16
+ this._homeScore = homeScore;
17
+ this._awayScore = awayScore;
18
18
  this.homePlayerPosition = homePlayerPosition;
19
19
  this.awayPlayerPosition = awayPlayerPosition;
20
20
  this.stats = stats;
@@ -22,17 +22,17 @@ class MatchSet {
22
22
  this.isTieBreak = isTieBreak;
23
23
  this.scoreThreshold = isTieBreak ? ScoreThreshold.TIE_BREAK : ScoreThreshold.SET;
24
24
  }
25
- getHomeScore() {
26
- return this.homeScore;
25
+ get homeScore() {
26
+ return this._homeScore;
27
27
  }
28
- getAwayScore() {
29
- return this.awayScore;
28
+ get awayScore() {
29
+ return this._awayScore;
30
30
  }
31
31
  increaseScore(team) {
32
32
  if (team === match_team_1.MatchTeam.HOME)
33
- this.homeScore++;
33
+ this._homeScore++;
34
34
  else if (team === match_team_1.MatchTeam.AWAY)
35
- this.awayScore++;
35
+ this._awayScore++;
36
36
  else
37
37
  throw new Error('UNKNOWN_TEAM');
38
38
  }
@@ -3,9 +3,14 @@ import { Role } from './role';
3
3
  import { Trait } from './trait';
4
4
  import { Country } from '../country';
5
5
  import { GeneralStat } from './stats';
6
- export interface Stat {
7
- name: GeneralStat;
8
- value: number;
6
+ export declare class Stat {
7
+ readonly name: GeneralStat;
8
+ readonly value: number;
9
+ constructor({ name, value }: {
10
+ name: GeneralStat;
11
+ value: number;
12
+ });
13
+ toString(): string;
9
14
  }
10
15
  interface PlayerParams {
11
16
  readonly id: string;
@@ -15,9 +20,14 @@ interface PlayerParams {
15
20
  readonly roles: Role[];
16
21
  readonly traits: Trait[];
17
22
  }
18
- export interface Name {
19
- first: string;
20
- last: string;
23
+ export declare class Name {
24
+ readonly first: string;
25
+ readonly last: string;
26
+ constructor({ first, last }: {
27
+ first: string;
28
+ last: string;
29
+ });
30
+ toString(): string;
21
31
  }
22
32
  export declare class Player implements PlayerParams {
23
33
  readonly id: string;
@@ -31,5 +41,6 @@ export declare class Player implements PlayerParams {
31
41
  static sortPlayers(roles: Role[]): (p1: Player, p2: Player) => number;
32
42
  static compareStats(p1: Player, p2: Player): number;
33
43
  canPlayLibero(): boolean;
44
+ toString(): string;
34
45
  }
35
46
  export {};
@@ -1,9 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Player = void 0;
3
+ exports.Player = exports.Name = exports.Stat = void 0;
4
4
  const role_1 = require("./role");
5
5
  const utils_1 = require("../utils");
6
6
  const stats_1 = require("./stats");
7
+ class Stat {
8
+ constructor({ name, value }) {
9
+ this.name = name;
10
+ this.value = value;
11
+ }
12
+ toString() {
13
+ return `${this.name}: ${this.value}`;
14
+ }
15
+ }
16
+ exports.Stat = Stat;
17
+ class Name {
18
+ constructor({ first, last }) {
19
+ this.first = first;
20
+ this.last = last;
21
+ }
22
+ toString() {
23
+ return `${this.first} ${this.last}`;
24
+ }
25
+ }
26
+ exports.Name = Name;
7
27
  class Player {
8
28
  constructor({ id, name, country, stats, roles, traits }) {
9
29
  (0, utils_1.validateUUID)(id);
@@ -55,5 +75,16 @@ class Player {
55
75
  canPlayLibero() {
56
76
  return this.roles.includes(role_1.Role.LIBERO);
57
77
  }
78
+ toString() {
79
+ return JSON.stringify({
80
+ id: this.id,
81
+ name: this.name.toString(),
82
+ country: this.country.toString(),
83
+ stats: this.stats.toString(),
84
+ roles: `[${this.roles.map(r => r.toString()).join(',')}]`,
85
+ traits: `[${this.traits.map(r => r.toString()).join(',')}]`,
86
+ generalStats: `[${this.generalStats.map(r => r.toString()).join(',')}]`
87
+ });
88
+ }
58
89
  }
59
90
  exports.Player = Player;
@@ -10,6 +10,7 @@ export declare class Role {
10
10
  private static readonly ROLES;
11
11
  readonly name: RoleType;
12
12
  private constructor();
13
+ toString(): string;
13
14
  static getRoles(): Role[];
14
15
  static calculateScore(stats: PerformanceStats, role: Role): number;
15
16
  static assignRoles(stats: PerformanceStats): Role[];
@@ -9,6 +9,9 @@ class Role {
9
9
  constructor(name) {
10
10
  this.name = name;
11
11
  }
12
+ toString() {
13
+ return this.name;
14
+ }
12
15
  static getRoles() {
13
16
  return [...Role.ROLES];
14
17
  }
@@ -17,4 +17,5 @@ export declare class Trait {
17
17
  private constructor();
18
18
  static getTraits(): Trait[];
19
19
  static assignTraits(performanceStats: PerformanceStats): Trait[];
20
+ toString(): string;
20
21
  }
@@ -37,6 +37,16 @@ class Trait {
37
37
  return qualifiedTraits.sort((t1, t2) => t2.weight - t1.weight)
38
38
  .slice(0, traitCount);
39
39
  }
40
+ toString() {
41
+ return JSON.stringify({
42
+ name: this.name,
43
+ modifier: this.modifier,
44
+ statThreshold: this.statThreshold,
45
+ chance: this.chance,
46
+ stat: this.stat,
47
+ weight: this.weight
48
+ });
49
+ }
40
50
  }
41
51
  exports.Trait = Trait;
42
52
  // A Setter gets a bonus to their score and the receiving attacker gets a bonus as well.
@@ -2,7 +2,7 @@ import { Coach } from '../coach';
2
2
  import { Player } from '../player';
3
3
  import { Country } from '../country';
4
4
  import { League } from '../competition';
5
- interface TeamOpts {
5
+ interface TeamParams {
6
6
  readonly id: string;
7
7
  readonly rating: number;
8
8
  readonly name: string;
@@ -12,7 +12,7 @@ interface TeamOpts {
12
12
  readonly league?: League;
13
13
  readonly coach?: Coach;
14
14
  }
15
- export declare class Team {
15
+ export declare class Team implements TeamParams {
16
16
  readonly id: string;
17
17
  readonly roster: Player[];
18
18
  readonly name: string;
@@ -21,7 +21,7 @@ export declare class Team {
21
21
  readonly league?: League;
22
22
  readonly country?: Country;
23
23
  private _rating;
24
- constructor({ id, rating, name, shortName, country, roster, coach, league }: TeamOpts);
24
+ constructor({ id, rating, name, shortName, country, roster, coach, league }: TeamParams);
25
25
  get rating(): number;
26
26
  set rating(value: number);
27
27
  isPlayerInRoster(player: Player): boolean;
@@ -1,6 +1,6 @@
1
1
  [
2
2
  {
3
- "role": "Setter",
3
+ "role": "SETTER",
4
4
  "weight": {
5
5
  "serve": 0.2,
6
6
  "setting": 0.2475,
@@ -16,7 +16,7 @@
16
16
  }
17
17
  },
18
18
  {
19
- "role": "Libero",
19
+ "role": "LIBERO",
20
20
  "weight": {
21
21
  "serve": 0.02,
22
22
  "setting": 0.045,
@@ -32,7 +32,7 @@
32
32
  }
33
33
  },
34
34
  {
35
- "role": "Outside Hitter",
35
+ "role": "OUTSIDE_HITTER",
36
36
  "weight": {
37
37
  "serve": 0.2,
38
38
  "setting": 0,
@@ -48,7 +48,7 @@
48
48
  }
49
49
  },
50
50
  {
51
- "role": "Opposite Hitter",
51
+ "role": "OPPOSITE_HITTER",
52
52
  "weight": {
53
53
  "serve": 0.2,
54
54
  "setting": 0,
@@ -64,7 +64,7 @@
64
64
  }
65
65
  },
66
66
  {
67
- "role": "Middle Blocker",
67
+ "role": "MIDDLE_BLOCKER",
68
68
  "weight": {
69
69
  "serve": 0.2,
70
70
  "setting": 0,
@@ -80,7 +80,7 @@
80
80
  }
81
81
  },
82
82
  {
83
- "role": "Defensive Specialist",
83
+ "role": "DEFENSIVE_SPECIALIST",
84
84
  "weight": {
85
85
  "serve": 0.005,
86
86
  "setting": 0.025,
@@ -1,6 +1,6 @@
1
1
  [
2
2
  {
3
- "statName": "Attack",
3
+ "statName": "ATTACK",
4
4
  "weight": {
5
5
  "serve": 0,
6
6
  "setting": 0.2,
@@ -16,7 +16,7 @@
16
16
  }
17
17
  },
18
18
  {
19
- "statName": "Defense",
19
+ "statName": "DEFENSE",
20
20
  "weight": {
21
21
  "serve": 0,
22
22
  "setting": 0.02,
@@ -32,7 +32,7 @@
32
32
  }
33
33
  },
34
34
  {
35
- "statName": "Physical",
35
+ "statName": "PHYSICAL",
36
36
  "weight": {
37
37
  "serve": 0,
38
38
  "setting": 0,
@@ -48,7 +48,7 @@
48
48
  }
49
49
  },
50
50
  {
51
- "statName": "Serve",
51
+ "statName": "SERVE",
52
52
  "weight": {
53
53
  "serve": 0.9,
54
54
  "setting": 0,
@@ -8,8 +8,8 @@ function transformToAttributes(set, matchId) {
8
8
  match_id: matchId,
9
9
  order: set.order,
10
10
  is_tie_break: set.isTieBreak,
11
- home_score: set.getHomeScore(),
12
- away_score: set.getAwayScore(),
11
+ home_score: set.homeScore,
12
+ away_score: set.awayScore,
13
13
  SetPositions: [...homeSetPositions, ...awaySetPositions],
14
14
  MatchSetStats: set.stats != null ? set.stats.map(stats => transformFromMatchSetStats(stats, set.id)) : undefined,
15
15
  Rallies: set.rallies != null ? set.rallies.map(rally => transformFromRally(rally, set.id)) : undefined
@@ -9,12 +9,12 @@ interface PositionRole {
9
9
  readonly [CourtPosition.RIGHT_BACK]: Role[];
10
10
  }
11
11
  export interface SubPriority {
12
- readonly 'Middle Blocker': number;
13
- readonly 'Outside Hitter': number;
14
- readonly 'Opposite Hitter': number;
15
- readonly 'Defensive Specialist': number;
16
- readonly Setter: number;
17
- readonly Libero: number;
12
+ readonly MIDDLE_BLOCKER: number;
13
+ readonly OUTSIDE_HITTER: number;
14
+ readonly OPPOSITE_HITTER: number;
15
+ readonly DEFENSIVE_SPECIALIST: number;
16
+ readonly SETTER: number;
17
+ readonly LIBERO: number;
18
18
  }
19
19
  export declare class Formation {
20
20
  static readonly '5-1': Formation;
@@ -40,12 +40,12 @@ Formation['5-1'] = new Formation({
40
40
  [Role.LIBERO]
41
41
  ],
42
42
  liberoSubPriority: {
43
- 'Middle Blocker': 1,
44
- 'Outside Hitter': 10,
45
- 'Opposite Hitter': 100,
46
- 'Defensive Specialist': 1000,
47
- Setter: 10000,
48
- Libero: 100000
43
+ MIDDLE_BLOCKER: 1,
44
+ OUTSIDE_HITTER: 10,
45
+ OPPOSITE_HITTER: 100,
46
+ DEFENSIVE_SPECIALIST: 1000,
47
+ SETTER: 10000,
48
+ LIBERO: 100000
49
49
  }
50
50
  });
51
51
  Formation['4-2'] = new Formation({
@@ -76,12 +76,12 @@ Formation['4-2'] = new Formation({
76
76
  [Role.LIBERO]
77
77
  ],
78
78
  liberoSubPriority: {
79
- 'Middle Blocker': 1,
80
- 'Outside Hitter': 10,
81
- 'Opposite Hitter': 100,
82
- 'Defensive Specialist': 1000,
83
- Setter: 10000,
84
- Libero: 100000
79
+ MIDDLE_BLOCKER: 1,
80
+ OUTSIDE_HITTER: 10,
81
+ OPPOSITE_HITTER: 100,
82
+ DEFENSIVE_SPECIALIST: 1000,
83
+ SETTER: 10000,
84
+ LIBERO: 100000
85
85
  }
86
86
  });
87
87
  Formation['6-2'] = new Formation({
@@ -112,11 +112,11 @@ Formation['6-2'] = new Formation({
112
112
  [Role.LIBERO]
113
113
  ],
114
114
  liberoSubPriority: {
115
- 'Middle Blocker': 1,
116
- 'Outside Hitter': 10,
117
- 'Opposite Hitter': 100,
118
- 'Defensive Specialist': 1000,
119
- Setter: 10000,
120
- Libero: 100000
115
+ MIDDLE_BLOCKER: 1,
116
+ OUTSIDE_HITTER: 10,
117
+ OPPOSITE_HITTER: 100,
118
+ DEFENSIVE_SPECIALIST: 1000,
119
+ SETTER: 10000,
120
+ LIBERO: 100000
121
121
  }
122
122
  });
@@ -12,5 +12,6 @@ export declare class Country {
12
12
  readonly language?: string;
13
13
  readonly league?: string;
14
14
  constructor({ id, name, short, language, league }: CountryOpts);
15
+ toString(): string;
15
16
  }
16
17
  export {};
@@ -6,4 +6,13 @@ export class Country {
6
6
  this.language = language;
7
7
  this.league = league;
8
8
  }
9
+ toString() {
10
+ return JSON.stringify({
11
+ id: this.id,
12
+ name: this.name,
13
+ short: this.short,
14
+ language: this.language,
15
+ league: this.league
16
+ });
17
+ }
9
18
  }
@@ -44,11 +44,11 @@ export declare class MatchSet implements MatchSetParams {
44
44
  readonly stats: SetStatistics[];
45
45
  readonly rallies: Rally[];
46
46
  readonly scoreThreshold: ScoreThreshold;
47
- homeScore: number;
48
- awayScore: number;
47
+ private _homeScore;
48
+ private _awayScore;
49
49
  constructor({ id, order, isTieBreak, homePlayerPosition, awayPlayerPosition, stats, rallies, homeScore, awayScore }: MatchSetParams);
50
- getHomeScore(): number;
51
- getAwayScore(): number;
50
+ get homeScore(): number;
51
+ get awayScore(): number;
52
52
  increaseScore(team: MatchTeam): void;
53
53
  addRally(rally: Rally): void;
54
54
  /**
@@ -10,8 +10,8 @@ export class MatchSet {
10
10
  validateUUID(id);
11
11
  this.id = id;
12
12
  this.order = order;
13
- this.homeScore = homeScore;
14
- this.awayScore = awayScore;
13
+ this._homeScore = homeScore;
14
+ this._awayScore = awayScore;
15
15
  this.homePlayerPosition = homePlayerPosition;
16
16
  this.awayPlayerPosition = awayPlayerPosition;
17
17
  this.stats = stats;
@@ -19,17 +19,17 @@ export class MatchSet {
19
19
  this.isTieBreak = isTieBreak;
20
20
  this.scoreThreshold = isTieBreak ? ScoreThreshold.TIE_BREAK : ScoreThreshold.SET;
21
21
  }
22
- getHomeScore() {
23
- return this.homeScore;
22
+ get homeScore() {
23
+ return this._homeScore;
24
24
  }
25
- getAwayScore() {
26
- return this.awayScore;
25
+ get awayScore() {
26
+ return this._awayScore;
27
27
  }
28
28
  increaseScore(team) {
29
29
  if (team === MatchTeam.HOME)
30
- this.homeScore++;
30
+ this._homeScore++;
31
31
  else if (team === MatchTeam.AWAY)
32
- this.awayScore++;
32
+ this._awayScore++;
33
33
  else
34
34
  throw new Error('UNKNOWN_TEAM');
35
35
  }
@@ -3,9 +3,14 @@ import { Role } from './role';
3
3
  import { Trait } from './trait';
4
4
  import { Country } from '../country';
5
5
  import { GeneralStat } from './stats';
6
- export interface Stat {
7
- name: GeneralStat;
8
- value: number;
6
+ export declare class Stat {
7
+ readonly name: GeneralStat;
8
+ readonly value: number;
9
+ constructor({ name, value }: {
10
+ name: GeneralStat;
11
+ value: number;
12
+ });
13
+ toString(): string;
9
14
  }
10
15
  interface PlayerParams {
11
16
  readonly id: string;
@@ -15,9 +20,14 @@ interface PlayerParams {
15
20
  readonly roles: Role[];
16
21
  readonly traits: Trait[];
17
22
  }
18
- export interface Name {
19
- first: string;
20
- last: string;
23
+ export declare class Name {
24
+ readonly first: string;
25
+ readonly last: string;
26
+ constructor({ first, last }: {
27
+ first: string;
28
+ last: string;
29
+ });
30
+ toString(): string;
21
31
  }
22
32
  export declare class Player implements PlayerParams {
23
33
  readonly id: string;
@@ -31,5 +41,6 @@ export declare class Player implements PlayerParams {
31
41
  static sortPlayers(roles: Role[]): (p1: Player, p2: Player) => number;
32
42
  static compareStats(p1: Player, p2: Player): number;
33
43
  canPlayLibero(): boolean;
44
+ toString(): string;
34
45
  }
35
46
  export {};
@@ -1,6 +1,24 @@
1
1
  import { Role } from './role';
2
2
  import { validateUUID } from '../utils';
3
3
  import { GeneralStat } from './stats';
4
+ export class Stat {
5
+ constructor({ name, value }) {
6
+ this.name = name;
7
+ this.value = value;
8
+ }
9
+ toString() {
10
+ return `${this.name}: ${this.value}`;
11
+ }
12
+ }
13
+ export class Name {
14
+ constructor({ first, last }) {
15
+ this.first = first;
16
+ this.last = last;
17
+ }
18
+ toString() {
19
+ return `${this.first} ${this.last}`;
20
+ }
21
+ }
4
22
  export class Player {
5
23
  constructor({ id, name, country, stats, roles, traits }) {
6
24
  validateUUID(id);
@@ -52,4 +70,15 @@ export class Player {
52
70
  canPlayLibero() {
53
71
  return this.roles.includes(Role.LIBERO);
54
72
  }
73
+ toString() {
74
+ return JSON.stringify({
75
+ id: this.id,
76
+ name: this.name.toString(),
77
+ country: this.country.toString(),
78
+ stats: this.stats.toString(),
79
+ roles: `[${this.roles.map(r => r.toString()).join(',')}]`,
80
+ traits: `[${this.traits.map(r => r.toString()).join(',')}]`,
81
+ generalStats: `[${this.generalStats.map(r => r.toString()).join(',')}]`
82
+ });
83
+ }
55
84
  }
@@ -10,6 +10,7 @@ export declare class Role {
10
10
  private static readonly ROLES;
11
11
  readonly name: RoleType;
12
12
  private constructor();
13
+ toString(): string;
13
14
  static getRoles(): Role[];
14
15
  static calculateScore(stats: PerformanceStats, role: Role): number;
15
16
  static assignRoles(stats: PerformanceStats): Role[];
@@ -3,6 +3,9 @@ export class Role {
3
3
  constructor(name) {
4
4
  this.name = name;
5
5
  }
6
+ toString() {
7
+ return this.name;
8
+ }
6
9
  static getRoles() {
7
10
  return [...Role.ROLES];
8
11
  }
@@ -17,4 +17,5 @@ export declare class Trait {
17
17
  private constructor();
18
18
  static getTraits(): Trait[];
19
19
  static assignTraits(performanceStats: PerformanceStats): Trait[];
20
+ toString(): string;
20
21
  }
@@ -34,6 +34,16 @@ export class Trait {
34
34
  return qualifiedTraits.sort((t1, t2) => t2.weight - t1.weight)
35
35
  .slice(0, traitCount);
36
36
  }
37
+ toString() {
38
+ return JSON.stringify({
39
+ name: this.name,
40
+ modifier: this.modifier,
41
+ statThreshold: this.statThreshold,
42
+ chance: this.chance,
43
+ stat: this.stat,
44
+ weight: this.weight
45
+ });
46
+ }
37
47
  }
38
48
  // A Setter gets a bonus to their score and the receiving attacker gets a bonus as well.
39
49
  // Stacks with attacker bonus
@@ -2,7 +2,7 @@ import { Coach } from '../coach';
2
2
  import { Player } from '../player';
3
3
  import { Country } from '../country';
4
4
  import { League } from '../competition';
5
- interface TeamOpts {
5
+ interface TeamParams {
6
6
  readonly id: string;
7
7
  readonly rating: number;
8
8
  readonly name: string;
@@ -12,7 +12,7 @@ interface TeamOpts {
12
12
  readonly league?: League;
13
13
  readonly coach?: Coach;
14
14
  }
15
- export declare class Team {
15
+ export declare class Team implements TeamParams {
16
16
  readonly id: string;
17
17
  readonly roster: Player[];
18
18
  readonly name: string;
@@ -21,7 +21,7 @@ export declare class Team {
21
21
  readonly league?: League;
22
22
  readonly country?: Country;
23
23
  private _rating;
24
- constructor({ id, rating, name, shortName, country, roster, coach, league }: TeamOpts);
24
+ constructor({ id, rating, name, shortName, country, roster, coach, league }: TeamParams);
25
25
  get rating(): number;
26
26
  set rating(value: number);
27
27
  isPlayerInRoster(player: Player): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.133",
3
+ "version": "0.0.135",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",
@@ -29,7 +29,8 @@
29
29
  "ts-jest": "^29.0.5",
30
30
  "ts-node": "^10.9.1",
31
31
  "ts-standard": "^12.0.2",
32
- "typescript": "^4.9.4"
32
+ "typescript": "^4.9.4",
33
+ "jest": "^29.7.0"
33
34
  },
34
35
  "dependencies": {
35
36
  "@types/sequelize": "^4.28.15",