volleyballsimtypes 0.0.73 → 0.0.75

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 (55) hide show
  1. package/dist/cjs/src/data/init-models.js +2 -2
  2. package/dist/cjs/src/data/models/player.d.ts +22 -22
  3. package/dist/cjs/src/data/models/team.d.ts +0 -1
  4. package/dist/cjs/src/data/transformers/team.js +2 -2
  5. package/dist/cjs/src/service/coach/formation.d.ts +6 -6
  6. package/dist/cjs/src/service/coach/formation.js +1 -1
  7. package/dist/cjs/src/service/coach/index.d.ts +2 -3
  8. package/dist/cjs/src/service/coach/index.js +16 -5
  9. package/dist/cjs/src/service/competition/index.d.ts +7 -8
  10. package/dist/cjs/src/service/competition/index.js +21 -15
  11. package/dist/cjs/src/service/country/index.d.ts +1 -2
  12. package/dist/cjs/src/service/country/index.js +15 -3
  13. package/dist/cjs/src/service/draft/index.d.ts +2 -3
  14. package/dist/cjs/src/service/draft/index.js +16 -5
  15. package/dist/cjs/src/service/event/index.d.ts +10 -11
  16. package/dist/cjs/src/service/event/index.js +24 -33
  17. package/dist/cjs/src/service/index.d.ts +9 -10
  18. package/dist/cjs/src/service/index.js +23 -68
  19. package/dist/cjs/src/service/match/index.d.ts +7 -8
  20. package/dist/cjs/src/service/match/index.js +21 -18
  21. package/dist/cjs/src/service/player/index.d.ts +5 -6
  22. package/dist/cjs/src/service/player/index.js +19 -11
  23. package/dist/cjs/src/service/player/role.d.ts +13 -11
  24. package/dist/cjs/src/service/player/role.js +32 -20
  25. package/dist/cjs/src/service/player/trait.js +12 -5
  26. package/dist/cjs/src/service/team/index.d.ts +1 -2
  27. package/dist/cjs/src/service/team/index.js +15 -3
  28. package/dist/esm/src/data/init-models.js +2 -2
  29. package/dist/esm/src/data/models/player.d.ts +22 -22
  30. package/dist/esm/src/data/models/team.d.ts +0 -1
  31. package/dist/esm/src/data/transformers/team.js +2 -2
  32. package/dist/esm/src/service/coach/formation.d.ts +6 -6
  33. package/dist/esm/src/service/coach/formation.js +1 -1
  34. package/dist/esm/src/service/coach/index.d.ts +2 -3
  35. package/dist/esm/src/service/coach/index.js +2 -3
  36. package/dist/esm/src/service/competition/index.d.ts +7 -8
  37. package/dist/esm/src/service/competition/index.js +7 -8
  38. package/dist/esm/src/service/country/index.d.ts +1 -2
  39. package/dist/esm/src/service/country/index.js +1 -2
  40. package/dist/esm/src/service/draft/index.d.ts +2 -3
  41. package/dist/esm/src/service/draft/index.js +2 -3
  42. package/dist/esm/src/service/event/index.d.ts +10 -11
  43. package/dist/esm/src/service/event/index.js +10 -11
  44. package/dist/esm/src/service/index.d.ts +9 -10
  45. package/dist/esm/src/service/index.js +9 -10
  46. package/dist/esm/src/service/match/index.d.ts +7 -8
  47. package/dist/esm/src/service/match/index.js +7 -8
  48. package/dist/esm/src/service/player/index.d.ts +5 -6
  49. package/dist/esm/src/service/player/index.js +5 -6
  50. package/dist/esm/src/service/player/role.d.ts +13 -11
  51. package/dist/esm/src/service/player/role.js +31 -20
  52. package/dist/esm/src/service/player/trait.js +12 -5
  53. package/dist/esm/src/service/team/index.d.ts +1 -2
  54. package/dist/esm/src/service/team/index.js +1 -2
  55. package/package.json +1 -1
@@ -1,13 +1,15 @@
1
1
  import { PerformanceStats } from './performance-stats';
2
- export declare enum Role {
3
- SETTER = "Setter",
4
- LIBERO = "Libero",
5
- OUTSIDE_HITTER = "Outside Hitter",
6
- OPPOSITE_HITTER = "Opposite Hitter",
7
- MIDDLE_BLOCKER = "Middle Blocker",
8
- DEFENSIVE_SPECIALIST = "Defensive Specialist"
9
- }
10
- export declare namespace Role {
11
- function getRoles(): Role[];
12
- function calculateScore(stats: PerformanceStats, role: Role): number;
2
+ export declare class Role {
3
+ readonly name: string;
4
+ static readonly SETTER: Role;
5
+ static readonly LIBERO: Role;
6
+ static readonly OUTSIDE_HITTER: Role;
7
+ static readonly OPPOSITE_HITTER: Role;
8
+ static readonly MIDDLE_BLOCKER: Role;
9
+ static readonly DEFENSIVE_SPECIALIST: Role;
10
+ private static readonly ROLES;
11
+ private constructor();
12
+ static getRoles(): Role[];
13
+ static calculateScore(stats: PerformanceStats, role: Role): number;
14
+ static assignRoles(stats: PerformanceStats): Role[];
13
15
  }
@@ -5,30 +5,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Role = void 0;
7
7
  const role_formula_json_1 = __importDefault(require("../../../data/role.formula.json"));
8
- var Role;
9
- (function (Role) {
10
- Role["SETTER"] = "Setter";
11
- Role["LIBERO"] = "Libero";
12
- Role["OUTSIDE_HITTER"] = "Outside Hitter";
13
- Role["OPPOSITE_HITTER"] = "Opposite Hitter";
14
- Role["MIDDLE_BLOCKER"] = "Middle Blocker";
15
- Role["DEFENSIVE_SPECIALIST"] = "Defensive Specialist";
16
- })(Role = exports.Role || (exports.Role = {}));
17
- // eslint-disable-next-line @typescript-eslint/no-namespace
18
- (function (Role) {
19
- const ROLES = [Role.LIBERO, Role.SETTER, Role.OPPOSITE_HITTER, Role.OUTSIDE_HITTER, Role.MIDDLE_BLOCKER,
20
- Role.DEFENSIVE_SPECIALIST];
21
- function getRoles() {
22
- return [...ROLES];
8
+ class Role {
9
+ constructor(name) {
10
+ this.name = name;
23
11
  }
24
- Role.getRoles = getRoles;
25
- function calculateScore(stats, role) {
26
- const weights = role_formula_json_1.default.find(r => r.role === role);
12
+ static getRoles() {
13
+ return [...Role.ROLES];
14
+ }
15
+ static calculateScore(stats, role) {
16
+ const weights = role_formula_json_1.default.find(r => r.role === role.name);
27
17
  if (weights == null)
28
18
  throw new Error('COULD_NOT_FIND_ROLE_WEIGHT');
29
19
  const score = Object.entries(weights.weight)
30
20
  .reduce((score, [key, value]) => score + (stats[key] * weights.weight[key]), 0);
31
21
  return Math.round(score);
32
22
  }
33
- Role.calculateScore = calculateScore;
34
- })(Role = exports.Role || (exports.Role = {}));
23
+ static assignRoles(stats) {
24
+ const scores = this.getRoles().map(role => ({
25
+ role,
26
+ score: this.calculateScore(stats, role)
27
+ })).sort((x, y) => y.score - x.score);
28
+ const out = [scores[0].role];
29
+ if (scores[1].score >= 60) {
30
+ out.push(scores[1].role);
31
+ }
32
+ if (scores[2].score >= 70) {
33
+ out.push(scores[2].role);
34
+ }
35
+ return out;
36
+ }
37
+ }
38
+ exports.Role = Role;
39
+ Role.SETTER = new Role('Setter');
40
+ Role.LIBERO = new Role('Libero');
41
+ Role.OUTSIDE_HITTER = new Role('Outside Hitter');
42
+ Role.OPPOSITE_HITTER = new Role('Opposite Hitter');
43
+ Role.MIDDLE_BLOCKER = new Role('Middle Blocker');
44
+ Role.DEFENSIVE_SPECIALIST = new Role('Defensive Specialist');
45
+ Role.ROLES = [Role.LIBERO, Role.SETTER, Role.OPPOSITE_HITTER, Role.OUTSIDE_HITTER, Role.MIDDLE_BLOCKER,
46
+ Role.DEFENSIVE_SPECIALIST];
@@ -41,15 +41,18 @@ class Trait {
41
41
  }
42
42
  }
43
43
  exports.Trait = Trait;
44
+ // A Setter gets a bonus to their score and the receiving attacker gets a bonus as well.
45
+ // Stacks with attacker bonus
44
46
  Trait.MASTER_MIND = new Trait({
45
47
  name: 'Master Mind',
46
48
  roles: [role_1.Role.SETTER],
47
49
  modifier: 1.25,
48
- chance: 0.15,
50
+ chance: 0.25,
49
51
  statThreshold: 80,
50
52
  stat: stats_1.GeneralStat.ATTACK,
51
53
  weight: 10
52
54
  });
55
+ // Will always participate in blocking regardless of chance
53
56
  Trait.MOVING_WALL = new Trait({
54
57
  name: 'Moving Wall',
55
58
  roles: [role_1.Role.MIDDLE_BLOCKER, role_1.Role.DEFENSIVE_SPECIALIST],
@@ -59,6 +62,7 @@ Trait.MOVING_WALL = new Trait({
59
62
  stat: stats_1.GeneralStat.DEFENSE,
60
63
  weight: 5
61
64
  });
65
+ // On attack, will always pick the worst receiver
62
66
  Trait.MARKSMAN = new Trait({
63
67
  name: 'Marksman',
64
68
  roles: [role_1.Role.OUTSIDE_HITTER, role_1.Role.OPPOSITE_HITTER, role_1.Role.SETTER],
@@ -68,15 +72,17 @@ Trait.MARKSMAN = new Trait({
68
72
  stat: stats_1.GeneralStat.ATTACK,
69
73
  weight: 5
70
74
  });
75
+ // Increases the score of the serve by 25% when serve type is Jumping.
71
76
  Trait.METEOR_SERVE = new Trait({
72
77
  name: 'Meteor Serve',
73
78
  roles: [role_1.Role.OUTSIDE_HITTER, role_1.Role.OPPOSITE_HITTER, role_1.Role.SETTER, role_1.Role.DEFENSIVE_SPECIALIST, role_1.Role.MIDDLE_BLOCKER],
74
- modifier: 1.33,
75
- chance: 0.25,
79
+ modifier: 1.25,
80
+ chance: 0.1,
76
81
  statThreshold: 75,
77
82
  stat: stats_1.GeneralStat.SERVE,
78
83
  weight: 10
79
84
  });
85
+ // Has a 50% chance of taking an action without decreasing energy.
80
86
  Trait.VIGOROUS = new Trait({
81
87
  name: 'Vigorous',
82
88
  roles: [],
@@ -86,12 +92,13 @@ Trait.VIGOROUS = new Trait({
86
92
  stat: stats_1.GeneralStat.PHYSICAL,
87
93
  weight: 1
88
94
  });
95
+ // Takes place of the receiver and increases reception score by 25%. Can only trigger in back-row.
89
96
  Trait.GUARDIAN = new Trait({
90
97
  name: 'Guardian',
91
98
  roles: [role_1.Role.DEFENSIVE_SPECIALIST, role_1.Role.LIBERO],
92
- chance: 0.33,
99
+ chance: 0.25,
93
100
  statThreshold: 75,
94
- modifier: 1.2,
101
+ modifier: 1.25,
95
102
  stat: stats_1.GeneralStat.DEFENSE,
96
103
  weight: 10
97
104
  });
@@ -1,2 +1 @@
1
- import { Team } from './team';
2
- export { Team };
1
+ export * from './team';
@@ -1,5 +1,17 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Team = void 0;
4
- const team_1 = require("./team");
5
- Object.defineProperty(exports, "Team", { enumerable: true, get: function () { return team_1.Team; } });
17
+ __exportStar(require("./team"), exports);
@@ -102,8 +102,8 @@ export function initModels(sequelize) {
102
102
  Player.hasMany(Serve, { as: 'Serves', foreignKey: 'player_id' });
103
103
  Player.hasMany(Set, { as: 'Sets', foreignKey: 'player_id' });
104
104
  Player.hasMany(Spike, { as: 'Spikes', foreignKey: 'player_id' });
105
- Player.hasMany(Substitution, { as: 'Substitutions', foreignKey: 'player_out' });
106
- Player.hasMany(Substitution, { as: 'player_Substitutions', foreignKey: 'player_id' });
105
+ Player.hasMany(Substitution, { as: 'OutSubstitutions', foreignKey: 'player_out' });
106
+ Player.hasMany(Substitution, { as: 'InSubstitutions', foreignKey: 'player_id' });
107
107
  Player.hasOne(PerformanceStats, { as: 'PerformanceStat', foreignKey: 'player_id' });
108
108
  Player.hasOne(DraftPick, { as: 'DraftPick', foreignKey: 'player_id' });
109
109
  Player.hasOne(PlayerTeam, { as: 'PlayerTeam', foreignKey: 'player_id' });
@@ -238,27 +238,27 @@ export declare class PlayerModel extends Model<PlayerAttributes, PlayerCreationA
238
238
  hasSpike: Sequelize.HasManyHasAssociationMixin<SpikeModel, SpikeId>;
239
239
  hasSpikes: Sequelize.HasManyHasAssociationsMixin<SpikeModel, SpikeId>;
240
240
  countSpikes: Sequelize.HasManyCountAssociationsMixin;
241
- Substitutions: SubstitutionModel[];
242
- getSubstitutions: Sequelize.HasManyGetAssociationsMixin<SubstitutionModel>;
243
- setSubstitutions: Sequelize.HasManySetAssociationsMixin<SubstitutionModel, SubstitutionId>;
244
- addSubstitution: Sequelize.HasManyAddAssociationMixin<SubstitutionModel, SubstitutionId>;
245
- addSubstitutions: Sequelize.HasManyAddAssociationsMixin<SubstitutionModel, SubstitutionId>;
246
- createSubstitution: Sequelize.HasManyCreateAssociationMixin<SubstitutionModel>;
247
- removeSubstitution: Sequelize.HasManyRemoveAssociationMixin<SubstitutionModel, SubstitutionId>;
248
- removeSubstitutions: Sequelize.HasManyRemoveAssociationsMixin<SubstitutionModel, SubstitutionId>;
249
- hasSubstitution: Sequelize.HasManyHasAssociationMixin<SubstitutionModel, SubstitutionId>;
250
- hasSubstitutions: Sequelize.HasManyHasAssociationsMixin<SubstitutionModel, SubstitutionId>;
251
- countSubstitutions: Sequelize.HasManyCountAssociationsMixin;
252
- player_Substitutions: SubstitutionModel[];
253
- getPlayer_Substitutions: Sequelize.HasManyGetAssociationsMixin<SubstitutionModel>;
254
- setPlayer_Substitutions: Sequelize.HasManySetAssociationsMixin<SubstitutionModel, SubstitutionId>;
255
- addPlayer_Substitution: Sequelize.HasManyAddAssociationMixin<SubstitutionModel, SubstitutionId>;
256
- addPlayer_Substitutions: Sequelize.HasManyAddAssociationsMixin<SubstitutionModel, SubstitutionId>;
257
- createPlayer_Substitution: Sequelize.HasManyCreateAssociationMixin<SubstitutionModel>;
258
- removePlayer_Substitution: Sequelize.HasManyRemoveAssociationMixin<SubstitutionModel, SubstitutionId>;
259
- removePlayer_Substitutions: Sequelize.HasManyRemoveAssociationsMixin<SubstitutionModel, SubstitutionId>;
260
- hasPlayer_Substitution: Sequelize.HasManyHasAssociationMixin<SubstitutionModel, SubstitutionId>;
261
- hasPlayer_Substitutions: Sequelize.HasManyHasAssociationsMixin<SubstitutionModel, SubstitutionId>;
262
- countPlayer_Substitutions: Sequelize.HasManyCountAssociationsMixin;
241
+ outSubstitutions: SubstitutionModel[];
242
+ getOutSubstitutions: Sequelize.HasManyGetAssociationsMixin<SubstitutionModel>;
243
+ setOutSubstitutions: Sequelize.HasManySetAssociationsMixin<SubstitutionModel, SubstitutionId>;
244
+ addOutSubstitution: Sequelize.HasManyAddAssociationMixin<SubstitutionModel, SubstitutionId>;
245
+ addOutSubstitutions: Sequelize.HasManyAddAssociationsMixin<SubstitutionModel, SubstitutionId>;
246
+ createOutSubstitution: Sequelize.HasManyCreateAssociationMixin<SubstitutionModel>;
247
+ removeOutSubstitution: Sequelize.HasManyRemoveAssociationMixin<SubstitutionModel, SubstitutionId>;
248
+ removeOutSubstitutions: Sequelize.HasManyRemoveAssociationsMixin<SubstitutionModel, SubstitutionId>;
249
+ hasOutSubstitution: Sequelize.HasManyHasAssociationMixin<SubstitutionModel, SubstitutionId>;
250
+ hasOutSubstitutions: Sequelize.HasManyHasAssociationsMixin<SubstitutionModel, SubstitutionId>;
251
+ countOutSubstitutions: Sequelize.HasManyCountAssociationsMixin;
252
+ InSubstitutions: SubstitutionModel[];
253
+ getInSubstitutions: Sequelize.HasManyGetAssociationsMixin<SubstitutionModel>;
254
+ setInSubstitutions: Sequelize.HasManySetAssociationsMixin<SubstitutionModel, SubstitutionId>;
255
+ addInSubstitution: Sequelize.HasManyAddAssociationMixin<SubstitutionModel, SubstitutionId>;
256
+ addInSubstitutions: Sequelize.HasManyAddAssociationsMixin<SubstitutionModel, SubstitutionId>;
257
+ createInSubstitution: Sequelize.HasManyCreateAssociationMixin<SubstitutionModel>;
258
+ removeInSubstitution: Sequelize.HasManyRemoveAssociationMixin<SubstitutionModel, SubstitutionId>;
259
+ removeInSubstitutions: Sequelize.HasManyRemoveAssociationsMixin<SubstitutionModel, SubstitutionId>;
260
+ hasInSubstitution: Sequelize.HasManyHasAssociationMixin<SubstitutionModel, SubstitutionId>;
261
+ hasInSubstitutions: Sequelize.HasManyHasAssociationsMixin<SubstitutionModel, SubstitutionId>;
262
+ countInSubstitutions: Sequelize.HasManyCountAssociationsMixin;
263
263
  static initModel(sequelize: Sequelize.Sequelize): typeof PlayerModel;
264
264
  }
@@ -26,7 +26,6 @@ export declare class TeamModel extends Model<TeamAttributes, TeamCreationAttribu
26
26
  league_id: string;
27
27
  country_id: string;
28
28
  coach: CoachModel;
29
- Players: PlayerModel[];
30
29
  getCoach: Sequelize.BelongsToGetAssociationMixin<CoachModel>;
31
30
  setCoach: Sequelize.BelongsToSetAssociationMixin<CoachModel, CoachId>;
32
31
  createCoach: Sequelize.BelongsToCreateAssociationMixin<CoachModel>;
@@ -19,7 +19,7 @@ function transformToObject(team) {
19
19
  shortName: team.short_name,
20
20
  country: team.country != null ? transformToCountry(team.country) : undefined,
21
21
  coach: team.coach != null ? transformToCoach(team.coach) : undefined,
22
- roster: team.Players != null ? team.Players.map(transformToPlayer) : [],
22
+ roster: team.PlayerTeams != null ? team.PlayerTeams.map(pt => transformToPlayer(pt.player)) : [],
23
23
  rating: team.rating
24
24
  });
25
25
  }
@@ -30,7 +30,7 @@ function transformToAPIObject(team) {
30
30
  shortName: team.short_name,
31
31
  country: team.country != null ? transformToCountry(team.country) : undefined,
32
32
  coach: team.coach != null ? transformToAPICoach(team.coach) : undefined,
33
- roster: team.Players != null ? team.Players.map(transformToAPIPlayer) : []
33
+ roster: team.PlayerTeams != null ? team.PlayerTeams.map(pt => transformToAPIPlayer(pt.player)) : []
34
34
  };
35
35
  }
36
36
  export { transformToObject as transformToTeam, transformToAPIObject as transformToAPITeam, transformToAttributes as transformFromTeam };
@@ -9,12 +9,12 @@ interface PositionRole {
9
9
  readonly [CourtPosition.RIGHT_BACK]: Role[];
10
10
  }
11
11
  export interface SubPriority {
12
- readonly [Role.MIDDLE_BLOCKER]: number;
13
- readonly [Role.LIBERO]: number;
14
- readonly [Role.DEFENSIVE_SPECIALIST]: number;
15
- readonly [Role.OUTSIDE_HITTER]: number;
16
- readonly [Role.OPPOSITE_HITTER]: number;
17
- readonly [Role.SETTER]: number;
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
18
  }
19
19
  export declare class Formation {
20
20
  static readonly '5-1': Formation;
@@ -80,7 +80,7 @@ Formation['4-2'] = new Formation({
80
80
  'Outside Hitter': 10,
81
81
  'Opposite Hitter': 100,
82
82
  'Defensive Specialist': 1000,
83
- [Role.SETTER]: 10000,
83
+ Setter: 10000,
84
84
  Libero: 100000
85
85
  }
86
86
  });
@@ -1,3 +1,2 @@
1
- import { Coach } from './coach';
2
- import { Formation, SubPriority } from './formation';
3
- export { Coach, Formation, SubPriority };
1
+ export * from './coach';
2
+ export * from './formation';
@@ -1,3 +1,2 @@
1
- import { Coach } from './coach';
2
- import { Formation } from './formation';
3
- export { Coach, Formation };
1
+ export * from './coach';
2
+ export * from './formation';
@@ -1,8 +1,7 @@
1
- import { Standing } from './standing';
2
- import { Season } from './season';
3
- import { League } from './league';
4
- import { Iteration } from './iteration';
5
- import { Tournament } from './tournament';
6
- import { TournamentMatch } from './tournament-match';
7
- import { Stage } from './stage';
8
- export { TournamentMatch, Stage, Tournament, Season, Standing, League, Iteration, };
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';
@@ -1,8 +1,7 @@
1
- import { Standing } from './standing';
2
- import { Season } from './season';
3
- import { League } from './league';
4
- import { Iteration } from './iteration';
5
- import { Tournament } from './tournament';
6
- import { TournamentMatch } from './tournament-match';
7
- import { Stage } from './stage';
8
- export { TournamentMatch, Stage, Tournament, Season, Standing, League, Iteration, };
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';
@@ -1,2 +1 @@
1
- import { Country } from './country';
2
- export { Country };
1
+ export * from './country';
@@ -1,2 +1 @@
1
- import { Country } from './country';
2
- export { Country };
1
+ export * from './country';
@@ -1,3 +1,2 @@
1
- import { Draft } from './draft';
2
- import { DraftPick } from './draft-pick';
3
- export { Draft, DraftPick };
1
+ export * from './draft';
2
+ export * from './draft-pick';
@@ -1,3 +1,2 @@
1
- import { Draft } from './draft';
2
- import { DraftPick } from './draft-pick';
3
- export { Draft, DraftPick };
1
+ export * from './draft';
2
+ export * from './draft-pick';
@@ -1,11 +1,10 @@
1
- import { Score } from './score';
2
- import { Set, SetFailure, SetType } from './set';
3
- import { Block, BlockFailure, BlockType } from './block';
4
- import { Serve, ServeFailure, ServeType } from './serve';
5
- import { InPlayEvent, InPlayEventOpts } from './in-play-event';
6
- import { EventType, RallyEvent, RallyEventOpts } from './rally-event';
7
- import { Reception, ReceptionFailure, ReceptionType } from './reception';
8
- import { Spike, SpikeFailure, SpikeType } from './spike';
9
- import { Substitution } from './substitution';
10
- import { LiberoReplacement, LiberoReplacementType } from './libero-replacement';
11
- export { Spike, SpikeFailure, SpikeType, ServeType, Set, SetFailure, SetType, ReceptionFailure, ReceptionType, BlockFailure, BlockType, Block, ServeFailure, Serve, EventType, RallyEvent, RallyEventOpts, InPlayEventOpts, InPlayEvent, Reception, Substitution, LiberoReplacementType, LiberoReplacement, Score };
1
+ export * from './score';
2
+ export * from './set';
3
+ export * from './block';
4
+ export * from './serve';
5
+ export * from './in-play-event';
6
+ export * from './rally-event';
7
+ export * from './reception';
8
+ export * from './spike';
9
+ export * from './substitution';
10
+ export * from './libero-replacement';
@@ -1,11 +1,10 @@
1
- import { Score } from './score';
2
- import { Set, SetFailure, SetType } from './set';
3
- import { Block, BlockFailure, BlockType } from './block';
4
- import { Serve, ServeFailure, ServeType } from './serve';
5
- import { InPlayEvent } from './in-play-event';
6
- import { EventType, RallyEvent } from './rally-event';
7
- import { Reception, ReceptionFailure, ReceptionType } from './reception';
8
- import { Spike, SpikeFailure, SpikeType } from './spike';
9
- import { Substitution } from './substitution';
10
- import { LiberoReplacement, LiberoReplacementType, } from './libero-replacement';
11
- export { Spike, SpikeFailure, SpikeType, ServeType, Set, SetFailure, SetType, ReceptionFailure, ReceptionType, BlockFailure, BlockType, Block, ServeFailure, Serve, EventType, RallyEvent, InPlayEvent, Reception, Substitution, LiberoReplacementType, LiberoReplacement, Score };
1
+ export * from './score';
2
+ export * from './set';
3
+ export * from './block';
4
+ export * from './serve';
5
+ export * from './in-play-event';
6
+ export * from './rally-event';
7
+ export * from './reception';
8
+ export * from './spike';
9
+ export * from './substitution';
10
+ export * from './libero-replacement';
@@ -1,10 +1,9 @@
1
- import { CourtPosition, CourtRow, CourtTarget, EventStat, Match, MatchRating, MatchSet, MatchSetState, MatchTeam, PlayerPosition, Rally, RallyState, SetStatistics } from './match';
2
- import { Coach, Formation, SubPriority } from './coach';
3
- import { Country } from './country';
4
- import { Draft, DraftPick } from './draft';
5
- import { Team } from './team';
6
- import { Block, BlockFailure, BlockType, EventType, InPlayEvent, InPlayEventOpts, LiberoReplacement, LiberoReplacementType, RallyEvent, RallyEventOpts, Reception, ReceptionFailure, ReceptionType, Score, Serve, ServeFailure, ServeType, Set, SetFailure, SetType, Spike, SpikeFailure, SpikeType, Substitution } from './event';
7
- import { GeneralStat, Name, PerformanceStats, Player, Role, Stat, Trait } from './player';
8
- import { Iteration, League, Season, Stage, Standing, Tournament, TournamentMatch } from './competition';
9
- import { formatNumber, generateModifier, getKeys, getRandomEnumValue, randomNumber, shuffle, validateUUID } from './utils';
10
- export { Draft, DraftPick, Stage, TournamentMatch, Tournament, Block, BlockFailure, BlockType, Coach, Country, CourtPosition, CourtRow, CourtTarget, EventStat, EventType, Formation, formatNumber, GeneralStat, generateModifier, getKeys, getRandomEnumValue, InPlayEvent, InPlayEventOpts, League, LiberoReplacement, LiberoReplacementType, Match, MatchSet, MatchRating, MatchSetState, MatchTeam, Name, PerformanceStats, Player, PlayerPosition, Rally, RallyEvent, RallyEventOpts, RallyState, randomNumber, Reception, ReceptionFailure, ReceptionType, Role, Score, Season, Serve, ServeFailure, ServeType, Set, SetFailure, SetStatistics, SetType, shuffle, Spike, SpikeFailure, SpikeType, Standing, Stat, SubPriority, Substitution, Team, Trait, Iteration, validateUUID };
1
+ export * from './match';
2
+ export * from './coach';
3
+ export * from './country';
4
+ export * from './draft';
5
+ export * from './team';
6
+ export * from './event';
7
+ export * from './player';
8
+ export * from './competition';
9
+ export * from './utils';
@@ -1,10 +1,9 @@
1
- import { CourtPosition, CourtRow, CourtTarget, Match, MatchRating, MatchSet, MatchSetState, MatchTeam, Rally, RallyState, } from './match';
2
- import { Coach, Formation } from './coach';
3
- import { Country } from './country';
4
- import { Draft, DraftPick } from './draft';
5
- import { Team } from './team';
6
- import { Block, BlockFailure, BlockType, EventType, InPlayEvent, LiberoReplacement, LiberoReplacementType, RallyEvent, Reception, ReceptionFailure, ReceptionType, Score, Serve, ServeFailure, ServeType, Set, SetFailure, SetType, Spike, SpikeFailure, SpikeType, Substitution } from './event';
7
- import { GeneralStat, PerformanceStats, Player, Role, Trait } from './player';
8
- import { Iteration, League, Season, Stage, Standing, Tournament, TournamentMatch } from './competition';
9
- import { formatNumber, generateModifier, getKeys, getRandomEnumValue, randomNumber, shuffle, validateUUID, } from './utils';
10
- export { Draft, DraftPick, Stage, TournamentMatch, Tournament, Block, BlockFailure, BlockType, Coach, Country, CourtPosition, CourtRow, CourtTarget, EventType, Formation, formatNumber, GeneralStat, generateModifier, getKeys, getRandomEnumValue, InPlayEvent, League, LiberoReplacement, LiberoReplacementType, Match, MatchSet, MatchRating, MatchSetState, MatchTeam, PerformanceStats, Player, Rally, RallyEvent, RallyState, randomNumber, Reception, ReceptionFailure, ReceptionType, Role, Score, Season, Serve, ServeFailure, ServeType, Set, SetFailure, SetType, shuffle, Spike, SpikeFailure, SpikeType, Standing, Substitution, Team, Trait, Iteration, validateUUID };
1
+ export * from './match';
2
+ export * from './coach';
3
+ export * from './country';
4
+ export * from './draft';
5
+ export * from './team';
6
+ export * from './event';
7
+ export * from './player';
8
+ export * from './competition';
9
+ export * from './utils';
@@ -1,8 +1,7 @@
1
- import { Match } from './match';
2
- import { MatchRating } from './match-rating';
3
- import { EventStat, MatchSet, MatchSetState, SetStatistics } from './match-set';
4
- import { PlayerPosition, Rally, RallyState } from './rally';
5
- import { CourtPosition, CourtRow } from './court-position';
6
- import { CourtTarget } from './court-target';
7
- import { MatchTeam } from './match-team';
8
- export { CourtPosition, CourtRow, CourtTarget, EventStat, Match, MatchSet, MatchRating, MatchSetState, MatchTeam, PlayerPosition, Rally, RallyState, SetStatistics, };
1
+ export * from './match';
2
+ export * from './match-rating';
3
+ export * from './match-set';
4
+ export * from './rally';
5
+ export * from './court-position';
6
+ export * from './court-target';
7
+ export * from './match-team';
@@ -1,8 +1,7 @@
1
- import { Match } from './match';
2
- import { MatchRating } from './match-rating';
3
- import { MatchSet, MatchSetState } from './match-set';
4
- import { Rally, RallyState } from './rally';
5
- import { CourtPosition, CourtRow } from './court-position';
6
- import { CourtTarget } from './court-target';
7
- import { MatchTeam } from './match-team';
8
- export { CourtPosition, CourtRow, CourtTarget, Match, MatchSet, MatchRating, MatchSetState, MatchTeam, Rally, RallyState, };
1
+ export * from './match';
2
+ export * from './match-rating';
3
+ export * from './match-set';
4
+ export * from './rally';
5
+ export * from './court-position';
6
+ export * from './court-target';
7
+ export * from './match-team';
@@ -1,6 +1,5 @@
1
- import { Name, Player, Stat } from './player';
2
- import { PerformanceStats } from './performance-stats';
3
- import { Role } from './role';
4
- import { Trait } from './trait';
5
- import { GeneralStat } from './stats';
6
- export { Player, PerformanceStats, GeneralStat, Name, Stat, Role, Trait };
1
+ export * from './player';
2
+ export * from './performance-stats';
3
+ export * from './role';
4
+ export * from './trait';
5
+ export * from './stats';
@@ -1,6 +1,5 @@
1
- import { Player } from './player';
2
- import { PerformanceStats } from './performance-stats';
3
- import { Role } from './role';
4
- import { Trait } from './trait';
5
- import { GeneralStat } from './stats';
6
- export { Player, PerformanceStats, GeneralStat, Role, Trait };
1
+ export * from './player';
2
+ export * from './performance-stats';
3
+ export * from './role';
4
+ export * from './trait';
5
+ export * from './stats';
@@ -1,13 +1,15 @@
1
1
  import { PerformanceStats } from './performance-stats';
2
- export declare enum Role {
3
- SETTER = "Setter",
4
- LIBERO = "Libero",
5
- OUTSIDE_HITTER = "Outside Hitter",
6
- OPPOSITE_HITTER = "Opposite Hitter",
7
- MIDDLE_BLOCKER = "Middle Blocker",
8
- DEFENSIVE_SPECIALIST = "Defensive Specialist"
9
- }
10
- export declare namespace Role {
11
- function getRoles(): Role[];
12
- function calculateScore(stats: PerformanceStats, role: Role): number;
2
+ export declare class Role {
3
+ readonly name: string;
4
+ static readonly SETTER: Role;
5
+ static readonly LIBERO: Role;
6
+ static readonly OUTSIDE_HITTER: Role;
7
+ static readonly OPPOSITE_HITTER: Role;
8
+ static readonly MIDDLE_BLOCKER: Role;
9
+ static readonly DEFENSIVE_SPECIALIST: Role;
10
+ private static readonly ROLES;
11
+ private constructor();
12
+ static getRoles(): Role[];
13
+ static calculateScore(stats: PerformanceStats, role: Role): number;
14
+ static assignRoles(stats: PerformanceStats): Role[];
13
15
  }
@@ -1,28 +1,39 @@
1
1
  import roleWeights from '../../../data/role.formula.json';
2
- export var Role;
3
- (function (Role) {
4
- Role["SETTER"] = "Setter";
5
- Role["LIBERO"] = "Libero";
6
- Role["OUTSIDE_HITTER"] = "Outside Hitter";
7
- Role["OPPOSITE_HITTER"] = "Opposite Hitter";
8
- Role["MIDDLE_BLOCKER"] = "Middle Blocker";
9
- Role["DEFENSIVE_SPECIALIST"] = "Defensive Specialist";
10
- })(Role || (Role = {}));
11
- // eslint-disable-next-line @typescript-eslint/no-namespace
12
- (function (Role) {
13
- const ROLES = [Role.LIBERO, Role.SETTER, Role.OPPOSITE_HITTER, Role.OUTSIDE_HITTER, Role.MIDDLE_BLOCKER,
14
- Role.DEFENSIVE_SPECIALIST];
15
- function getRoles() {
16
- return [...ROLES];
2
+ export class Role {
3
+ constructor(name) {
4
+ this.name = name;
17
5
  }
18
- Role.getRoles = getRoles;
19
- function calculateScore(stats, role) {
20
- const weights = roleWeights.find(r => r.role === role);
6
+ static getRoles() {
7
+ return [...Role.ROLES];
8
+ }
9
+ static calculateScore(stats, role) {
10
+ const weights = roleWeights.find(r => r.role === role.name);
21
11
  if (weights == null)
22
12
  throw new Error('COULD_NOT_FIND_ROLE_WEIGHT');
23
13
  const score = Object.entries(weights.weight)
24
14
  .reduce((score, [key, value]) => score + (stats[key] * weights.weight[key]), 0);
25
15
  return Math.round(score);
26
16
  }
27
- Role.calculateScore = calculateScore;
28
- })(Role || (Role = {}));
17
+ static assignRoles(stats) {
18
+ const scores = this.getRoles().map(role => ({
19
+ role,
20
+ score: this.calculateScore(stats, role)
21
+ })).sort((x, y) => y.score - x.score);
22
+ const out = [scores[0].role];
23
+ if (scores[1].score >= 60) {
24
+ out.push(scores[1].role);
25
+ }
26
+ if (scores[2].score >= 70) {
27
+ out.push(scores[2].role);
28
+ }
29
+ return out;
30
+ }
31
+ }
32
+ Role.SETTER = new Role('Setter');
33
+ Role.LIBERO = new Role('Libero');
34
+ Role.OUTSIDE_HITTER = new Role('Outside Hitter');
35
+ Role.OPPOSITE_HITTER = new Role('Opposite Hitter');
36
+ Role.MIDDLE_BLOCKER = new Role('Middle Blocker');
37
+ Role.DEFENSIVE_SPECIALIST = new Role('Defensive Specialist');
38
+ Role.ROLES = [Role.LIBERO, Role.SETTER, Role.OPPOSITE_HITTER, Role.OUTSIDE_HITTER, Role.MIDDLE_BLOCKER,
39
+ Role.DEFENSIVE_SPECIALIST];