volleyballsimtypes 0.0.204 → 0.0.205

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.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # VolleyballSimTypes
2
+
3
+ Tree-shaking
4
+
5
+ This package ships ESM + CJS builds and supports subpath imports. Prefer subpath imports to avoid pulling in unused modules.
6
+
7
+ Examples:
8
+
9
+ ```ts
10
+ import { Team } from 'volleyballsimtypes/service'
11
+ import { initModels } from 'volleyballsimtypes/data'
12
+ import { transformToTeam } from 'volleyballsimtypes/data/transformers'
13
+ ```
@@ -23,5 +23,6 @@ export declare class Season {
23
23
  champion?: Team;
24
24
  constructor({ id, iteration, teams, matches, champion, status, divisionId }: SeasonOpts);
25
25
  calculateStandings(): Standing[];
26
+ updateStandings(): void;
26
27
  }
27
28
  export {};
@@ -20,5 +20,14 @@ class Season {
20
20
  return standing;
21
21
  }).sort(standing_1.Standing.sortFn);
22
22
  }
23
+ updateStandings() {
24
+ if (this.matches == null || this.matches.length < 1)
25
+ throw new Error('NO_MATCHES');
26
+ const updated = this.calculateStandings();
27
+ this.standings.splice(0, this.standings.length, ...updated);
28
+ if (this.matches.every((match) => match.isOver())) {
29
+ this.champion = this.standings[0].team;
30
+ }
31
+ }
23
32
  }
24
33
  exports.Season = Season;
@@ -32,13 +32,10 @@ class Match {
32
32
  return `${this.getTeamSets(match_team_1.MatchTeam.HOME)}-${this.getTeamSets(match_team_1.MatchTeam.AWAY)}`;
33
33
  }
34
34
  isOver() {
35
- const gamesRequired = 3;
36
- const lastSet = this.sets.at(-1);
37
- if (lastSet == null || !lastSet.isOver() || this.sets.length < gamesRequired)
38
- return false;
35
+ const setsToWin = 3;
39
36
  const homeSets = this.getTeamSets(match_team_1.MatchTeam.HOME);
40
37
  const awaySets = this.getTeamSets(match_team_1.MatchTeam.AWAY);
41
- return !(homeSets < gamesRequired && awaySets < gamesRequired);
38
+ return !(homeSets < setsToWin && awaySets < setsToWin);
42
39
  }
43
40
  getWinner() {
44
41
  if (!this.isOver())
@@ -23,5 +23,6 @@ export declare class Season {
23
23
  champion?: Team;
24
24
  constructor({ id, iteration, teams, matches, champion, status, divisionId }: SeasonOpts);
25
25
  calculateStandings(): Standing[];
26
+ updateStandings(): void;
26
27
  }
27
28
  export {};
@@ -17,4 +17,13 @@ export class Season {
17
17
  return standing;
18
18
  }).sort(Standing.sortFn);
19
19
  }
20
+ updateStandings() {
21
+ if (this.matches == null || this.matches.length < 1)
22
+ throw new Error('NO_MATCHES');
23
+ const updated = this.calculateStandings();
24
+ this.standings.splice(0, this.standings.length, ...updated);
25
+ if (this.matches.every((match) => match.isOver())) {
26
+ this.champion = this.standings[0].team;
27
+ }
28
+ }
20
29
  }
@@ -29,13 +29,10 @@ export class Match {
29
29
  return `${this.getTeamSets(MatchTeam.HOME)}-${this.getTeamSets(MatchTeam.AWAY)}`;
30
30
  }
31
31
  isOver() {
32
- const gamesRequired = 3;
33
- const lastSet = this.sets.at(-1);
34
- if (lastSet == null || !lastSet.isOver() || this.sets.length < gamesRequired)
35
- return false;
32
+ const setsToWin = 3;
36
33
  const homeSets = this.getTeamSets(MatchTeam.HOME);
37
34
  const awaySets = this.getTeamSets(MatchTeam.AWAY);
38
- return !(homeSets < gamesRequired && awaySets < gamesRequired);
35
+ return !(homeSets < setsToWin && awaySets < setsToWin);
39
36
  }
40
37
  getWinner() {
41
38
  if (!this.isOver())
package/package.json CHANGED
@@ -1,9 +1,43 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.204",
3
+ "version": "0.0.205",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",
7
+ "types": "./dist/esm/src/index.d.ts",
8
+ "sideEffects": false,
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/esm/src/index.d.ts",
12
+ "import": "./dist/esm/src/index.js",
13
+ "require": "./dist/cjs/src/index.js"
14
+ },
15
+ "./service": {
16
+ "types": "./dist/esm/src/service/index.d.ts",
17
+ "import": "./dist/esm/src/service/index.js",
18
+ "require": "./dist/cjs/src/service/index.js"
19
+ },
20
+ "./data": {
21
+ "types": "./dist/esm/src/data/index.d.ts",
22
+ "import": "./dist/esm/src/data/index.js",
23
+ "require": "./dist/cjs/src/data/index.js"
24
+ },
25
+ "./data/models": {
26
+ "types": "./dist/esm/src/data/models/index.d.ts",
27
+ "import": "./dist/esm/src/data/models/index.js",
28
+ "require": "./dist/cjs/src/data/models/index.js"
29
+ },
30
+ "./data/transformers": {
31
+ "types": "./dist/esm/src/data/transformers/index.d.ts",
32
+ "import": "./dist/esm/src/data/transformers/index.js",
33
+ "require": "./dist/cjs/src/data/transformers/index.js"
34
+ },
35
+ "./data/common": {
36
+ "types": "./dist/esm/src/data/common/index.d.ts",
37
+ "import": "./dist/esm/src/data/common/index.js",
38
+ "require": "./dist/cjs/src/data/common/index.js"
39
+ }
40
+ },
7
41
  "files": [
8
42
  "dist/"
9
43
  ],