volleyballsimtypes 0.0.200 → 0.0.201

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 (33) hide show
  1. package/dist/cjs/src/data/models/tactics.d.ts +20 -5
  2. package/dist/cjs/src/data/models/tactics.js +16 -4
  3. package/dist/cjs/src/data/models/team.d.ts +1 -1
  4. package/dist/cjs/src/data/models/team.js +1 -6
  5. package/dist/cjs/src/data/transformers/index.d.ts +0 -1
  6. package/dist/cjs/src/data/transformers/index.js +0 -1
  7. package/dist/cjs/src/data/transformers/performance-stats.d.ts +2 -2
  8. package/dist/cjs/src/data/transformers/performance-stats.js +20 -20
  9. package/dist/cjs/src/data/transformers/player.js +1 -1
  10. package/dist/cjs/src/data/transformers/tactics.d.ts +3 -3
  11. package/dist/cjs/src/data/transformers/tactics.js +47 -7
  12. package/dist/cjs/src/data/transformers/team.js +4 -3
  13. package/dist/cjs/src/service/team/tactics.d.ts +20 -6
  14. package/dist/cjs/src/service/team/tactics.js +5 -2
  15. package/dist/esm/src/data/models/tactics.d.ts +20 -5
  16. package/dist/esm/src/data/models/tactics.js +16 -4
  17. package/dist/esm/src/data/models/team.d.ts +1 -1
  18. package/dist/esm/src/data/models/team.js +2 -7
  19. package/dist/esm/src/data/transformers/index.d.ts +0 -1
  20. package/dist/esm/src/data/transformers/index.js +0 -1
  21. package/dist/esm/src/data/transformers/performance-stats.d.ts +2 -2
  22. package/dist/esm/src/data/transformers/performance-stats.js +20 -20
  23. package/dist/esm/src/data/transformers/player.js +1 -1
  24. package/dist/esm/src/data/transformers/tactics.d.ts +3 -3
  25. package/dist/esm/src/data/transformers/tactics.js +48 -8
  26. package/dist/esm/src/data/transformers/team.js +4 -3
  27. package/dist/esm/src/service/team/tactics.d.ts +20 -6
  28. package/dist/esm/src/service/team/tactics.js +5 -2
  29. package/package.json +1 -1
  30. package/dist/cjs/src/data/transformers/formation.d.ts +0 -5
  31. package/dist/cjs/src/data/transformers/formation.js +0 -12
  32. package/dist/esm/src/data/transformers/formation.d.ts +0 -5
  33. package/dist/esm/src/data/transformers/formation.js +0 -8
@@ -1,20 +1,35 @@
1
1
  import * as Sequelize from 'sequelize';
2
2
  import { Model, Optional } from 'sequelize';
3
- import { TeamId, TeamModel } from '.';
3
+ import { PlayerId, TeamId, TeamModel } from '.';
4
+ import { CourtPosition } from '../../service';
5
+ export interface TacticsLineupAttributes {
6
+ [CourtPosition.LIBERO_ZONE]?: PlayerId;
7
+ [CourtPosition.LEFT_BACK]: PlayerId;
8
+ [CourtPosition.LEFT_FRONT]: PlayerId;
9
+ [CourtPosition.MIDDLE_BACK]: PlayerId;
10
+ [CourtPosition.MIDDLE_FRONT]: PlayerId;
11
+ [CourtPosition.RIGHT_BACK]: PlayerId;
12
+ [CourtPosition.RIGHT_FRONT]: PlayerId;
13
+ bench: PlayerId[];
14
+ }
15
+ export type PinchServerSubsAttributes = Record<PlayerId, PlayerId>;
4
16
  export interface TacticsAttributes {
5
17
  team_id: string;
6
- formation: FormationType;
7
18
  substitution_tolerance: number;
19
+ lineup: TacticsLineupAttributes;
20
+ libero_replacements: PlayerId[];
21
+ pinch_server_subs: PinchServerSubsAttributes;
8
22
  }
9
- export type FormationType = '4-2' | '5-1' | '6-2';
10
23
  export type TacticsPk = 'team_id';
11
24
  export type TacticsId = TacticsModel[TacticsPk];
12
- export type TacticsOptionalAttributes = 'substitution_tolerance';
25
+ export type TacticsOptionalAttributes = 'substitution_tolerance' | 'lineup' | 'libero_replacements' | 'pinch_server_subs';
13
26
  export type TacticsCreationAttributes = Optional<TacticsAttributes, TacticsOptionalAttributes>;
14
27
  export declare class TacticsModel extends Model<TacticsAttributes, TacticsCreationAttributes> implements TacticsAttributes {
15
28
  team_id: string;
16
- formation: FormationType;
17
29
  substitution_tolerance: number;
30
+ lineup: TacticsLineupAttributes;
31
+ libero_replacements: PlayerId[];
32
+ pinch_server_subs: PinchServerSubsAttributes;
18
33
  team: TeamModel;
19
34
  getTeam: Sequelize.BelongsToGetAssociationMixin<TeamModel>;
20
35
  setTeam: Sequelize.BelongsToSetAssociationMixin<TeamModel, TeamId>;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TacticsModel = void 0;
4
4
  const sequelize_1 = require("sequelize");
5
+ const service_1 = require("../../service");
5
6
  class TacticsModel extends sequelize_1.Model {
6
7
  static initModel(sequelize) {
7
8
  return TacticsModel.init({
@@ -14,14 +15,25 @@ class TacticsModel extends sequelize_1.Model {
14
15
  key: 'team_id'
15
16
  }
16
17
  },
17
- formation: {
18
- type: sequelize_1.DataTypes.ENUM('4-2', '5-1', '6-2'),
19
- allowNull: false
20
- },
21
18
  substitution_tolerance: {
22
19
  type: sequelize_1.DataTypes.REAL,
23
20
  allowNull: false,
24
21
  defaultValue: 0
22
+ },
23
+ lineup: {
24
+ type: sequelize_1.DataTypes.JSONB,
25
+ allowNull: false,
26
+ defaultValue: {}
27
+ },
28
+ libero_replacements: {
29
+ type: sequelize_1.DataTypes.ARRAY(sequelize_1.DataTypes.UUID),
30
+ allowNull: false,
31
+ defaultValue: []
32
+ },
33
+ pinch_server_subs: {
34
+ type: sequelize_1.DataTypes.JSONB,
35
+ allowNull: false,
36
+ defaultValue: {}
25
37
  }
26
38
  }, {
27
39
  sequelize,
@@ -1,6 +1,6 @@
1
1
  import * as Sequelize from 'sequelize';
2
2
  import { Model, Optional } from 'sequelize';
3
- import { TacticsAttributes, TacticsId, TacticsModel, CompetitionChampionId, CompetitionChampionModel, CompetitionId, CompetitionModel, CompetitionTeamsId, CompetitionTeamsModel, CountryId, CountryModel, DraftPickId, DraftPickModel, DivisionAttributes, DivisionId, DivisionModel, MatchId, MatchModel, MatchRatingId, MatchRatingModel, PlayerAttributes, PlayerId, PlayerModel, PlayerTeamId, PlayerTeamModel, RallyId, RallyModel } from '.';
3
+ import { CompetitionChampionId, CompetitionChampionModel, CompetitionId, CompetitionModel, CompetitionTeamsId, CompetitionTeamsModel, CountryId, CountryModel, DivisionAttributes, DivisionId, DivisionModel, DraftPickId, DraftPickModel, MatchId, MatchModel, MatchRatingId, MatchRatingModel, PlayerAttributes, PlayerId, PlayerModel, PlayerTeamId, PlayerTeamModel, RallyId, RallyModel, TacticsAttributes, TacticsId, TacticsModel } from '.';
4
4
  export interface TeamAttributes {
5
5
  team_id: string;
6
6
  name: string;
@@ -45,12 +45,7 @@ class TeamModel extends sequelize_1.Model {
45
45
  tableName: 'Team',
46
46
  schema: 'public',
47
47
  timestamps: false,
48
- defaultScope: {
49
- include: [
50
- { model: _1.CountryModel, as: 'country' },
51
- { model: _1.TacticsModel, as: 'tactics' }
52
- ]
53
- },
48
+ defaultScope: { include: [{ model: _1.CountryModel, as: 'country' }] },
54
49
  indexes: [{
55
50
  name: 'Team_pk',
56
51
  unique: true,
@@ -1,6 +1,5 @@
1
1
  export * from './country';
2
2
  export * from './court-position';
3
- export * from './formation';
4
3
  export * from './iteration';
5
4
  export * from './draft';
6
5
  export * from './draft-pick';
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./country"), exports);
18
18
  __exportStar(require("./court-position"), exports);
19
- __exportStar(require("./formation"), exports);
20
19
  __exportStar(require("./iteration"), exports);
21
20
  __exportStar(require("./draft"), exports);
22
21
  __exportStar(require("./draft-pick"), exports);
@@ -1,5 +1,5 @@
1
1
  import { PerformanceStatsAttributes, PerformanceStatsModel } from '../models';
2
- import { PerformanceStats, Player } from '../../service';
3
- declare function transformToAttributes(player: Player): PerformanceStatsAttributes;
2
+ import { PerformanceStats } from '../../service';
3
+ declare function transformToAttributes(stats: PerformanceStats, playerId: string): PerformanceStatsAttributes;
4
4
  declare function transformToObject(model: PerformanceStatsModel): PerformanceStats;
5
5
  export { transformToObject as transformToPerformanceStats, transformToAttributes as transformFromPerformanceStats };
@@ -2,27 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformFromPerformanceStats = exports.transformToPerformanceStats = void 0;
4
4
  const service_1 = require("../../service");
5
- function transformToAttributes(player) {
5
+ function transformToAttributes(stats, playerId) {
6
6
  return {
7
- player_id: player.id,
8
- back_attack: player.stats.backAttack,
9
- block: player.stats.block,
10
- read: player.stats.read,
11
- commit: player.stats.commit,
12
- focus: player.stats.focus,
13
- awareness: player.stats.awareness,
14
- defense: player.stats.defense,
15
- quick: player.stats.quick,
16
- power: player.stats.power,
17
- attack: player.stats.attack,
18
- serve: player.stats.serve,
19
- reception: player.stats.reception,
20
- overhand: player.stats.overhand,
21
- bump: player.stats.bump,
22
- setting: player.stats.setting,
23
- spike: player.stats.spike,
24
- stamina: player.stats.stamina,
25
- reflex: player.stats.reflex
7
+ player_id: playerId,
8
+ back_attack: stats.backAttack,
9
+ block: stats.block,
10
+ read: stats.read,
11
+ commit: stats.commit,
12
+ focus: stats.focus,
13
+ awareness: stats.awareness,
14
+ defense: stats.defense,
15
+ quick: stats.quick,
16
+ power: stats.power,
17
+ attack: stats.attack,
18
+ serve: stats.serve,
19
+ reception: stats.reception,
20
+ overhand: stats.overhand,
21
+ bump: stats.bump,
22
+ setting: stats.setting,
23
+ spike: stats.spike,
24
+ stamina: stats.stamina,
25
+ reflex: stats.reflex
26
26
  };
27
27
  }
28
28
  exports.transformFromPerformanceStats = transformToAttributes;
@@ -11,7 +11,7 @@ function transformToAttributes(player) {
11
11
  last_name: player.name.last,
12
12
  roles: player.roles,
13
13
  traits: player.traits,
14
- PerformanceStat: (0, _1.transformFromPerformanceStats)(player),
14
+ PerformanceStat: (0, _1.transformFromPerformanceStats)(player.stats, player.id),
15
15
  rarity: player.rarity
16
16
  };
17
17
  }
@@ -1,5 +1,5 @@
1
1
  import { TacticsAttributes, TacticsModel } from '../models';
2
- import { Tactics, Team } from '../../service';
3
- declare function transformToAttributes(team: Team): TacticsAttributes;
4
- declare function transformToObject(model: TacticsModel): Tactics;
2
+ import { Player, Tactics } from '../../service';
3
+ declare function transformToAttributes(tactics: Tactics, teamId: string): TacticsAttributes;
4
+ declare function transformToObject(model: TacticsModel, roster: Player[]): Tactics;
5
5
  export { transformToObject as transformToTactics, transformToAttributes as transformFromTactics };
@@ -1,20 +1,60 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformFromTactics = exports.transformToTactics = void 0;
4
- const _1 = require(".");
5
4
  const service_1 = require("../../service");
6
- function transformToAttributes(team) {
5
+ function findPlayer(id, roster) {
6
+ const player = roster.find((p) => p.id === id);
7
+ if (player == null)
8
+ throw new Error(`PLAYER_NOT_FOUND: ${id}`);
9
+ return player;
10
+ }
11
+ function transformFromLineup(lineup) {
12
+ return {
13
+ [service_1.CourtPosition.LIBERO_ZONE]: lineup[service_1.CourtPosition.LIBERO_ZONE] != null ? lineup[service_1.CourtPosition.LIBERO_ZONE].id : undefined,
14
+ [service_1.CourtPosition.LEFT_BACK]: lineup[service_1.CourtPosition.LEFT_BACK].id,
15
+ [service_1.CourtPosition.LEFT_FRONT]: lineup[service_1.CourtPosition.LEFT_FRONT].id,
16
+ [service_1.CourtPosition.MIDDLE_BACK]: lineup[service_1.CourtPosition.MIDDLE_BACK].id,
17
+ [service_1.CourtPosition.MIDDLE_FRONT]: lineup[service_1.CourtPosition.MIDDLE_FRONT].id,
18
+ [service_1.CourtPosition.RIGHT_BACK]: lineup[service_1.CourtPosition.RIGHT_BACK].id,
19
+ [service_1.CourtPosition.RIGHT_FRONT]: lineup[service_1.CourtPosition.RIGHT_FRONT].id,
20
+ bench: lineup.bench.map((b) => b.id)
21
+ };
22
+ }
23
+ function transformToLineup(lineup, roster) {
7
24
  return {
8
- team_id: team.id,
9
- substitution_tolerance: team.tactics.substitutionTolerance ?? 0,
10
- formation: (0, _1.transformFromFormation)(team.tactics.formation)
25
+ [service_1.CourtPosition.LIBERO_ZONE]: roster.find((p) => p.id === lineup[service_1.CourtPosition.LIBERO_ZONE]),
26
+ [service_1.CourtPosition.LEFT_BACK]: findPlayer(lineup[service_1.CourtPosition.LEFT_BACK], roster),
27
+ [service_1.CourtPosition.LEFT_FRONT]: findPlayer(lineup[service_1.CourtPosition.LEFT_FRONT], roster),
28
+ [service_1.CourtPosition.MIDDLE_BACK]: findPlayer(lineup[service_1.CourtPosition.MIDDLE_BACK], roster),
29
+ [service_1.CourtPosition.MIDDLE_FRONT]: findPlayer(lineup[service_1.CourtPosition.MIDDLE_FRONT], roster),
30
+ [service_1.CourtPosition.RIGHT_BACK]: findPlayer(lineup[service_1.CourtPosition.RIGHT_BACK], roster),
31
+ [service_1.CourtPosition.RIGHT_FRONT]: findPlayer(lineup[service_1.CourtPosition.RIGHT_FRONT], roster),
32
+ bench: lineup.bench.map((b) => findPlayer(b, roster))
33
+ };
34
+ }
35
+ function transformToAttributes(tactics, teamId) {
36
+ return {
37
+ team_id: teamId,
38
+ substitution_tolerance: tactics.substitutionTolerance ?? 0,
39
+ lineup: transformFromLineup(tactics.lineup),
40
+ libero_replacements: tactics.liberoReplacements.map((lr) => lr.id),
41
+ pinch_server_subs: Object.fromEntries([...tactics.pinchServerSubs].map(([k, v]) => [k.id, v.id]))
11
42
  };
12
43
  }
13
44
  exports.transformFromTactics = transformToAttributes;
14
- function transformToObject(model) {
45
+ function buildPinchServerSubs(pinchServerSubs, roster) {
46
+ const map = new Map();
47
+ for (const [key, value] of Object.entries(pinchServerSubs)) {
48
+ map.set(findPlayer(key, roster), findPlayer(value, roster));
49
+ }
50
+ return map;
51
+ }
52
+ function transformToObject(model, roster) {
15
53
  return new service_1.Tactics({
16
54
  substitutionTolerance: model.substitution_tolerance,
17
- formation: (0, _1.transformToFormation)(model.formation)
55
+ lineup: transformToLineup(model.lineup, roster),
56
+ liberoReplacements: model.libero_replacements.map((lr) => findPlayer(lr, roster)),
57
+ pinchServerSubs: buildPinchServerSubs(model.pinch_server_subs, roster)
18
58
  });
19
59
  }
20
60
  exports.transformToTactics = transformToObject;
@@ -9,20 +9,21 @@ function transformToAttributes(team) {
9
9
  name: team.name,
10
10
  short_name: team.shortName,
11
11
  country_id: team.country?.id,
12
- tactics: (0, _1.transformFromTactics)(team),
12
+ tactics: (0, _1.transformFromTactics)(team.tactics, team.id),
13
13
  rating: team.rating,
14
14
  division_id: team.divisionId
15
15
  };
16
16
  }
17
17
  exports.transformFromTeam = transformToAttributes;
18
18
  function transformToObject(model) {
19
+ const roster = (model.PlayerTeams ?? []).map((pt) => (0, _1.transformToPlayer)(pt.player));
19
20
  return new service_1.Team({
20
21
  id: model.team_id,
21
22
  name: model.name,
22
23
  shortName: model.short_name,
23
24
  country: (0, _1.transformToCountry)(model.country),
24
- tactics: (0, _1.transformToTactics)(model.tactics),
25
- roster: (model.PlayerTeams ?? []).map((pt) => (0, _1.transformToPlayer)(pt.player)),
25
+ tactics: (0, _1.transformToTactics)(model.tactics, roster),
26
+ roster,
26
27
  rating: model.rating,
27
28
  divisionId: model.division_id
28
29
  });
@@ -1,11 +1,25 @@
1
- import { Formation } from './formation';
2
- interface TacticsOpts {
3
- readonly formation: Formation;
1
+ import { CourtPosition } from '../match';
2
+ import { Player } from '../player';
3
+ export interface StartingLineup {
4
+ readonly [CourtPosition.LEFT_FRONT]: Player;
5
+ readonly [CourtPosition.MIDDLE_FRONT]: Player;
6
+ readonly [CourtPosition.RIGHT_FRONT]: Player;
7
+ readonly [CourtPosition.LEFT_BACK]: Player;
8
+ readonly [CourtPosition.MIDDLE_BACK]: Player;
9
+ readonly [CourtPosition.RIGHT_BACK]: Player;
10
+ readonly [CourtPosition.LIBERO_ZONE]?: Player;
11
+ readonly bench: Player[];
12
+ }
13
+ export interface TacticsOpts {
14
+ readonly lineup: StartingLineup;
4
15
  readonly substitutionTolerance?: number;
16
+ readonly liberoReplacements: Player[];
17
+ readonly pinchServerSubs: Map<Player, Player>;
5
18
  }
6
19
  export declare class Tactics {
7
- readonly formation: Formation;
20
+ readonly lineup: StartingLineup;
8
21
  readonly substitutionTolerance: number;
9
- constructor({ formation, substitutionTolerance }: TacticsOpts);
22
+ readonly liberoReplacements: Player[];
23
+ readonly pinchServerSubs: Map<Player, Player>;
24
+ constructor({ lineup, pinchServerSubs, liberoReplacements, substitutionTolerance }: TacticsOpts);
10
25
  }
11
- export {};
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Tactics = void 0;
4
+ const match_1 = require("../match");
4
5
  class Tactics {
5
- constructor({ formation, substitutionTolerance = 0 }) {
6
- this.formation = formation;
6
+ constructor({ lineup, pinchServerSubs, liberoReplacements, substitutionTolerance = 1 }) {
7
+ this.lineup = lineup;
7
8
  this.substitutionTolerance = substitutionTolerance;
9
+ this.pinchServerSubs = pinchServerSubs;
10
+ this.liberoReplacements = liberoReplacements;
8
11
  }
9
12
  }
10
13
  exports.Tactics = Tactics;
@@ -1,20 +1,35 @@
1
1
  import * as Sequelize from 'sequelize';
2
2
  import { Model, Optional } from 'sequelize';
3
- import { TeamId, TeamModel } from '.';
3
+ import { PlayerId, TeamId, TeamModel } from '.';
4
+ import { CourtPosition } from '../../service';
5
+ export interface TacticsLineupAttributes {
6
+ [CourtPosition.LIBERO_ZONE]?: PlayerId;
7
+ [CourtPosition.LEFT_BACK]: PlayerId;
8
+ [CourtPosition.LEFT_FRONT]: PlayerId;
9
+ [CourtPosition.MIDDLE_BACK]: PlayerId;
10
+ [CourtPosition.MIDDLE_FRONT]: PlayerId;
11
+ [CourtPosition.RIGHT_BACK]: PlayerId;
12
+ [CourtPosition.RIGHT_FRONT]: PlayerId;
13
+ bench: PlayerId[];
14
+ }
15
+ export type PinchServerSubsAttributes = Record<PlayerId, PlayerId>;
4
16
  export interface TacticsAttributes {
5
17
  team_id: string;
6
- formation: FormationType;
7
18
  substitution_tolerance: number;
19
+ lineup: TacticsLineupAttributes;
20
+ libero_replacements: PlayerId[];
21
+ pinch_server_subs: PinchServerSubsAttributes;
8
22
  }
9
- export type FormationType = '4-2' | '5-1' | '6-2';
10
23
  export type TacticsPk = 'team_id';
11
24
  export type TacticsId = TacticsModel[TacticsPk];
12
- export type TacticsOptionalAttributes = 'substitution_tolerance';
25
+ export type TacticsOptionalAttributes = 'substitution_tolerance' | 'lineup' | 'libero_replacements' | 'pinch_server_subs';
13
26
  export type TacticsCreationAttributes = Optional<TacticsAttributes, TacticsOptionalAttributes>;
14
27
  export declare class TacticsModel extends Model<TacticsAttributes, TacticsCreationAttributes> implements TacticsAttributes {
15
28
  team_id: string;
16
- formation: FormationType;
17
29
  substitution_tolerance: number;
30
+ lineup: TacticsLineupAttributes;
31
+ libero_replacements: PlayerId[];
32
+ pinch_server_subs: PinchServerSubsAttributes;
18
33
  team: TeamModel;
19
34
  getTeam: Sequelize.BelongsToGetAssociationMixin<TeamModel>;
20
35
  setTeam: Sequelize.BelongsToSetAssociationMixin<TeamModel, TeamId>;
@@ -1,4 +1,5 @@
1
1
  import { DataTypes, Model } from 'sequelize';
2
+ import { CourtPosition } from '../../service';
2
3
  export class TacticsModel extends Model {
3
4
  static initModel(sequelize) {
4
5
  return TacticsModel.init({
@@ -11,14 +12,25 @@ export class TacticsModel extends Model {
11
12
  key: 'team_id'
12
13
  }
13
14
  },
14
- formation: {
15
- type: DataTypes.ENUM('4-2', '5-1', '6-2'),
16
- allowNull: false
17
- },
18
15
  substitution_tolerance: {
19
16
  type: DataTypes.REAL,
20
17
  allowNull: false,
21
18
  defaultValue: 0
19
+ },
20
+ lineup: {
21
+ type: DataTypes.JSONB,
22
+ allowNull: false,
23
+ defaultValue: {}
24
+ },
25
+ libero_replacements: {
26
+ type: DataTypes.ARRAY(DataTypes.UUID),
27
+ allowNull: false,
28
+ defaultValue: []
29
+ },
30
+ pinch_server_subs: {
31
+ type: DataTypes.JSONB,
32
+ allowNull: false,
33
+ defaultValue: {}
22
34
  }
23
35
  }, {
24
36
  sequelize,
@@ -1,6 +1,6 @@
1
1
  import * as Sequelize from 'sequelize';
2
2
  import { Model, Optional } from 'sequelize';
3
- import { TacticsAttributes, TacticsId, TacticsModel, CompetitionChampionId, CompetitionChampionModel, CompetitionId, CompetitionModel, CompetitionTeamsId, CompetitionTeamsModel, CountryId, CountryModel, DraftPickId, DraftPickModel, DivisionAttributes, DivisionId, DivisionModel, MatchId, MatchModel, MatchRatingId, MatchRatingModel, PlayerAttributes, PlayerId, PlayerModel, PlayerTeamId, PlayerTeamModel, RallyId, RallyModel } from '.';
3
+ import { CompetitionChampionId, CompetitionChampionModel, CompetitionId, CompetitionModel, CompetitionTeamsId, CompetitionTeamsModel, CountryId, CountryModel, DivisionAttributes, DivisionId, DivisionModel, DraftPickId, DraftPickModel, MatchId, MatchModel, MatchRatingId, MatchRatingModel, PlayerAttributes, PlayerId, PlayerModel, PlayerTeamId, PlayerTeamModel, RallyId, RallyModel, TacticsAttributes, TacticsId, TacticsModel } from '.';
4
4
  export interface TeamAttributes {
5
5
  team_id: string;
6
6
  name: string;
@@ -1,5 +1,5 @@
1
1
  import { DataTypes, Model } from 'sequelize';
2
- import { TacticsModel, CountryModel } from '.';
2
+ import { CountryModel } from '.';
3
3
  export class TeamModel extends Model {
4
4
  static initModel(sequelize) {
5
5
  return TeamModel.init({
@@ -42,12 +42,7 @@ export class TeamModel extends Model {
42
42
  tableName: 'Team',
43
43
  schema: 'public',
44
44
  timestamps: false,
45
- defaultScope: {
46
- include: [
47
- { model: CountryModel, as: 'country' },
48
- { model: TacticsModel, as: 'tactics' }
49
- ]
50
- },
45
+ defaultScope: { include: [{ model: CountryModel, as: 'country' }] },
51
46
  indexes: [{
52
47
  name: 'Team_pk',
53
48
  unique: true,
@@ -1,6 +1,5 @@
1
1
  export * from './country';
2
2
  export * from './court-position';
3
- export * from './formation';
4
3
  export * from './iteration';
5
4
  export * from './draft';
6
5
  export * from './draft-pick';
@@ -1,6 +1,5 @@
1
1
  export * from './country';
2
2
  export * from './court-position';
3
- export * from './formation';
4
3
  export * from './iteration';
5
4
  export * from './draft';
6
5
  export * from './draft-pick';
@@ -1,5 +1,5 @@
1
1
  import { PerformanceStatsAttributes, PerformanceStatsModel } from '../models';
2
- import { PerformanceStats, Player } from '../../service';
3
- declare function transformToAttributes(player: Player): PerformanceStatsAttributes;
2
+ import { PerformanceStats } from '../../service';
3
+ declare function transformToAttributes(stats: PerformanceStats, playerId: string): PerformanceStatsAttributes;
4
4
  declare function transformToObject(model: PerformanceStatsModel): PerformanceStats;
5
5
  export { transformToObject as transformToPerformanceStats, transformToAttributes as transformFromPerformanceStats };
@@ -1,25 +1,25 @@
1
1
  import { PerformanceStats } from '../../service';
2
- function transformToAttributes(player) {
2
+ function transformToAttributes(stats, playerId) {
3
3
  return {
4
- player_id: player.id,
5
- back_attack: player.stats.backAttack,
6
- block: player.stats.block,
7
- read: player.stats.read,
8
- commit: player.stats.commit,
9
- focus: player.stats.focus,
10
- awareness: player.stats.awareness,
11
- defense: player.stats.defense,
12
- quick: player.stats.quick,
13
- power: player.stats.power,
14
- attack: player.stats.attack,
15
- serve: player.stats.serve,
16
- reception: player.stats.reception,
17
- overhand: player.stats.overhand,
18
- bump: player.stats.bump,
19
- setting: player.stats.setting,
20
- spike: player.stats.spike,
21
- stamina: player.stats.stamina,
22
- reflex: player.stats.reflex
4
+ player_id: playerId,
5
+ back_attack: stats.backAttack,
6
+ block: stats.block,
7
+ read: stats.read,
8
+ commit: stats.commit,
9
+ focus: stats.focus,
10
+ awareness: stats.awareness,
11
+ defense: stats.defense,
12
+ quick: stats.quick,
13
+ power: stats.power,
14
+ attack: stats.attack,
15
+ serve: stats.serve,
16
+ reception: stats.reception,
17
+ overhand: stats.overhand,
18
+ bump: stats.bump,
19
+ setting: stats.setting,
20
+ spike: stats.spike,
21
+ stamina: stats.stamina,
22
+ reflex: stats.reflex
23
23
  };
24
24
  }
25
25
  function transformToObject(model) {
@@ -8,7 +8,7 @@ function transformToAttributes(player) {
8
8
  last_name: player.name.last,
9
9
  roles: player.roles,
10
10
  traits: player.traits,
11
- PerformanceStat: transformFromPerformanceStats(player),
11
+ PerformanceStat: transformFromPerformanceStats(player.stats, player.id),
12
12
  rarity: player.rarity
13
13
  };
14
14
  }
@@ -1,5 +1,5 @@
1
1
  import { TacticsAttributes, TacticsModel } from '../models';
2
- import { Tactics, Team } from '../../service';
3
- declare function transformToAttributes(team: Team): TacticsAttributes;
4
- declare function transformToObject(model: TacticsModel): Tactics;
2
+ import { Player, Tactics } from '../../service';
3
+ declare function transformToAttributes(tactics: Tactics, teamId: string): TacticsAttributes;
4
+ declare function transformToObject(model: TacticsModel, roster: Player[]): Tactics;
5
5
  export { transformToObject as transformToTactics, transformToAttributes as transformFromTactics };
@@ -1,16 +1,56 @@
1
- import { transformFromFormation, transformToFormation } from '.';
2
- import { Tactics } from '../../service';
3
- function transformToAttributes(team) {
1
+ import { CourtPosition, Tactics } from '../../service';
2
+ function findPlayer(id, roster) {
3
+ const player = roster.find((p) => p.id === id);
4
+ if (player == null)
5
+ throw new Error(`PLAYER_NOT_FOUND: ${id}`);
6
+ return player;
7
+ }
8
+ function transformFromLineup(lineup) {
9
+ return {
10
+ [CourtPosition.LIBERO_ZONE]: lineup[CourtPosition.LIBERO_ZONE] != null ? lineup[CourtPosition.LIBERO_ZONE].id : undefined,
11
+ [CourtPosition.LEFT_BACK]: lineup[CourtPosition.LEFT_BACK].id,
12
+ [CourtPosition.LEFT_FRONT]: lineup[CourtPosition.LEFT_FRONT].id,
13
+ [CourtPosition.MIDDLE_BACK]: lineup[CourtPosition.MIDDLE_BACK].id,
14
+ [CourtPosition.MIDDLE_FRONT]: lineup[CourtPosition.MIDDLE_FRONT].id,
15
+ [CourtPosition.RIGHT_BACK]: lineup[CourtPosition.RIGHT_BACK].id,
16
+ [CourtPosition.RIGHT_FRONT]: lineup[CourtPosition.RIGHT_FRONT].id,
17
+ bench: lineup.bench.map((b) => b.id)
18
+ };
19
+ }
20
+ function transformToLineup(lineup, roster) {
4
21
  return {
5
- team_id: team.id,
6
- substitution_tolerance: team.tactics.substitutionTolerance ?? 0,
7
- formation: transformFromFormation(team.tactics.formation)
22
+ [CourtPosition.LIBERO_ZONE]: roster.find((p) => p.id === lineup[CourtPosition.LIBERO_ZONE]),
23
+ [CourtPosition.LEFT_BACK]: findPlayer(lineup[CourtPosition.LEFT_BACK], roster),
24
+ [CourtPosition.LEFT_FRONT]: findPlayer(lineup[CourtPosition.LEFT_FRONT], roster),
25
+ [CourtPosition.MIDDLE_BACK]: findPlayer(lineup[CourtPosition.MIDDLE_BACK], roster),
26
+ [CourtPosition.MIDDLE_FRONT]: findPlayer(lineup[CourtPosition.MIDDLE_FRONT], roster),
27
+ [CourtPosition.RIGHT_BACK]: findPlayer(lineup[CourtPosition.RIGHT_BACK], roster),
28
+ [CourtPosition.RIGHT_FRONT]: findPlayer(lineup[CourtPosition.RIGHT_FRONT], roster),
29
+ bench: lineup.bench.map((b) => findPlayer(b, roster))
8
30
  };
9
31
  }
10
- function transformToObject(model) {
32
+ function transformToAttributes(tactics, teamId) {
33
+ return {
34
+ team_id: teamId,
35
+ substitution_tolerance: tactics.substitutionTolerance ?? 0,
36
+ lineup: transformFromLineup(tactics.lineup),
37
+ libero_replacements: tactics.liberoReplacements.map((lr) => lr.id),
38
+ pinch_server_subs: Object.fromEntries([...tactics.pinchServerSubs].map(([k, v]) => [k.id, v.id]))
39
+ };
40
+ }
41
+ function buildPinchServerSubs(pinchServerSubs, roster) {
42
+ const map = new Map();
43
+ for (const [key, value] of Object.entries(pinchServerSubs)) {
44
+ map.set(findPlayer(key, roster), findPlayer(value, roster));
45
+ }
46
+ return map;
47
+ }
48
+ function transformToObject(model, roster) {
11
49
  return new Tactics({
12
50
  substitutionTolerance: model.substitution_tolerance,
13
- formation: transformToFormation(model.formation)
51
+ lineup: transformToLineup(model.lineup, roster),
52
+ liberoReplacements: model.libero_replacements.map((lr) => findPlayer(lr, roster)),
53
+ pinchServerSubs: buildPinchServerSubs(model.pinch_server_subs, roster)
14
54
  });
15
55
  }
16
56
  export { transformToObject as transformToTactics, transformToAttributes as transformFromTactics };
@@ -6,19 +6,20 @@ function transformToAttributes(team) {
6
6
  name: team.name,
7
7
  short_name: team.shortName,
8
8
  country_id: team.country?.id,
9
- tactics: transformFromTactics(team),
9
+ tactics: transformFromTactics(team.tactics, team.id),
10
10
  rating: team.rating,
11
11
  division_id: team.divisionId
12
12
  };
13
13
  }
14
14
  function transformToObject(model) {
15
+ const roster = (model.PlayerTeams ?? []).map((pt) => transformToPlayer(pt.player));
15
16
  return new Team({
16
17
  id: model.team_id,
17
18
  name: model.name,
18
19
  shortName: model.short_name,
19
20
  country: transformToCountry(model.country),
20
- tactics: transformToTactics(model.tactics),
21
- roster: (model.PlayerTeams ?? []).map((pt) => transformToPlayer(pt.player)),
21
+ tactics: transformToTactics(model.tactics, roster),
22
+ roster,
22
23
  rating: model.rating,
23
24
  divisionId: model.division_id
24
25
  });
@@ -1,11 +1,25 @@
1
- import { Formation } from './formation';
2
- interface TacticsOpts {
3
- readonly formation: Formation;
1
+ import { CourtPosition } from '../match';
2
+ import { Player } from '../player';
3
+ export interface StartingLineup {
4
+ readonly [CourtPosition.LEFT_FRONT]: Player;
5
+ readonly [CourtPosition.MIDDLE_FRONT]: Player;
6
+ readonly [CourtPosition.RIGHT_FRONT]: Player;
7
+ readonly [CourtPosition.LEFT_BACK]: Player;
8
+ readonly [CourtPosition.MIDDLE_BACK]: Player;
9
+ readonly [CourtPosition.RIGHT_BACK]: Player;
10
+ readonly [CourtPosition.LIBERO_ZONE]?: Player;
11
+ readonly bench: Player[];
12
+ }
13
+ export interface TacticsOpts {
14
+ readonly lineup: StartingLineup;
4
15
  readonly substitutionTolerance?: number;
16
+ readonly liberoReplacements: Player[];
17
+ readonly pinchServerSubs: Map<Player, Player>;
5
18
  }
6
19
  export declare class Tactics {
7
- readonly formation: Formation;
20
+ readonly lineup: StartingLineup;
8
21
  readonly substitutionTolerance: number;
9
- constructor({ formation, substitutionTolerance }: TacticsOpts);
22
+ readonly liberoReplacements: Player[];
23
+ readonly pinchServerSubs: Map<Player, Player>;
24
+ constructor({ lineup, pinchServerSubs, liberoReplacements, substitutionTolerance }: TacticsOpts);
10
25
  }
11
- export {};
@@ -1,6 +1,9 @@
1
+ import { CourtPosition } from '../match';
1
2
  export class Tactics {
2
- constructor({ formation, substitutionTolerance = 0 }) {
3
- this.formation = formation;
3
+ constructor({ lineup, pinchServerSubs, liberoReplacements, substitutionTolerance = 1 }) {
4
+ this.lineup = lineup;
4
5
  this.substitutionTolerance = substitutionTolerance;
6
+ this.pinchServerSubs = pinchServerSubs;
7
+ this.liberoReplacements = liberoReplacements;
5
8
  }
6
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.200",
3
+ "version": "0.0.201",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",
@@ -1,5 +0,0 @@
1
- import { Formation } from '../../service';
2
- import { FormationType } from '../models';
3
- declare function transformToType(_formation: Formation): FormationType;
4
- declare function transformFromType(_formation: FormationType): Formation;
5
- export { transformToType as transformFromFormation, transformFromType as transformToFormation };
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformToFormation = exports.transformFromFormation = void 0;
4
- const service_1 = require("../../service");
5
- function transformToType(_formation) {
6
- return _formation.name;
7
- }
8
- exports.transformFromFormation = transformToType;
9
- function transformFromType(_formation) {
10
- return service_1.Formation[_formation];
11
- }
12
- exports.transformToFormation = transformFromType;
@@ -1,5 +0,0 @@
1
- import { Formation } from '../../service';
2
- import { FormationType } from '../models';
3
- declare function transformToType(_formation: Formation): FormationType;
4
- declare function transformFromType(_formation: FormationType): Formation;
5
- export { transformToType as transformFromFormation, transformFromType as transformToFormation };
@@ -1,8 +0,0 @@
1
- import { Formation } from '../../service';
2
- function transformToType(_formation) {
3
- return _formation.name;
4
- }
5
- function transformFromType(_formation) {
6
- return Formation[_formation];
7
- }
8
- export { transformToType as transformFromFormation, transformFromType as transformToFormation };