volleyballsimtypes 0.0.211 → 0.0.212

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.
@@ -33,6 +33,7 @@ function initModels(sequelize) {
33
33
  Tactics.belongsTo(Team, { as: 'team', foreignKey: 'team_id' });
34
34
  Competition.belongsTo(Iteration, { as: 'Iteration', foreignKey: 'iteration' });
35
35
  Competition.hasMany(CompetitionMatch, { as: 'CompetitionMatches', foreignKey: 'competition_id' });
36
+ Competition.hasMany(CompetitionStandings, { as: 'CompetitionStandings', foreignKey: 'competition_id' });
36
37
  Competition.hasMany(CompetitionTeams, { as: 'CompetitionTeams', foreignKey: 'competition_id' });
37
38
  Competition.hasOne(CompetitionChampion, { as: 'CompetitionChampion', foreignKey: 'competition_id' });
38
39
  Competition.hasOne(DivisionSeason, { as: 'DivisionSeason', foreignKey: 'competition_id' });
@@ -153,6 +154,7 @@ function initModels(sequelize) {
153
154
  Team.hasMany(PlayerTeam, { as: 'PlayerTeams', foreignKey: 'team_id' });
154
155
  Team.hasMany(Rally, { as: 'Rallies', foreignKey: 'serving_team' });
155
156
  Team.hasMany(MatchResult, { as: 'WonMatches', foreignKey: 'winner_team_id' });
157
+ Team.hasMany(CompetitionStandings, { as: 'CompetitionStandings', foreignKey: 'team_id' });
156
158
  return {
157
159
  Competition,
158
160
  CompetitionChampion,
@@ -16,6 +16,7 @@ export * from './player';
16
16
  export * from './rally';
17
17
  export * from './season';
18
18
  export * from './season-match';
19
+ export * from './standing';
19
20
  export * from './player-team';
20
21
  export * from './match-rating';
21
22
  export * from './team';
@@ -32,6 +32,7 @@ __exportStar(require("./player"), exports);
32
32
  __exportStar(require("./rally"), exports);
33
33
  __exportStar(require("./season"), exports);
34
34
  __exportStar(require("./season-match"), exports);
35
+ __exportStar(require("./standing"), exports);
35
36
  __exportStar(require("./player-team"), exports);
36
37
  __exportStar(require("./match-rating"), exports);
37
38
  __exportStar(require("./team"), exports);
@@ -0,0 +1,4 @@
1
+ import { CompetitionStandingsModel } from '../models';
2
+ import { Standing } from '../../service';
3
+ declare function transformToObject(model: CompetitionStandingsModel): Standing;
4
+ export { transformToObject as transformToStanding };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformToStanding = void 0;
4
+ const service_1 = require("../../service");
5
+ function transformToObject(model) {
6
+ return new service_1.Standing({
7
+ teamId: model.team_id,
8
+ won30: Number(model.won30),
9
+ won31: Number(model.won31),
10
+ won32: Number(model.won32),
11
+ lost03: Number(model.lost03),
12
+ lost13: Number(model.lost13),
13
+ lost23: Number(model.lost23),
14
+ pointsWon: Number(model.points_won),
15
+ pointsLost: Number(model.points_lost),
16
+ points: Number(model.points),
17
+ setsWon: Number(model.sets_won),
18
+ setsLost: Number(model.sets_lost),
19
+ matchesWon: Number(model.matches_won),
20
+ matchesLost: Number(model.matches_lost),
21
+ totalMatches: Number(model.total_matches)
22
+ });
23
+ }
24
+ exports.transformToStanding = transformToObject;
@@ -11,6 +11,7 @@ interface SeasonOpts {
11
11
  readonly divisionId: string;
12
12
  readonly champion?: Team;
13
13
  readonly status: StatusEnum;
14
+ readonly standings?: Standing[];
14
15
  }
15
16
  export declare class Season {
16
17
  readonly id: string;
@@ -21,7 +22,7 @@ export declare class Season {
21
22
  readonly standings: Standing[];
22
23
  readonly status: StatusEnum;
23
24
  champion?: Team;
24
- constructor({ id, iteration, teams, matches, champion, status, divisionId }: SeasonOpts);
25
+ constructor({ id, iteration, teams, matches, champion, status, divisionId, standings }: SeasonOpts);
25
26
  calculateStandings(): Standing[];
26
27
  updateStandings(): void;
27
28
  }
@@ -3,22 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Season = void 0;
4
4
  const standing_1 = require("./standing");
5
5
  class Season {
6
- constructor({ id, iteration, teams, matches, champion, status, divisionId }) {
6
+ constructor({ id, iteration, teams, matches, champion, status, divisionId, standings }) {
7
7
  this.id = id;
8
8
  this.teams = teams;
9
9
  this.matches = matches;
10
10
  this.iteration = iteration;
11
11
  this.divisionId = divisionId;
12
12
  this.champion = champion;
13
- this.standings = this.calculateStandings();
13
+ this.standings = standings ?? this.calculateStandings();
14
14
  this.status = status;
15
+ this.standings.sort(standing_1.Standing.sortFn);
15
16
  }
16
17
  calculateStandings() {
17
18
  return this.teams.map(team => {
18
- const standing = new standing_1.Standing({ team });
19
+ const standing = new standing_1.Standing({ teamId: team.id });
19
20
  standing.calculateStanding(this.matches);
20
21
  return standing;
21
- }).sort(standing_1.Standing.sortFn);
22
+ });
22
23
  }
23
24
  updateStandings() {
24
25
  if (this.matches == null || this.matches.length < 1)
@@ -26,7 +27,7 @@ class Season {
26
27
  const updated = this.calculateStandings();
27
28
  this.standings.splice(0, this.standings.length, ...updated);
28
29
  if (this.matches.every((match) => match.isOver())) {
29
- this.champion = this.standings[0].team;
30
+ this.champion = this.teams.find((team) => team.id === this.standings[0].teamId);
30
31
  }
31
32
  }
32
33
  }
@@ -1,10 +1,23 @@
1
1
  import { Match } from '../match';
2
- import { Team } from '../team';
3
2
  interface StandingOpts {
4
- readonly team: Team;
3
+ teamId: string;
4
+ won30?: number;
5
+ won31?: number;
6
+ won32?: number;
7
+ lost03?: number;
8
+ lost13?: number;
9
+ lost23?: number;
10
+ pointsWon?: number;
11
+ pointsLost?: number;
12
+ points?: number;
13
+ setsWon?: number;
14
+ setsLost?: number;
15
+ matchesWon?: number;
16
+ matchesLost?: number;
17
+ totalMatches?: number;
5
18
  }
6
19
  export declare class Standing {
7
- readonly team: Team;
20
+ readonly teamId: string;
8
21
  won30: number;
9
22
  won31: number;
10
23
  won32: number;
@@ -21,7 +34,7 @@ export declare class Standing {
21
34
  matchesWon: number;
22
35
  matchesLost: number;
23
36
  totalMatches: number;
24
- constructor({ team }: StandingOpts);
37
+ constructor(opts: StandingOpts);
25
38
  static sortFn(standingA: Standing, standingB: Standing): number;
26
39
  calculateStanding(matches: Match[]): void;
27
40
  }
@@ -3,24 +3,24 @@ 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({ team }) {
7
- this.won30 = 0;
8
- this.won31 = 0;
9
- this.won32 = 0;
10
- this.lost03 = 0;
11
- this.lost13 = 0;
12
- this.lost23 = 0;
13
- this.pointsWon = 0;
14
- this.pointsLost = 0;
15
- this.points = 0;
16
- this.pointsRatio = 0;
17
- this.setsWon = 0;
18
- this.setsLost = 0;
19
- this.setsRatio = 0;
20
- this.matchesWon = 0;
21
- this.matchesLost = 0;
22
- this.totalMatches = 0;
23
- this.team = team;
6
+ constructor(opts) {
7
+ this.teamId = opts.teamId;
8
+ this.won30 = opts.won30 ?? 0;
9
+ this.won31 = opts.won31 ?? 0;
10
+ this.won32 = opts.won32 ?? 0;
11
+ this.lost03 = opts.lost03 ?? 0;
12
+ this.lost13 = opts.lost13 ?? 0;
13
+ this.lost23 = opts.lost23 ?? 0;
14
+ this.pointsWon = opts.pointsWon ?? 0;
15
+ this.pointsLost = opts.pointsLost ?? 0;
16
+ this.points = opts.points ?? 0;
17
+ this.pointsRatio = this.pointsWon / this.pointsLost;
18
+ this.setsWon = opts.setsWon ?? 0;
19
+ this.setsLost = opts.setsLost ?? 0;
20
+ this.setsRatio = this.setsWon / this.setsLost;
21
+ this.matchesWon = opts.matchesWon ?? 0;
22
+ this.matchesLost = opts.matchesLost ?? 0;
23
+ this.totalMatches = opts.totalMatches ?? 0;
24
24
  }
25
25
  static sortFn(standingA, standingB) {
26
26
  if (standingB.points > standingA.points)
@@ -39,12 +39,12 @@ class Standing {
39
39
  return 0;
40
40
  }
41
41
  calculateStanding(matches) {
42
- matches = matches.filter(match => match.homeTeam.id === this.team.id || match.awayTeam.id === this.team.id)
42
+ matches = matches.filter(match => match.homeTeam.id === this.teamId || match.awayTeam.id === this.teamId)
43
43
  .filter(match => match.isOver());
44
44
  let teamSide;
45
45
  let otherSide;
46
46
  for (const match of matches) {
47
- if (this.team.id === match.homeTeam.id) {
47
+ if (this.teamId === match.homeTeam.id) {
48
48
  teamSide = match_1.MatchTeam.HOME;
49
49
  otherSide = match_1.MatchTeam.AWAY;
50
50
  }
@@ -52,7 +52,7 @@ class Standing {
52
52
  teamSide = match_1.MatchTeam.AWAY;
53
53
  otherSide = match_1.MatchTeam.HOME;
54
54
  }
55
- if (match.getWinner().id === this.team.id) {
55
+ if (match.getWinner().id === this.teamId) {
56
56
  this[`won3${match.getTeamSets(otherSide)}`]++;
57
57
  }
58
58
  else {
@@ -30,6 +30,7 @@ export function initModels(sequelize) {
30
30
  Tactics.belongsTo(Team, { as: 'team', foreignKey: 'team_id' });
31
31
  Competition.belongsTo(Iteration, { as: 'Iteration', foreignKey: 'iteration' });
32
32
  Competition.hasMany(CompetitionMatch, { as: 'CompetitionMatches', foreignKey: 'competition_id' });
33
+ Competition.hasMany(CompetitionStandings, { as: 'CompetitionStandings', foreignKey: 'competition_id' });
33
34
  Competition.hasMany(CompetitionTeams, { as: 'CompetitionTeams', foreignKey: 'competition_id' });
34
35
  Competition.hasOne(CompetitionChampion, { as: 'CompetitionChampion', foreignKey: 'competition_id' });
35
36
  Competition.hasOne(DivisionSeason, { as: 'DivisionSeason', foreignKey: 'competition_id' });
@@ -150,6 +151,7 @@ export function initModels(sequelize) {
150
151
  Team.hasMany(PlayerTeam, { as: 'PlayerTeams', foreignKey: 'team_id' });
151
152
  Team.hasMany(Rally, { as: 'Rallies', foreignKey: 'serving_team' });
152
153
  Team.hasMany(MatchResult, { as: 'WonMatches', foreignKey: 'winner_team_id' });
154
+ Team.hasMany(CompetitionStandings, { as: 'CompetitionStandings', foreignKey: 'team_id' });
153
155
  return {
154
156
  Competition,
155
157
  CompetitionChampion,
@@ -16,6 +16,7 @@ export * from './player';
16
16
  export * from './rally';
17
17
  export * from './season';
18
18
  export * from './season-match';
19
+ export * from './standing';
19
20
  export * from './player-team';
20
21
  export * from './match-rating';
21
22
  export * from './team';
@@ -16,6 +16,7 @@ export * from './player';
16
16
  export * from './rally';
17
17
  export * from './season';
18
18
  export * from './season-match';
19
+ export * from './standing';
19
20
  export * from './player-team';
20
21
  export * from './match-rating';
21
22
  export * from './team';
@@ -0,0 +1,4 @@
1
+ import { CompetitionStandingsModel } from '../models';
2
+ import { Standing } from '../../service';
3
+ declare function transformToObject(model: CompetitionStandingsModel): Standing;
4
+ export { transformToObject as transformToStanding };
@@ -0,0 +1,21 @@
1
+ import { Standing } from '../../service';
2
+ function transformToObject(model) {
3
+ return new Standing({
4
+ teamId: model.team_id,
5
+ won30: Number(model.won30),
6
+ won31: Number(model.won31),
7
+ won32: Number(model.won32),
8
+ lost03: Number(model.lost03),
9
+ lost13: Number(model.lost13),
10
+ lost23: Number(model.lost23),
11
+ pointsWon: Number(model.points_won),
12
+ pointsLost: Number(model.points_lost),
13
+ points: Number(model.points),
14
+ setsWon: Number(model.sets_won),
15
+ setsLost: Number(model.sets_lost),
16
+ matchesWon: Number(model.matches_won),
17
+ matchesLost: Number(model.matches_lost),
18
+ totalMatches: Number(model.total_matches)
19
+ });
20
+ }
21
+ export { transformToObject as transformToStanding };
@@ -11,6 +11,7 @@ interface SeasonOpts {
11
11
  readonly divisionId: string;
12
12
  readonly champion?: Team;
13
13
  readonly status: StatusEnum;
14
+ readonly standings?: Standing[];
14
15
  }
15
16
  export declare class Season {
16
17
  readonly id: string;
@@ -21,7 +22,7 @@ export declare class Season {
21
22
  readonly standings: Standing[];
22
23
  readonly status: StatusEnum;
23
24
  champion?: Team;
24
- constructor({ id, iteration, teams, matches, champion, status, divisionId }: SeasonOpts);
25
+ constructor({ id, iteration, teams, matches, champion, status, divisionId, standings }: SeasonOpts);
25
26
  calculateStandings(): Standing[];
26
27
  updateStandings(): void;
27
28
  }
@@ -1,21 +1,22 @@
1
1
  import { Standing } from './standing';
2
2
  export class Season {
3
- constructor({ id, iteration, teams, matches, champion, status, divisionId }) {
3
+ constructor({ id, iteration, teams, matches, champion, status, divisionId, standings }) {
4
4
  this.id = id;
5
5
  this.teams = teams;
6
6
  this.matches = matches;
7
7
  this.iteration = iteration;
8
8
  this.divisionId = divisionId;
9
9
  this.champion = champion;
10
- this.standings = this.calculateStandings();
10
+ this.standings = standings ?? this.calculateStandings();
11
11
  this.status = status;
12
+ this.standings.sort(Standing.sortFn);
12
13
  }
13
14
  calculateStandings() {
14
15
  return this.teams.map(team => {
15
- const standing = new Standing({ team });
16
+ const standing = new Standing({ teamId: team.id });
16
17
  standing.calculateStanding(this.matches);
17
18
  return standing;
18
- }).sort(Standing.sortFn);
19
+ });
19
20
  }
20
21
  updateStandings() {
21
22
  if (this.matches == null || this.matches.length < 1)
@@ -23,7 +24,7 @@ export class Season {
23
24
  const updated = this.calculateStandings();
24
25
  this.standings.splice(0, this.standings.length, ...updated);
25
26
  if (this.matches.every((match) => match.isOver())) {
26
- this.champion = this.standings[0].team;
27
+ this.champion = this.teams.find((team) => team.id === this.standings[0].teamId);
27
28
  }
28
29
  }
29
30
  }
@@ -1,10 +1,23 @@
1
1
  import { Match } from '../match';
2
- import { Team } from '../team';
3
2
  interface StandingOpts {
4
- readonly team: Team;
3
+ teamId: string;
4
+ won30?: number;
5
+ won31?: number;
6
+ won32?: number;
7
+ lost03?: number;
8
+ lost13?: number;
9
+ lost23?: number;
10
+ pointsWon?: number;
11
+ pointsLost?: number;
12
+ points?: number;
13
+ setsWon?: number;
14
+ setsLost?: number;
15
+ matchesWon?: number;
16
+ matchesLost?: number;
17
+ totalMatches?: number;
5
18
  }
6
19
  export declare class Standing {
7
- readonly team: Team;
20
+ readonly teamId: string;
8
21
  won30: number;
9
22
  won31: number;
10
23
  won32: number;
@@ -21,7 +34,7 @@ export declare class Standing {
21
34
  matchesWon: number;
22
35
  matchesLost: number;
23
36
  totalMatches: number;
24
- constructor({ team }: StandingOpts);
37
+ constructor(opts: StandingOpts);
25
38
  static sortFn(standingA: Standing, standingB: Standing): number;
26
39
  calculateStanding(matches: Match[]): void;
27
40
  }
@@ -1,23 +1,23 @@
1
1
  import { MatchTeam } from '../match';
2
2
  export class Standing {
3
- constructor({ team }) {
4
- this.won30 = 0;
5
- this.won31 = 0;
6
- this.won32 = 0;
7
- this.lost03 = 0;
8
- this.lost13 = 0;
9
- this.lost23 = 0;
10
- this.pointsWon = 0;
11
- this.pointsLost = 0;
12
- this.points = 0;
13
- this.pointsRatio = 0;
14
- this.setsWon = 0;
15
- this.setsLost = 0;
16
- this.setsRatio = 0;
17
- this.matchesWon = 0;
18
- this.matchesLost = 0;
19
- this.totalMatches = 0;
20
- this.team = team;
3
+ constructor(opts) {
4
+ this.teamId = opts.teamId;
5
+ this.won30 = opts.won30 ?? 0;
6
+ this.won31 = opts.won31 ?? 0;
7
+ this.won32 = opts.won32 ?? 0;
8
+ this.lost03 = opts.lost03 ?? 0;
9
+ this.lost13 = opts.lost13 ?? 0;
10
+ this.lost23 = opts.lost23 ?? 0;
11
+ this.pointsWon = opts.pointsWon ?? 0;
12
+ this.pointsLost = opts.pointsLost ?? 0;
13
+ this.points = opts.points ?? 0;
14
+ this.pointsRatio = this.pointsWon / this.pointsLost;
15
+ this.setsWon = opts.setsWon ?? 0;
16
+ this.setsLost = opts.setsLost ?? 0;
17
+ this.setsRatio = this.setsWon / this.setsLost;
18
+ this.matchesWon = opts.matchesWon ?? 0;
19
+ this.matchesLost = opts.matchesLost ?? 0;
20
+ this.totalMatches = opts.totalMatches ?? 0;
21
21
  }
22
22
  static sortFn(standingA, standingB) {
23
23
  if (standingB.points > standingA.points)
@@ -36,12 +36,12 @@ export class Standing {
36
36
  return 0;
37
37
  }
38
38
  calculateStanding(matches) {
39
- matches = matches.filter(match => match.homeTeam.id === this.team.id || match.awayTeam.id === this.team.id)
39
+ matches = matches.filter(match => match.homeTeam.id === this.teamId || match.awayTeam.id === this.teamId)
40
40
  .filter(match => match.isOver());
41
41
  let teamSide;
42
42
  let otherSide;
43
43
  for (const match of matches) {
44
- if (this.team.id === match.homeTeam.id) {
44
+ if (this.teamId === match.homeTeam.id) {
45
45
  teamSide = MatchTeam.HOME;
46
46
  otherSide = MatchTeam.AWAY;
47
47
  }
@@ -49,7 +49,7 @@ export class Standing {
49
49
  teamSide = MatchTeam.AWAY;
50
50
  otherSide = MatchTeam.HOME;
51
51
  }
52
- if (match.getWinner().id === this.team.id) {
52
+ if (match.getWinner().id === this.teamId) {
53
53
  this[`won3${match.getTeamSets(otherSide)}`]++;
54
54
  }
55
55
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.211",
3
+ "version": "0.0.212",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",