volleyballsimtypes 0.0.139 → 0.0.140

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.
Files changed (185) hide show
  1. package/dist/esm/data/index.d.ts +3 -0
  2. package/dist/esm/data/index.js +3 -0
  3. package/dist/esm/data/init-models.d.ts +2 -0
  4. package/dist/esm/data/init-models.js +194 -0
  5. package/dist/esm/data/models/coach.d.ts +40 -0
  6. package/dist/esm/data/models/coach.js +51 -0
  7. package/dist/esm/data/models/competition-champion.d.ts +23 -0
  8. package/dist/esm/data/models/competition-champion.js +34 -0
  9. package/dist/esm/data/models/competition-match.d.ts +29 -0
  10. package/dist/esm/data/models/competition-match.js +42 -0
  11. package/dist/esm/data/models/competition-teams.d.ts +23 -0
  12. package/dist/esm/data/models/competition-teams.js +38 -0
  13. package/dist/esm/data/models/competition.d.ts +67 -0
  14. package/dist/esm/data/models/competition.js +34 -0
  15. package/dist/esm/data/models/country.d.ts +61 -0
  16. package/dist/esm/data/models/country.js +30 -0
  17. package/dist/esm/data/models/draft-pick.d.ts +31 -0
  18. package/dist/esm/data/models/draft-pick.js +46 -0
  19. package/dist/esm/data/models/draft.d.ts +29 -0
  20. package/dist/esm/data/models/draft.js +30 -0
  21. package/dist/esm/data/models/index.d.ts +24 -0
  22. package/dist/esm/data/models/index.js +24 -0
  23. package/dist/esm/data/models/iteration.d.ts +26 -0
  24. package/dist/esm/data/models/iteration.js +26 -0
  25. package/dist/esm/data/models/league-season.d.ts +23 -0
  26. package/dist/esm/data/models/league-season.js +34 -0
  27. package/dist/esm/data/models/league.d.ts +44 -0
  28. package/dist/esm/data/models/league.js +34 -0
  29. package/dist/esm/data/models/match-rating.d.ts +27 -0
  30. package/dist/esm/data/models/match-rating.js +48 -0
  31. package/dist/esm/data/models/match-set-stats.d.ts +58 -0
  32. package/dist/esm/data/models/match-set-stats.js +123 -0
  33. package/dist/esm/data/models/match-set.d.ts +85 -0
  34. package/dist/esm/data/models/match-set.js +47 -0
  35. package/dist/esm/data/models/match.d.ts +67 -0
  36. package/dist/esm/data/models/match.js +47 -0
  37. package/dist/esm/data/models/performance-stats.d.ts +40 -0
  38. package/dist/esm/data/models/performance-stats.js +81 -0
  39. package/dist/esm/data/models/player-team.d.ts +28 -0
  40. package/dist/esm/data/models/player-team.js +48 -0
  41. package/dist/esm/data/models/player-trait.d.ts +23 -0
  42. package/dist/esm/data/models/player-trait.js +38 -0
  43. package/dist/esm/data/models/player.d.ts +124 -0
  44. package/dist/esm/data/models/player.js +42 -0
  45. package/dist/esm/data/models/rally.d.ts +29 -0
  46. package/dist/esm/data/models/rally.js +46 -0
  47. package/dist/esm/data/models/set-position.d.ts +29 -0
  48. package/dist/esm/data/models/set-position.js +46 -0
  49. package/dist/esm/data/models/team.d.ts +162 -0
  50. package/dist/esm/data/models/team.js +59 -0
  51. package/dist/esm/data/models/trait.d.ts +37 -0
  52. package/dist/esm/data/models/trait.js +26 -0
  53. package/dist/esm/data/models/user.d.ts +22 -0
  54. package/dist/esm/data/models/user.js +53 -0
  55. package/dist/esm/data/transformers/coach.d.ts +5 -0
  56. package/dist/esm/data/transformers/coach.js +25 -0
  57. package/dist/esm/data/transformers/country.d.ts +5 -0
  58. package/dist/esm/data/transformers/country.js +16 -0
  59. package/dist/esm/data/transformers/court-position.d.ts +5 -0
  60. package/dist/esm/data/transformers/court-position.js +27 -0
  61. package/dist/esm/data/transformers/draft-pick.d.ts +5 -0
  62. package/dist/esm/data/transformers/draft-pick.js +18 -0
  63. package/dist/esm/data/transformers/draft.d.ts +5 -0
  64. package/dist/esm/data/transformers/draft.js +20 -0
  65. package/dist/esm/data/transformers/formation.d.ts +5 -0
  66. package/dist/esm/data/transformers/formation.js +8 -0
  67. package/dist/esm/data/transformers/index.d.ts +25 -0
  68. package/dist/esm/data/transformers/index.js +25 -0
  69. package/dist/esm/data/transformers/iteration.d.ts +5 -0
  70. package/dist/esm/data/transformers/iteration.js +14 -0
  71. package/dist/esm/data/transformers/league.d.ts +5 -0
  72. package/dist/esm/data/transformers/league.js +28 -0
  73. package/dist/esm/data/transformers/match-rating.d.ts +4 -0
  74. package/dist/esm/data/transformers/match-rating.js +13 -0
  75. package/dist/esm/data/transformers/match-set-stats.d.ts +5 -0
  76. package/dist/esm/data/transformers/match-set-stats.js +57 -0
  77. package/dist/esm/data/transformers/match-set.d.ts +5 -0
  78. package/dist/esm/data/transformers/match-set.js +44 -0
  79. package/dist/esm/data/transformers/match.d.ts +5 -0
  80. package/dist/esm/data/transformers/match.js +27 -0
  81. package/dist/esm/data/transformers/performance-stats.d.ts +5 -0
  82. package/dist/esm/data/transformers/performance-stats.js +33 -0
  83. package/dist/esm/data/transformers/player-team.d.ts +3 -0
  84. package/dist/esm/data/transformers/player-team.js +9 -0
  85. package/dist/esm/data/transformers/player.d.ts +5 -0
  86. package/dist/esm/data/transformers/player.js +26 -0
  87. package/dist/esm/data/transformers/rally.d.ts +5 -0
  88. package/dist/esm/data/transformers/rally.js +23 -0
  89. package/dist/esm/data/transformers/role.d.ts +5 -0
  90. package/dist/esm/data/transformers/role.js +23 -0
  91. package/dist/esm/data/transformers/season-match.d.ts +4 -0
  92. package/dist/esm/data/transformers/season-match.js +13 -0
  93. package/dist/esm/data/transformers/season.d.ts +5 -0
  94. package/dist/esm/data/transformers/season.js +39 -0
  95. package/dist/esm/data/transformers/set-position.d.ts +5 -0
  96. package/dist/esm/data/transformers/set-position.js +16 -0
  97. package/dist/esm/data/transformers/stage.d.ts +5 -0
  98. package/dist/esm/data/transformers/stage.js +21 -0
  99. package/dist/esm/data/transformers/team.d.ts +5 -0
  100. package/dist/esm/data/transformers/team.js +28 -0
  101. package/dist/esm/data/transformers/tournament-match.d.ts +5 -0
  102. package/dist/esm/data/transformers/tournament-match.js +19 -0
  103. package/dist/esm/data/transformers/tournament.d.ts +5 -0
  104. package/dist/esm/data/transformers/tournament.js +33 -0
  105. package/dist/esm/data/transformers/trait.d.ts +5 -0
  106. package/dist/esm/data/transformers/trait.js +15 -0
  107. package/dist/esm/index.d.ts +2 -0
  108. package/dist/esm/index.js +2 -0
  109. package/dist/esm/service/coach/coach.d.ts +19 -0
  110. package/dist/esm/service/coach/coach.js +11 -0
  111. package/dist/esm/service/coach/formation.d.ts +31 -0
  112. package/dist/esm/service/coach/formation.js +122 -0
  113. package/dist/esm/service/coach/index.d.ts +2 -0
  114. package/dist/esm/service/coach/index.js +2 -0
  115. package/dist/esm/service/competition/index.d.ts +11 -0
  116. package/dist/esm/service/competition/index.js +12 -0
  117. package/dist/esm/service/competition/iteration.d.ts +10 -0
  118. package/dist/esm/service/competition/iteration.js +8 -0
  119. package/dist/esm/service/competition/league.d.ts +16 -0
  120. package/dist/esm/service/competition/league.js +8 -0
  121. package/dist/esm/service/competition/season.d.ts +23 -0
  122. package/dist/esm/service/competition/season.js +27 -0
  123. package/dist/esm/service/competition/stage.d.ts +11 -0
  124. package/dist/esm/service/competition/stage.js +24 -0
  125. package/dist/esm/service/competition/standing.d.ts +28 -0
  126. package/dist/esm/service/competition/standing.js +76 -0
  127. package/dist/esm/service/competition/tournament-match.d.ts +14 -0
  128. package/dist/esm/service/competition/tournament-match.js +9 -0
  129. package/dist/esm/service/competition/tournament.d.ts +20 -0
  130. package/dist/esm/service/competition/tournament.js +18 -0
  131. package/dist/esm/service/country/country.d.ts +17 -0
  132. package/dist/esm/service/country/country.js +18 -0
  133. package/dist/esm/service/country/index.d.ts +1 -0
  134. package/dist/esm/service/country/index.js +1 -0
  135. package/dist/esm/service/draft/draft-pick.d.ts +14 -0
  136. package/dist/esm/service/draft/draft-pick.js +7 -0
  137. package/dist/esm/service/draft/draft.d.ts +15 -0
  138. package/dist/esm/service/draft/draft.js +8 -0
  139. package/dist/esm/service/draft/index.d.ts +2 -0
  140. package/dist/esm/service/draft/index.js +2 -0
  141. package/dist/esm/service/event/index.d.ts +1 -0
  142. package/dist/esm/service/event/index.js +1 -0
  143. package/dist/esm/service/event/rally-event.d.ts +20 -0
  144. package/dist/esm/service/event/rally-event.js +16 -0
  145. package/dist/esm/service/index.d.ts +9 -0
  146. package/dist/esm/service/index.js +9 -0
  147. package/dist/esm/service/match/court-position.d.ts +21 -0
  148. package/dist/esm/service/match/court-position.js +53 -0
  149. package/dist/esm/service/match/court-target-enum.d.ts +21 -0
  150. package/dist/esm/service/match/court-target-enum.js +54 -0
  151. package/dist/esm/service/match/index.d.ts +7 -0
  152. package/dist/esm/service/match/index.js +7 -0
  153. package/dist/esm/service/match/match-rating.d.ts +35 -0
  154. package/dist/esm/service/match/match-rating.js +61 -0
  155. package/dist/esm/service/match/match-set.d.ts +65 -0
  156. package/dist/esm/service/match/match-set.js +56 -0
  157. package/dist/esm/service/match/match-team.d.ts +7 -0
  158. package/dist/esm/service/match/match-team.js +17 -0
  159. package/dist/esm/service/match/match.d.ts +36 -0
  160. package/dist/esm/service/match/match.js +57 -0
  161. package/dist/esm/service/match/rally.d.ts +22 -0
  162. package/dist/esm/service/match/rally.js +13 -0
  163. package/dist/esm/service/player/index.d.ts +5 -0
  164. package/dist/esm/service/player/index.js +5 -0
  165. package/dist/esm/service/player/performance-stats.d.ts +30 -0
  166. package/dist/esm/service/player/performance-stats.js +34 -0
  167. package/dist/esm/service/player/player.d.ts +46 -0
  168. package/dist/esm/service/player/player.js +84 -0
  169. package/dist/esm/service/player/role.d.ts +17 -0
  170. package/dist/esm/service/player/role.js +42 -0
  171. package/dist/esm/service/player/stats.d.ts +11 -0
  172. package/dist/esm/service/player/stats.js +25 -0
  173. package/dist/esm/service/player/trait.d.ts +21 -0
  174. package/dist/esm/service/player/trait.js +108 -0
  175. package/dist/esm/service/team/index.d.ts +1 -0
  176. package/dist/esm/service/team/index.js +1 -0
  177. package/dist/esm/service/team/team.d.ts +31 -0
  178. package/dist/esm/service/team/team.js +32 -0
  179. package/dist/esm/service/utils/index.d.ts +2 -0
  180. package/dist/esm/service/utils/index.js +2 -0
  181. package/dist/esm/service/utils/object-utils.d.ts +1 -0
  182. package/dist/esm/service/utils/object-utils.js +1 -0
  183. package/dist/esm/service/utils/string-utils.d.ts +2 -0
  184. package/dist/esm/service/utils/string-utils.js +11 -0
  185. package/package.json +1 -1
@@ -0,0 +1,28 @@
1
+ import { Team } from '../../service';
2
+ import { transformFromCoach, transformToCoach, transformToCountry, transformToPlayer } from '.';
3
+ function transformToAttributes(team) {
4
+ return {
5
+ team_id: team.id,
6
+ name: team.name,
7
+ short_name: team.shortName,
8
+ coach_id: team.coach != null ? team.coach.id : undefined,
9
+ country_id: team.country != null ? team.country.id : undefined,
10
+ league_id: team.league != null ? team.league.id : undefined,
11
+ coach: team.coach != null ? transformFromCoach(team.coach) : undefined,
12
+ rating: team.rating
13
+ };
14
+ }
15
+ function transformToObject(team) {
16
+ return new Team({
17
+ id: team.team_id,
18
+ name: team.name,
19
+ shortName: team.short_name,
20
+ country: team.country != null ? transformToCountry(team.country) : undefined,
21
+ coach: team.coach != null ? transformToCoach(team.coach) : undefined,
22
+ roster: team.PlayerTeams == null
23
+ ? []
24
+ : team.PlayerTeams.map((pt) => transformToPlayer(pt.player)),
25
+ rating: team.rating
26
+ });
27
+ }
28
+ export { transformToObject as transformToTeam, transformToAttributes as transformFromTeam };
@@ -0,0 +1,5 @@
1
+ import { TournamentMatch } from '../../service';
2
+ import { CompetitionMatchAttributes, CompetitionMatchModel } from '../models';
3
+ declare function transformToAttributes(tournamentMatch: TournamentMatch, tournamentId: string): CompetitionMatchAttributes;
4
+ declare function transformToObject(model: CompetitionMatchModel): TournamentMatch;
5
+ export { transformToObject as transformToTournamentMatch, transformToAttributes as transformFromTournamentMatch };
@@ -0,0 +1,19 @@
1
+ import { TournamentMatch } from '../../service';
2
+ import { transformFromMatch, transformFromStage, transformToMatch, transformToStage } from '.';
3
+ function transformToAttributes(tournamentMatch, tournamentId) {
4
+ return {
5
+ competition_id: tournamentId,
6
+ match_id: tournamentMatch.match.id,
7
+ index: tournamentMatch.index,
8
+ stage: transformFromStage(tournamentMatch.stage),
9
+ Match: transformFromMatch(tournamentMatch.match)
10
+ };
11
+ }
12
+ function transformToObject(model) {
13
+ return new TournamentMatch({
14
+ stage: transformToStage(model.stage),
15
+ match: transformToMatch(model.Match),
16
+ index: model.index
17
+ });
18
+ }
19
+ export { transformToObject as transformToTournamentMatch, transformToAttributes as transformFromTournamentMatch };
@@ -0,0 +1,5 @@
1
+ import { CompetitionAttributes, CompetitionModel } from '../models';
2
+ import { Tournament } from '../../service';
3
+ declare function transformToAttributes(tournament: Tournament): CompetitionAttributes;
4
+ declare function transformToObject(model: CompetitionModel): Tournament;
5
+ export { transformToObject as transformToTournament, transformToAttributes as transformFromTournament };
@@ -0,0 +1,33 @@
1
+ import { transformFromTournamentMatch, transformToIteration, transformToTeam, transformToTournamentMatch } from '.';
2
+ import { Tournament } from '../../service';
3
+ function transformToAttributes(tournament) {
4
+ const matches = tournament.matches.map((match) => transformFromTournamentMatch(match, tournament.id));
5
+ const teams = tournament.teams.map((team) => ({
6
+ competition_id: tournament.id,
7
+ team_id: team.id
8
+ }));
9
+ const champion = tournament.champion == null
10
+ ? undefined
11
+ : {
12
+ competition_id: tournament.id,
13
+ team_id: tournament.champion?.id
14
+ };
15
+ return {
16
+ competition_id: tournament.id,
17
+ type: 'TOURNAMENT',
18
+ iteration: tournament.iteration.id,
19
+ CompetitionChampion: champion,
20
+ CompetitionMatches: matches,
21
+ CompetitionTeams: teams
22
+ };
23
+ }
24
+ function transformToObject(model) {
25
+ return new Tournament({
26
+ id: model.competition_id,
27
+ iteration: transformToIteration(model.Iteration),
28
+ matches: model.CompetitionMatches != null ? model.CompetitionMatches.map(transformToTournamentMatch) : [],
29
+ teams: model.Teams != null ? model.Teams.map(transformToTeam) : [],
30
+ champion: model.CompetitionChampion != null ? transformToTeam(model.CompetitionChampion.team) : undefined
31
+ });
32
+ }
33
+ export { transformToObject as transformToTournament, transformToAttributes as transformFromTournament };
@@ -0,0 +1,5 @@
1
+ import { Trait } from '../../service';
2
+ import { TraitAttributes, TraitModel } from '../models';
3
+ declare function transformToAttributes(trait: Trait): TraitAttributes;
4
+ declare function transformToObject(model: TraitModel): Trait;
5
+ export { transformToObject as transformToTrait, transformToAttributes as transformFromTrait };
@@ -0,0 +1,15 @@
1
+ import { Trait } from '../../service';
2
+ function transformToAttributes(trait) {
3
+ return {
4
+ trait_id: trait.id,
5
+ name: trait.name
6
+ };
7
+ }
8
+ function transformToObject(model) {
9
+ const trait = Trait.getTraits().find((trait) => trait.id === model.trait_id);
10
+ if (trait == null) {
11
+ throw new Error('TRAIT_NOT_FOUND');
12
+ }
13
+ return trait;
14
+ }
15
+ export { transformToObject as transformToTrait, transformToAttributes as transformFromTrait };
@@ -0,0 +1,2 @@
1
+ export * from './service';
2
+ export * from './data';
@@ -0,0 +1,2 @@
1
+ export * from './service';
2
+ export * from './data';
@@ -0,0 +1,19 @@
1
+ import { Formation } from './formation';
2
+ import { Name } from '../player';
3
+ import { Country } from '../country';
4
+ interface CoachOpts {
5
+ readonly id: string;
6
+ readonly name: Name;
7
+ readonly country: Country;
8
+ readonly formation: Formation;
9
+ readonly substitutionTolerance: number;
10
+ }
11
+ export declare class Coach {
12
+ readonly id: string;
13
+ readonly name: Name;
14
+ readonly country: Country;
15
+ readonly formation: Formation;
16
+ readonly substitutionTolerance: number;
17
+ constructor({ id, name, country, formation, substitutionTolerance }: CoachOpts);
18
+ }
19
+ export {};
@@ -0,0 +1,11 @@
1
+ import { validateUUID } from '../utils';
2
+ export class Coach {
3
+ constructor({ id, name, country, formation, substitutionTolerance }) {
4
+ validateUUID(id);
5
+ this.id = id;
6
+ this.name = name;
7
+ this.country = country;
8
+ this.formation = formation;
9
+ this.substitutionTolerance = substitutionTolerance;
10
+ }
11
+ }
@@ -0,0 +1,31 @@
1
+ import { Role } from '../player';
2
+ import { CourtPosition } from '../match';
3
+ interface PositionRole {
4
+ readonly [CourtPosition.LEFT_FRONT]: Role[];
5
+ readonly [CourtPosition.MIDDLE_FRONT]: Role[];
6
+ readonly [CourtPosition.RIGHT_FRONT]: Role[];
7
+ readonly [CourtPosition.LEFT_BACK]: Role[];
8
+ readonly [CourtPosition.MIDDLE_BACK]: Role[];
9
+ readonly [CourtPosition.RIGHT_BACK]: Role[];
10
+ }
11
+ export interface SubPriority {
12
+ readonly MIDDLE_BLOCKER: number;
13
+ readonly OUTSIDE_HITTER: number;
14
+ readonly OPPOSITE_HITTER: number;
15
+ readonly DEFENSIVE_SPECIALIST: number;
16
+ readonly SETTER: number;
17
+ readonly LIBERO: number;
18
+ }
19
+ export declare class Formation {
20
+ static readonly '5-1': Formation;
21
+ static readonly '4-2': Formation;
22
+ static readonly '6-2': Formation;
23
+ readonly name: string;
24
+ readonly initialRotation: PositionRole;
25
+ readonly base: PositionRole;
26
+ readonly draftingPriorities: Role[][];
27
+ readonly liberoSubPriority: SubPriority;
28
+ private constructor();
29
+ static getFormations(): Formation[];
30
+ }
31
+ export {};
@@ -0,0 +1,122 @@
1
+ import { Role } from '../player';
2
+ import { CourtPosition } from '../match';
3
+ export class Formation {
4
+ constructor({ name, initialRotation, base, draftingPriorities, liberoSubPriority }) {
5
+ this.name = name;
6
+ this.initialRotation = initialRotation;
7
+ this.base = base;
8
+ this.draftingPriorities = draftingPriorities;
9
+ this.liberoSubPriority = liberoSubPriority;
10
+ }
11
+ static getFormations() {
12
+ return [this['4-2'], this['5-1'], this['6-2']];
13
+ }
14
+ }
15
+ Formation['5-1'] = new Formation({
16
+ name: '5-1',
17
+ initialRotation: {
18
+ 1: [Role.SETTER],
19
+ 2: [Role.OUTSIDE_HITTER],
20
+ 3: [Role.MIDDLE_BLOCKER, Role.DEFENSIVE_SPECIALIST],
21
+ 4: [Role.OPPOSITE_HITTER],
22
+ 5: [Role.OUTSIDE_HITTER],
23
+ 6: [Role.MIDDLE_BLOCKER, Role.DEFENSIVE_SPECIALIST]
24
+ },
25
+ base: {
26
+ 1: [Role.OPPOSITE_HITTER, Role.SETTER],
27
+ 2: [Role.OPPOSITE_HITTER],
28
+ 3: [Role.MIDDLE_BLOCKER, Role.DEFENSIVE_SPECIALIST],
29
+ 4: [Role.OUTSIDE_HITTER],
30
+ 5: [Role.OUTSIDE_HITTER],
31
+ 6: [Role.LIBERO, Role.DEFENSIVE_SPECIALIST]
32
+ },
33
+ draftingPriorities: [
34
+ [Role.SETTER, Role.OPPOSITE_HITTER],
35
+ [Role.OPPOSITE_HITTER],
36
+ [Role.MIDDLE_BLOCKER, Role.DEFENSIVE_SPECIALIST],
37
+ [Role.MIDDLE_BLOCKER],
38
+ [Role.OUTSIDE_HITTER],
39
+ [Role.OUTSIDE_HITTER],
40
+ [Role.LIBERO]
41
+ ],
42
+ liberoSubPriority: {
43
+ MIDDLE_BLOCKER: 1,
44
+ OUTSIDE_HITTER: 10,
45
+ OPPOSITE_HITTER: 100,
46
+ DEFENSIVE_SPECIALIST: 1000,
47
+ SETTER: 10000,
48
+ LIBERO: 100000
49
+ }
50
+ });
51
+ Formation['4-2'] = new Formation({
52
+ name: '4-2',
53
+ initialRotation: {
54
+ 1: [Role.MIDDLE_BLOCKER, Role.DEFENSIVE_SPECIALIST],
55
+ 2: [Role.SETTER],
56
+ 3: [Role.OUTSIDE_HITTER],
57
+ 4: [Role.MIDDLE_BLOCKER],
58
+ 5: [Role.SETTER],
59
+ 6: [Role.OPPOSITE_HITTER]
60
+ },
61
+ base: {
62
+ 1: [Role.SETTER],
63
+ 2: [Role.OPPOSITE_HITTER, Role.SETTER],
64
+ 3: [Role.MIDDLE_BLOCKER, Role.DEFENSIVE_SPECIALIST],
65
+ 4: [Role.OUTSIDE_HITTER],
66
+ 5: [Role.OUTSIDE_HITTER],
67
+ 6: [Role.LIBERO, Role.DEFENSIVE_SPECIALIST]
68
+ },
69
+ draftingPriorities: [
70
+ [Role.SETTER, Role.OPPOSITE_HITTER],
71
+ [Role.SETTER],
72
+ [Role.MIDDLE_BLOCKER, Role.DEFENSIVE_SPECIALIST],
73
+ [Role.MIDDLE_BLOCKER],
74
+ [Role.OUTSIDE_HITTER],
75
+ [Role.OUTSIDE_HITTER],
76
+ [Role.LIBERO]
77
+ ],
78
+ liberoSubPriority: {
79
+ MIDDLE_BLOCKER: 1,
80
+ OUTSIDE_HITTER: 10,
81
+ OPPOSITE_HITTER: 100,
82
+ DEFENSIVE_SPECIALIST: 1000,
83
+ SETTER: 10000,
84
+ LIBERO: 100000
85
+ }
86
+ });
87
+ Formation['6-2'] = new Formation({
88
+ name: '6-2',
89
+ initialRotation: {
90
+ 1: [Role.OPPOSITE_HITTER, Role.SETTER],
91
+ 2: [Role.OUTSIDE_HITTER],
92
+ 3: [Role.MIDDLE_BLOCKER, Role.DEFENSIVE_SPECIALIST],
93
+ 4: [Role.OPPOSITE_HITTER, Role.SETTER],
94
+ 5: [Role.OUTSIDE_HITTER],
95
+ 6: [Role.MIDDLE_BLOCKER]
96
+ },
97
+ base: {
98
+ 1: [Role.SETTER],
99
+ 2: [Role.OPPOSITE_HITTER, Role.SETTER],
100
+ 3: [Role.MIDDLE_BLOCKER, Role.DEFENSIVE_SPECIALIST],
101
+ 4: [Role.OUTSIDE_HITTER],
102
+ 5: [Role.OUTSIDE_HITTER],
103
+ 6: [Role.LIBERO, Role.DEFENSIVE_SPECIALIST]
104
+ },
105
+ draftingPriorities: [
106
+ [Role.SETTER, Role.OPPOSITE_HITTER],
107
+ [Role.OPPOSITE_HITTER, Role.SETTER],
108
+ [Role.MIDDLE_BLOCKER, Role.DEFENSIVE_SPECIALIST],
109
+ [Role.DEFENSIVE_SPECIALIST, Role.MIDDLE_BLOCKER],
110
+ [Role.OUTSIDE_HITTER],
111
+ [Role.OUTSIDE_HITTER],
112
+ [Role.LIBERO]
113
+ ],
114
+ liberoSubPriority: {
115
+ MIDDLE_BLOCKER: 1,
116
+ OUTSIDE_HITTER: 10,
117
+ OPPOSITE_HITTER: 100,
118
+ DEFENSIVE_SPECIALIST: 1000,
119
+ SETTER: 10000,
120
+ LIBERO: 100000
121
+ }
122
+ });
@@ -0,0 +1,2 @@
1
+ export * from './coach';
2
+ export * from './formation';
@@ -0,0 +1,2 @@
1
+ export * from './coach';
2
+ export * from './formation';
@@ -0,0 +1,11 @@
1
+ export * from './standing';
2
+ export * from './season';
3
+ export * from './league';
4
+ export * from './iteration';
5
+ export * from './tournament';
6
+ export * from './tournament-match';
7
+ export * from './stage';
8
+ export declare enum _CompetitionType {
9
+ TOURNAMENT = "TOURNAMENT",
10
+ LEAGUE = "LEAGUE"
11
+ }
@@ -0,0 +1,12 @@
1
+ export * from './standing';
2
+ export * from './season';
3
+ export * from './league';
4
+ export * from './iteration';
5
+ export * from './tournament';
6
+ export * from './tournament-match';
7
+ export * from './stage';
8
+ export var _CompetitionType;
9
+ (function (_CompetitionType) {
10
+ _CompetitionType["TOURNAMENT"] = "TOURNAMENT";
11
+ _CompetitionType["LEAGUE"] = "LEAGUE";
12
+ })(_CompetitionType || (_CompetitionType = {}));
@@ -0,0 +1,10 @@
1
+ interface IterationOpts {
2
+ readonly id: number;
3
+ readonly startDate: Date;
4
+ }
5
+ export declare class Iteration {
6
+ readonly id: number;
7
+ readonly startDate: Date;
8
+ constructor({ id, startDate }: IterationOpts);
9
+ }
10
+ export {};
@@ -0,0 +1,8 @@
1
+ export class Iteration {
2
+ constructor({ id, startDate }) {
3
+ if (id < 1)
4
+ throw new Error(`INVALID_ITERATION: ${id}`);
5
+ this.id = id;
6
+ this.startDate = startDate;
7
+ }
8
+ }
@@ -0,0 +1,16 @@
1
+ import { Season } from './season';
2
+ import { Country } from '../country';
3
+ interface LeagueOpts {
4
+ readonly id: string;
5
+ readonly name: string;
6
+ readonly country: Country;
7
+ readonly seasons: Season[];
8
+ }
9
+ export declare class League {
10
+ readonly id: string;
11
+ readonly name: string;
12
+ readonly seasons: Season[];
13
+ readonly country: Country;
14
+ constructor({ id, name, country, seasons }: LeagueOpts);
15
+ }
16
+ export {};
@@ -0,0 +1,8 @@
1
+ export class League {
2
+ constructor({ id, name, country, seasons }) {
3
+ this.id = id;
4
+ this.name = name;
5
+ this.country = country;
6
+ this.seasons = seasons;
7
+ }
8
+ }
@@ -0,0 +1,23 @@
1
+ import { Team } from '../team';
2
+ import { Match } from '../match';
3
+ import { Standing } from './standing';
4
+ import { Iteration } from './iteration';
5
+ interface SeasonOpts {
6
+ readonly id: string;
7
+ readonly teams: Team[];
8
+ readonly matches: Match[];
9
+ readonly iteration: Iteration;
10
+ readonly champion?: Team;
11
+ }
12
+ export declare class Season {
13
+ readonly id: string;
14
+ readonly teams: Team[];
15
+ readonly matches: Match[];
16
+ readonly iteration: Iteration;
17
+ readonly standings: Standing[];
18
+ champion?: Team;
19
+ constructor({ id, iteration, teams, matches, champion }: SeasonOpts);
20
+ calculateStandings(): Standing[];
21
+ updateStandings(): void;
22
+ }
23
+ export {};
@@ -0,0 +1,27 @@
1
+ import { Standing } from './standing';
2
+ export class Season {
3
+ constructor({ id, iteration, teams, matches, champion }) {
4
+ this.id = id;
5
+ this.teams = teams;
6
+ this.matches = matches;
7
+ this.iteration = iteration;
8
+ this.champion = champion;
9
+ this.standings = this.calculateStandings();
10
+ }
11
+ calculateStandings() {
12
+ return this.teams.map(team => {
13
+ const standing = new Standing({ team });
14
+ standing.calculateStanding(this.matches);
15
+ return standing;
16
+ }).sort(Standing.sortFn);
17
+ }
18
+ updateStandings() {
19
+ if (this.matches == null || this.matches.length < 1)
20
+ throw new Error('NO_MATCHES');
21
+ this.standings.length = 0;
22
+ this.standings.push(...this.calculateStandings());
23
+ if (this.matches.every((match) => match.isOver())) {
24
+ this.champion = this.standings[0].team;
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,11 @@
1
+ export declare enum Stage {
2
+ ROUND_OF_8 = 8,
3
+ QUARTERFINALS = 4,
4
+ SEMIFINALS = 2,
5
+ FINAL = 1,
6
+ LEAGUE = 0
7
+ }
8
+ export declare namespace Stage {
9
+ function getStages(): Stage[];
10
+ function getNextStage(stage: Stage): Stage;
11
+ }
@@ -0,0 +1,24 @@
1
+ export var Stage;
2
+ (function (Stage) {
3
+ Stage[Stage["ROUND_OF_8"] = 8] = "ROUND_OF_8";
4
+ Stage[Stage["QUARTERFINALS"] = 4] = "QUARTERFINALS";
5
+ Stage[Stage["SEMIFINALS"] = 2] = "SEMIFINALS";
6
+ Stage[Stage["FINAL"] = 1] = "FINAL";
7
+ Stage[Stage["LEAGUE"] = 0] = "LEAGUE";
8
+ })(Stage || (Stage = {}));
9
+ // eslint-disable-next-line @typescript-eslint/no-namespace
10
+ (function (Stage) {
11
+ const STAGES = [Stage.ROUND_OF_8, Stage.QUARTERFINALS, Stage.SEMIFINALS, Stage.FINAL, Stage.LEAGUE];
12
+ function getStages() {
13
+ return [...STAGES];
14
+ }
15
+ Stage.getStages = getStages;
16
+ function getNextStage(stage) {
17
+ if (stage < 1)
18
+ throw new Error(`INVALID_STAGE ${stage}`);
19
+ if (stage === 1)
20
+ throw new Error('ALREADY_IN_FINAL_STAGE');
21
+ return stage / 2;
22
+ }
23
+ Stage.getNextStage = getNextStage;
24
+ })(Stage || (Stage = {}));
@@ -0,0 +1,28 @@
1
+ import { Match } from '../match';
2
+ import { Team } from '../team';
3
+ interface StandingOpts {
4
+ readonly team: Team;
5
+ }
6
+ export declare class Standing {
7
+ readonly team: Team;
8
+ won30: number;
9
+ won31: number;
10
+ won32: number;
11
+ lost03: number;
12
+ lost13: number;
13
+ lost23: number;
14
+ pointsWon: number;
15
+ pointsLost: number;
16
+ points: number;
17
+ pointsRatio: number;
18
+ setsWon: number;
19
+ setsLost: number;
20
+ setsRatio: number;
21
+ matchesWon: number;
22
+ matchesLost: number;
23
+ totalMatches: number;
24
+ constructor({ team }: StandingOpts);
25
+ static sortFn(standingA: Standing, standingB: Standing): number;
26
+ calculateStanding(matches: Match[]): void;
27
+ }
28
+ export {};
@@ -0,0 +1,76 @@
1
+ import { MatchTeam } from '../match';
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;
21
+ }
22
+ static sortFn(standingA, standingB) {
23
+ if (standingB.points > standingA.points)
24
+ return 1;
25
+ else if (standingA.points > standingB.points)
26
+ return -1;
27
+ else if (standingB.setsRatio > standingA.setsRatio)
28
+ return 1;
29
+ else if (standingA.setsRatio > standingB.setsRatio)
30
+ return -1;
31
+ else if (standingB.pointsRatio > standingA.pointsRatio)
32
+ return 1;
33
+ else if (standingA.pointsRatio > standingB.pointsRatio)
34
+ return -1;
35
+ else
36
+ return 0;
37
+ }
38
+ calculateStanding(matches) {
39
+ matches = matches.filter(match => match.homeTeam.id === this.team.id || match.awayTeam.id === this.team.id)
40
+ .filter(match => match.isOver());
41
+ let teamSide;
42
+ let otherSide;
43
+ let teamScore;
44
+ let otherScore;
45
+ for (const match of matches) {
46
+ if (this.team.id === match.homeTeam.id) {
47
+ teamSide = MatchTeam.HOME;
48
+ otherSide = MatchTeam.AWAY;
49
+ }
50
+ else {
51
+ teamSide = MatchTeam.AWAY;
52
+ otherSide = MatchTeam.HOME;
53
+ }
54
+ if (match.getWinner().id === this.team.id) {
55
+ this[`won3${match.getTeamSets(otherSide)}`]++;
56
+ }
57
+ else {
58
+ this[`lost${match.getTeamSets(teamSide)}3`]++;
59
+ }
60
+ teamScore = `${teamSide === MatchTeam.HOME ? 'home' : 'away'}Score`;
61
+ otherScore = `${otherSide === MatchTeam.HOME ? 'home' : 'away'}Score`;
62
+ for (const set of match.sets) {
63
+ this.pointsWon += set[teamScore];
64
+ this.pointsLost += set[otherScore];
65
+ }
66
+ }
67
+ this.points = (this.won30 + this.won31) * 3 + this.won32 * 2 + this.lost23;
68
+ this.pointsRatio = this.pointsWon / this.pointsLost;
69
+ this.setsWon = (this.won32 + this.won31 + this.won30) * 3 + this.lost23 * 2 + this.lost13;
70
+ this.setsLost = (this.lost03 + this.lost13 + this.lost23) * 3 + this.won32 * 2 + this.won31;
71
+ this.setsRatio = this.setsWon / this.setsLost;
72
+ this.matchesWon = this.won32 + this.won31 + this.won30;
73
+ this.matchesLost = this.lost03 + this.lost13 + this.lost23;
74
+ this.totalMatches = this.matchesWon + this.matchesLost;
75
+ }
76
+ }
@@ -0,0 +1,14 @@
1
+ import { Match } from '../match';
2
+ import { Stage } from './stage';
3
+ interface TournamentStageOpts {
4
+ readonly stage: Stage;
5
+ readonly match: Match;
6
+ readonly index: number;
7
+ }
8
+ export declare class TournamentMatch {
9
+ readonly stage: Stage;
10
+ readonly match: Match;
11
+ readonly index: number;
12
+ constructor({ stage, match, index }: TournamentStageOpts);
13
+ }
14
+ export {};
@@ -0,0 +1,9 @@
1
+ export class TournamentMatch {
2
+ constructor({ stage, match, index }) {
3
+ if (index > stage || index < 0)
4
+ throw new Error('INDEX_OUT_OF_BOUNDS');
5
+ this.stage = stage;
6
+ this.match = match;
7
+ this.index = index;
8
+ }
9
+ }
@@ -0,0 +1,20 @@
1
+ import { TournamentMatch } from './tournament-match';
2
+ import { Team } from '../team';
3
+ import { Iteration } from './iteration';
4
+ interface TournamentOpts {
5
+ readonly id: string;
6
+ readonly iteration: Iteration;
7
+ readonly matches: TournamentMatch[];
8
+ readonly teams: Team[];
9
+ readonly champion?: Team;
10
+ }
11
+ export declare class Tournament {
12
+ readonly id: string;
13
+ readonly iteration: Iteration;
14
+ readonly matches: TournamentMatch[];
15
+ readonly teams: Team[];
16
+ champion?: Team;
17
+ constructor({ id, iteration, matches, teams, champion }: TournamentOpts);
18
+ static sortMatchesFn(m1: TournamentMatch, m2: TournamentMatch): number;
19
+ }
20
+ export {};
@@ -0,0 +1,18 @@
1
+ export class Tournament {
2
+ constructor({ id, iteration, matches, teams, champion }) {
3
+ this.id = id;
4
+ this.iteration = iteration;
5
+ this.matches = matches;
6
+ this.teams = teams;
7
+ this.champion = champion;
8
+ this.matches.sort(Tournament.sortMatchesFn);
9
+ }
10
+ static sortMatchesFn(m1, m2) {
11
+ if (m1.stage > m2.stage)
12
+ return -1;
13
+ else if (m1.stage < m2.stage)
14
+ return 1;
15
+ else
16
+ return m1.index - m2.index;
17
+ }
18
+ }