volleyballsimtypes 0.0.69 → 0.0.71

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.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformFromMatchRating = void 0;
4
4
  const service_1 = require("../../service");
5
5
  function transformToAttributes(team, rating) {
6
- const teamId = team === service_1.MatchTeam.HOME ? rating.home.id : rating.away.id;
6
+ const teamId = team === service_1.MatchTeam.HOME ? rating.match.homeTeam.id : rating.match.awayTeam.id;
7
7
  if (team == null)
8
8
  throw new Error(`INVALID_TEAM: ${teamId}`);
9
9
  return {
@@ -1,16 +1,11 @@
1
1
  import { Match, MatchTeam } from '.';
2
- import { Team } from '../team';
3
2
  interface MatchRatingOpts {
4
- readonly home: Team;
5
- readonly away: Team;
6
3
  readonly match: Match;
7
4
  }
8
5
  export declare class MatchRating {
9
6
  static K: number;
10
- readonly home: Team;
11
- readonly away: Team;
12
7
  readonly match: Match;
13
- constructor({ home, away, match }: MatchRatingOpts);
8
+ constructor({ match }: MatchRatingOpts);
14
9
  getWinProbability(team: MatchTeam): number;
15
10
  getRatingChange(team: MatchTeam): number;
16
11
  }
@@ -3,21 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MatchRating = void 0;
4
4
  const _1 = require(".");
5
5
  class MatchRating {
6
- constructor({ home, away, match }) {
7
- this.home = home;
8
- this.away = away;
6
+ constructor({ match }) {
9
7
  this.match = match;
10
8
  }
11
9
  getWinProbability(team) {
12
10
  let rA;
13
11
  let rB;
14
12
  if (team === _1.MatchTeam.HOME) {
15
- rA = this.home.rating;
16
- rB = this.away.rating;
13
+ rA = this.match.homeTeam.rating;
14
+ rB = this.match.awayTeam.rating;
17
15
  }
18
16
  else {
19
- rA = this.away.rating;
20
- rB = this.home.rating;
17
+ rA = this.match.awayTeam.rating;
18
+ rB = this.match.homeTeam.rating;
21
19
  }
22
20
  return 1 / (1 + Math.pow(10, ((rB - rA) / 400)));
23
21
  }
@@ -25,6 +25,7 @@ export declare class Team {
25
25
  isPlayerInRoster(player: Player): boolean;
26
26
  toString(): string;
27
27
  get rating(): number;
28
+ set rating(value: number);
28
29
  updateRating(ratingChange: number): void;
29
30
  }
30
31
  export {};
@@ -19,11 +19,14 @@ class Team {
19
19
  return this.roster.some(p => p.id === player.id);
20
20
  }
21
21
  toString() {
22
- return `${this.name} [${this.shortName}] (${this.country?.name})`;
22
+ return `${this.name} [${this.shortName}] (${this.country?.name}) ELO=${this._rating}`;
23
23
  }
24
24
  get rating() {
25
25
  return this._rating;
26
26
  }
27
+ set rating(value) {
28
+ this._rating = value;
29
+ }
27
30
  updateRating(ratingChange) {
28
31
  if (Math.abs(ratingChange) > match_1.MatchRating.K)
29
32
  throw new Error(`INVALID RATING CHANGE: ${ratingChange}`);
@@ -1,6 +1,6 @@
1
1
  import { MatchTeam } from '../../service';
2
2
  function transformToAttributes(team, rating) {
3
- const teamId = team === MatchTeam.HOME ? rating.home.id : rating.away.id;
3
+ const teamId = team === MatchTeam.HOME ? rating.match.homeTeam.id : rating.match.awayTeam.id;
4
4
  if (team == null)
5
5
  throw new Error(`INVALID_TEAM: ${teamId}`);
6
6
  return {
@@ -1,16 +1,11 @@
1
1
  import { Match, MatchTeam } from '.';
2
- import { Team } from '../team';
3
2
  interface MatchRatingOpts {
4
- readonly home: Team;
5
- readonly away: Team;
6
3
  readonly match: Match;
7
4
  }
8
5
  export declare class MatchRating {
9
6
  static K: number;
10
- readonly home: Team;
11
- readonly away: Team;
12
7
  readonly match: Match;
13
- constructor({ home, away, match }: MatchRatingOpts);
8
+ constructor({ match }: MatchRatingOpts);
14
9
  getWinProbability(team: MatchTeam): number;
15
10
  getRatingChange(team: MatchTeam): number;
16
11
  }
@@ -1,20 +1,18 @@
1
1
  import { MatchTeam } from '.';
2
2
  export class MatchRating {
3
- constructor({ home, away, match }) {
4
- this.home = home;
5
- this.away = away;
3
+ constructor({ match }) {
6
4
  this.match = match;
7
5
  }
8
6
  getWinProbability(team) {
9
7
  let rA;
10
8
  let rB;
11
9
  if (team === MatchTeam.HOME) {
12
- rA = this.home.rating;
13
- rB = this.away.rating;
10
+ rA = this.match.homeTeam.rating;
11
+ rB = this.match.awayTeam.rating;
14
12
  }
15
13
  else {
16
- rA = this.away.rating;
17
- rB = this.home.rating;
14
+ rA = this.match.awayTeam.rating;
15
+ rB = this.match.homeTeam.rating;
18
16
  }
19
17
  return 1 / (1 + Math.pow(10, ((rB - rA) / 400)));
20
18
  }
@@ -25,6 +25,7 @@ export declare class Team {
25
25
  isPlayerInRoster(player: Player): boolean;
26
26
  toString(): string;
27
27
  get rating(): number;
28
+ set rating(value: number);
28
29
  updateRating(ratingChange: number): void;
29
30
  }
30
31
  export {};
@@ -16,11 +16,14 @@ export class Team {
16
16
  return this.roster.some(p => p.id === player.id);
17
17
  }
18
18
  toString() {
19
- return `${this.name} [${this.shortName}] (${this.country?.name})`;
19
+ return `${this.name} [${this.shortName}] (${this.country?.name}) ELO=${this._rating}`;
20
20
  }
21
21
  get rating() {
22
22
  return this._rating;
23
23
  }
24
+ set rating(value) {
25
+ this._rating = value;
26
+ }
24
27
  updateRating(ratingChange) {
25
28
  if (Math.abs(ratingChange) > MatchRating.K)
26
29
  throw new Error(`INVALID RATING CHANGE: ${ratingChange}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.69",
3
+ "version": "0.0.71",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",