volleyballsimtypes 0.0.22 → 0.0.24

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.
@@ -157,10 +157,10 @@ function initModels(sequelize) {
157
157
  Season.hasMany(Match, { as: 'Matches', foreignKey: 'season_id' });
158
158
  Team.belongsTo(League, { as: 'league', foreignKey: 'league_id' });
159
159
  League.hasMany(League, { as: 'Teams', foreignKey: 'league_id' });
160
- Season.belongsTo(Team, { as: 'champion', foreignKey: 'champion' });
160
+ Season.belongsTo(Team, { as: 'Champion', foreignKey: 'champion' });
161
161
  Team.hasMany(Season, { as: 'titles', foreignKey: 'champion' });
162
162
  Tournament.hasMany(TournamentMatch, { as: 'Matches', foreignKey: 'tournament_id' });
163
- Tournament.belongsTo(Team, { as: 'champion', foreignKey: 'champion' });
163
+ Tournament.belongsTo(Team, { as: 'Champion', foreignKey: 'champion' });
164
164
  TournamentMatch.belongsTo(Tournament, { as: 'tournament', foreignKey: 'tournament_id' });
165
165
  TournamentMatch.belongsTo(Match, { as: 'match', foreignKey: 'match_id' });
166
166
  return {
@@ -17,4 +17,5 @@ export declare class Season {
17
17
  champion?: Team;
18
18
  constructor({ id, iteration, teams, matches, champion }: SeasonOpts);
19
19
  calculateStandings(): Standing[];
20
+ updateStandings(): void;
20
21
  }
@@ -18,5 +18,12 @@ class Season {
18
18
  return standing;
19
19
  }).sort(standing_1.Standing.sortFn);
20
20
  }
21
+ updateStandings() {
22
+ this.standings.length = 0;
23
+ this.standings.push(...this.calculateStandings());
24
+ if (this.matches.every((match) => match.isSimulated)) {
25
+ this.champion = this.teams.find((team) => team.id === this.standings[0].teamId);
26
+ }
27
+ }
21
28
  }
22
29
  exports.Season = Season;
@@ -154,10 +154,10 @@ export function initModels(sequelize) {
154
154
  Season.hasMany(Match, { as: 'Matches', foreignKey: 'season_id' });
155
155
  Team.belongsTo(League, { as: 'league', foreignKey: 'league_id' });
156
156
  League.hasMany(League, { as: 'Teams', foreignKey: 'league_id' });
157
- Season.belongsTo(Team, { as: 'champion', foreignKey: 'champion' });
157
+ Season.belongsTo(Team, { as: 'Champion', foreignKey: 'champion' });
158
158
  Team.hasMany(Season, { as: 'titles', foreignKey: 'champion' });
159
159
  Tournament.hasMany(TournamentMatch, { as: 'Matches', foreignKey: 'tournament_id' });
160
- Tournament.belongsTo(Team, { as: 'champion', foreignKey: 'champion' });
160
+ Tournament.belongsTo(Team, { as: 'Champion', foreignKey: 'champion' });
161
161
  TournamentMatch.belongsTo(Tournament, { as: 'tournament', foreignKey: 'tournament_id' });
162
162
  TournamentMatch.belongsTo(Match, { as: 'match', foreignKey: 'match_id' });
163
163
  return {
@@ -17,4 +17,5 @@ export declare class Season {
17
17
  champion?: Team;
18
18
  constructor({ id, iteration, teams, matches, champion }: SeasonOpts);
19
19
  calculateStandings(): Standing[];
20
+ updateStandings(): void;
20
21
  }
@@ -15,4 +15,11 @@ export class Season {
15
15
  return standing;
16
16
  }).sort(Standing.sortFn);
17
17
  }
18
+ updateStandings() {
19
+ this.standings.length = 0;
20
+ this.standings.push(...this.calculateStandings());
21
+ if (this.matches.every((match) => match.isSimulated)) {
22
+ this.champion = this.teams.find((team) => team.id === this.standings[0].teamId);
23
+ }
24
+ }
18
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",