volleyballsimtypes 0.0.70 → 0.0.72

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 {
@@ -13,7 +13,7 @@ class Season {
13
13
  }
14
14
  calculateStandings() {
15
15
  return this.teams.map(team => {
16
- const standing = new standing_1.Standing({ teamId: team.id });
16
+ const standing = new standing_1.Standing({ team });
17
17
  standing.calculateStanding(this.matches);
18
18
  return standing;
19
19
  }).sort(standing_1.Standing.sortFn);
@@ -24,7 +24,7 @@ class Season {
24
24
  this.standings.length = 0;
25
25
  this.standings.push(...this.calculateStandings());
26
26
  if (this.matches.every((match) => match.isSimulated)) {
27
- this.champion = this.teams.find((team) => team.id === this.standings[0].teamId);
27
+ this.champion = this.standings[0].team;
28
28
  }
29
29
  }
30
30
  }
@@ -1,9 +1,10 @@
1
1
  import { Match } from '../match';
2
+ import { Team } from '../team';
2
3
  interface StandingOpts {
3
- readonly teamId: string;
4
+ readonly team: Team;
4
5
  }
5
6
  export declare class Standing {
6
- readonly teamId: string;
7
+ readonly team: Team;
7
8
  won30: number;
8
9
  won31: number;
9
10
  won32: number;
@@ -20,7 +21,7 @@ export declare class Standing {
20
21
  matchesWon: number;
21
22
  matchesLost: number;
22
23
  totalMatches: number;
23
- constructor({ teamId }: StandingOpts);
24
+ constructor({ team }: StandingOpts);
24
25
  static sortFn(standingA: Standing, standingB: Standing): number;
25
26
  calculateStanding(matches: Match[]): void;
26
27
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Standing = void 0;
4
4
  const match_1 = require("../match");
5
5
  class Standing {
6
- constructor({ teamId }) {
6
+ constructor({ team }) {
7
7
  this.won30 = 0;
8
8
  this.won31 = 0;
9
9
  this.won32 = 0;
@@ -20,7 +20,7 @@ class Standing {
20
20
  this.matchesWon = 0;
21
21
  this.matchesLost = 0;
22
22
  this.totalMatches = 0;
23
- this.teamId = teamId;
23
+ this.team = team;
24
24
  }
25
25
  static sortFn(standingA, standingB) {
26
26
  if (standingB.points > standingA.points)
@@ -39,14 +39,14 @@ class Standing {
39
39
  return 0;
40
40
  }
41
41
  calculateStanding(matches) {
42
- matches = matches.filter(match => match.homeTeam.id === this.teamId || match.awayTeam.id === this.teamId)
42
+ matches = matches.filter(match => match.homeTeam.id === this.team.id || match.awayTeam.id === this.team.id)
43
43
  .filter(match => match.isOver());
44
44
  let teamSide;
45
45
  let otherSide;
46
46
  let teamScore;
47
47
  let otherScore;
48
48
  for (const match of matches) {
49
- if (this.teamId === match.homeTeam.id) {
49
+ if (this.team.id === match.homeTeam.id) {
50
50
  teamSide = match_1.MatchTeam.HOME;
51
51
  otherSide = match_1.MatchTeam.AWAY;
52
52
  }
@@ -54,7 +54,7 @@ class Standing {
54
54
  teamSide = match_1.MatchTeam.AWAY;
55
55
  otherSide = match_1.MatchTeam.HOME;
56
56
  }
57
- if (match.getWinner().id === this.teamId) {
57
+ if (match.getWinner().id === this.team.id) {
58
58
  this[`won3${match.getTeamSets(otherSide)}`]++;
59
59
  }
60
60
  else {
@@ -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
  }
@@ -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 {
@@ -10,7 +10,7 @@ export class Season {
10
10
  }
11
11
  calculateStandings() {
12
12
  return this.teams.map(team => {
13
- const standing = new Standing({ teamId: team.id });
13
+ const standing = new Standing({ team });
14
14
  standing.calculateStanding(this.matches);
15
15
  return standing;
16
16
  }).sort(Standing.sortFn);
@@ -21,7 +21,7 @@ export class Season {
21
21
  this.standings.length = 0;
22
22
  this.standings.push(...this.calculateStandings());
23
23
  if (this.matches.every((match) => match.isSimulated)) {
24
- this.champion = this.teams.find((team) => team.id === this.standings[0].teamId);
24
+ this.champion = this.standings[0].team;
25
25
  }
26
26
  }
27
27
  }
@@ -1,9 +1,10 @@
1
1
  import { Match } from '../match';
2
+ import { Team } from '../team';
2
3
  interface StandingOpts {
3
- readonly teamId: string;
4
+ readonly team: Team;
4
5
  }
5
6
  export declare class Standing {
6
- readonly teamId: string;
7
+ readonly team: Team;
7
8
  won30: number;
8
9
  won31: number;
9
10
  won32: number;
@@ -20,7 +21,7 @@ export declare class Standing {
20
21
  matchesWon: number;
21
22
  matchesLost: number;
22
23
  totalMatches: number;
23
- constructor({ teamId }: StandingOpts);
24
+ constructor({ team }: StandingOpts);
24
25
  static sortFn(standingA: Standing, standingB: Standing): number;
25
26
  calculateStanding(matches: Match[]): void;
26
27
  }
@@ -1,6 +1,6 @@
1
1
  import { MatchTeam } from '../match';
2
2
  export class Standing {
3
- constructor({ teamId }) {
3
+ constructor({ team }) {
4
4
  this.won30 = 0;
5
5
  this.won31 = 0;
6
6
  this.won32 = 0;
@@ -17,7 +17,7 @@ export class Standing {
17
17
  this.matchesWon = 0;
18
18
  this.matchesLost = 0;
19
19
  this.totalMatches = 0;
20
- this.teamId = teamId;
20
+ this.team = team;
21
21
  }
22
22
  static sortFn(standingA, standingB) {
23
23
  if (standingB.points > standingA.points)
@@ -36,14 +36,14 @@ export class Standing {
36
36
  return 0;
37
37
  }
38
38
  calculateStanding(matches) {
39
- matches = matches.filter(match => match.homeTeam.id === this.teamId || match.awayTeam.id === this.teamId)
39
+ matches = matches.filter(match => match.homeTeam.id === this.team.id || match.awayTeam.id === this.team.id)
40
40
  .filter(match => match.isOver());
41
41
  let teamSide;
42
42
  let otherSide;
43
43
  let teamScore;
44
44
  let otherScore;
45
45
  for (const match of matches) {
46
- if (this.teamId === match.homeTeam.id) {
46
+ if (this.team.id === match.homeTeam.id) {
47
47
  teamSide = MatchTeam.HOME;
48
48
  otherSide = MatchTeam.AWAY;
49
49
  }
@@ -51,7 +51,7 @@ export class Standing {
51
51
  teamSide = MatchTeam.AWAY;
52
52
  otherSide = MatchTeam.HOME;
53
53
  }
54
- if (match.getWinner().id === this.teamId) {
54
+ if (match.getWinner().id === this.team.id) {
55
55
  this[`won3${match.getTeamSets(otherSide)}`]++;
56
56
  }
57
57
  else {
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.70",
3
+ "version": "0.0.72",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",