volleyballsimtypes 0.0.123 → 0.0.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/data/init-models.d.ts +1 -35
- package/dist/cjs/src/data/models/coach.js +2 -2
- package/dist/cjs/src/data/models/player-team.d.ts +1 -2
- package/dist/cjs/src/data/models/rally.js +1 -1
- package/dist/cjs/src/data/transformers/coach.js +2 -2
- package/dist/cjs/src/data/transformers/draft.js +3 -2
- package/dist/cjs/src/data/transformers/league.js +6 -4
- package/dist/cjs/src/data/transformers/match-set-stats.js +1 -1
- package/dist/cjs/src/data/transformers/match-set.js +20 -11
- package/dist/cjs/src/data/transformers/match.js +7 -5
- package/dist/cjs/src/data/transformers/player.js +6 -4
- package/dist/cjs/src/data/transformers/rally.js +20 -1
- package/dist/cjs/src/data/transformers/season.js +41 -30
- package/dist/cjs/src/data/transformers/team.js +4 -3
- package/dist/cjs/src/data/transformers/tournament.js +6 -4
- package/dist/cjs/src/data/transformers/trait.js +5 -1
- package/dist/cjs/src/service/coach/coach.d.ts +2 -2
- package/dist/cjs/src/service/event/block.d.ts +1 -1
- package/dist/cjs/src/service/event/libero-replacement.d.ts +1 -1
- package/dist/cjs/src/service/event/reception.d.ts +1 -1
- package/dist/cjs/src/service/event/serve.d.ts +1 -1
- package/dist/cjs/src/service/event/set.d.ts +1 -1
- package/dist/cjs/src/service/event/spike.d.ts +1 -1
- package/dist/cjs/src/service/event/substitution.d.ts +1 -1
- package/dist/cjs/src/service/team/team.d.ts +6 -6
- package/dist/cjs/src/service/team/team.js +3 -0
- package/dist/esm/src/data/init-models.d.ts +1 -35
- package/dist/esm/src/data/models/coach.js +2 -2
- package/dist/esm/src/data/models/player-team.d.ts +1 -2
- package/dist/esm/src/data/models/rally.js +1 -1
- package/dist/esm/src/data/transformers/coach.js +2 -2
- package/dist/esm/src/data/transformers/draft.js +3 -2
- package/dist/esm/src/data/transformers/league.js +6 -4
- package/dist/esm/src/data/transformers/match-set-stats.js +1 -1
- package/dist/esm/src/data/transformers/match-set.js +20 -11
- package/dist/esm/src/data/transformers/match.js +7 -5
- package/dist/esm/src/data/transformers/player.js +6 -4
- package/dist/esm/src/data/transformers/rally.js +21 -2
- package/dist/esm/src/data/transformers/season.js +41 -30
- package/dist/esm/src/data/transformers/team.js +5 -4
- package/dist/esm/src/data/transformers/tournament.js +6 -4
- package/dist/esm/src/data/transformers/trait.js +5 -1
- package/dist/esm/src/service/coach/coach.d.ts +2 -2
- package/dist/esm/src/service/event/block.d.ts +1 -1
- package/dist/esm/src/service/event/libero-replacement.d.ts +1 -1
- package/dist/esm/src/service/event/reception.d.ts +1 -1
- package/dist/esm/src/service/event/serve.d.ts +1 -1
- package/dist/esm/src/service/event/set.d.ts +1 -1
- package/dist/esm/src/service/event/spike.d.ts +1 -1
- package/dist/esm/src/service/event/substitution.d.ts +1 -1
- package/dist/esm/src/service/team/team.d.ts +6 -6
- package/dist/esm/src/service/team/team.js +3 -0
- package/package.json +3 -3
|
@@ -1,36 +1,2 @@
|
|
|
1
1
|
import type { Sequelize } from 'sequelize';
|
|
2
|
-
|
|
3
|
-
export declare function initModels(sequelize: Sequelize): {
|
|
4
|
-
Coach: typeof CoachModel;
|
|
5
|
-
Competition: typeof CompetitionModel;
|
|
6
|
-
CompetitionChampion: typeof CompetitionChampionModel;
|
|
7
|
-
CompetitionMatch: typeof CompetitionMatchModel;
|
|
8
|
-
CompetitionTeams: typeof CompetitionTeamsModel;
|
|
9
|
-
Country: typeof CountryModel;
|
|
10
|
-
Draft: typeof DraftModel;
|
|
11
|
-
DraftPick: typeof DraftPickModel;
|
|
12
|
-
Event: {
|
|
13
|
-
new (type: string, eventInitDict?: EventInit | undefined): Event;
|
|
14
|
-
prototype: Event;
|
|
15
|
-
readonly AT_TARGET: number;
|
|
16
|
-
readonly BUBBLING_PHASE: number;
|
|
17
|
-
readonly CAPTURING_PHASE: number;
|
|
18
|
-
readonly NONE: number;
|
|
19
|
-
};
|
|
20
|
-
Iteration: typeof IterationModel;
|
|
21
|
-
League: typeof LeagueModel;
|
|
22
|
-
LeagueSeason: typeof LeagueSeasonModel;
|
|
23
|
-
Match: typeof MatchModel;
|
|
24
|
-
MatchRating: typeof MatchRatingModel;
|
|
25
|
-
MatchSet: typeof MatchSetModel;
|
|
26
|
-
MatchSetStats: typeof MatchSetStatsModel;
|
|
27
|
-
PerformanceStats: typeof PerformanceStatsModel;
|
|
28
|
-
Player: typeof PlayerModel;
|
|
29
|
-
PlayerTeam: typeof PlayerTeamModel;
|
|
30
|
-
PlayerTrait: typeof PlayerTraitModel;
|
|
31
|
-
Rally: typeof RallyModel;
|
|
32
|
-
SetPosition: typeof SetPositionModel;
|
|
33
|
-
Team: typeof TeamModel;
|
|
34
|
-
Trait: typeof TraitModel;
|
|
35
|
-
User: typeof UserModel;
|
|
36
|
-
};
|
|
2
|
+
export declare function initModels(sequelize: Sequelize): any;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as Sequelize from 'sequelize';
|
|
2
2
|
import { Model, Optional } from 'sequelize';
|
|
3
|
-
import { PlayerId, PlayerModel } from '.';
|
|
4
|
-
import { TeamId, TeamModel } from '.';
|
|
3
|
+
import { PlayerId, PlayerModel, TeamId, TeamModel } from '.';
|
|
5
4
|
export interface PlayerTeamAttributes {
|
|
6
5
|
player_id: string;
|
|
7
6
|
team_id: string;
|
|
@@ -9,7 +9,7 @@ function transformToAttributes(coach) {
|
|
|
9
9
|
country_id: coach.country.id,
|
|
10
10
|
first_name: coach.name.first,
|
|
11
11
|
last_name: coach.name.last,
|
|
12
|
-
substitution_tolerance: coach.substitutionTolerance,
|
|
12
|
+
substitution_tolerance: coach.substitutionTolerance != null ? coach.substitutionTolerance : 0,
|
|
13
13
|
formation: (0, _1.transformFromFormation)(coach.formation)
|
|
14
14
|
};
|
|
15
15
|
}
|
|
@@ -22,7 +22,7 @@ function transformToObject(model) {
|
|
|
22
22
|
last: model.last_name
|
|
23
23
|
},
|
|
24
24
|
country: (0, _1.transformToCountry)(model.country),
|
|
25
|
-
substitutionTolerance: model.substitution_tolerance
|
|
25
|
+
substitutionTolerance: model.substitution_tolerance,
|
|
26
26
|
formation: (0, _1.transformToFormation)(model.formation)
|
|
27
27
|
});
|
|
28
28
|
}
|
|
@@ -13,8 +13,9 @@ function transformToAttributes(draft) {
|
|
|
13
13
|
}
|
|
14
14
|
exports.transformFromDraft = transformToAttributes;
|
|
15
15
|
function transformToObject(model) {
|
|
16
|
-
const picks = model.DraftPicks != null
|
|
17
|
-
model.DraftPicks.map(draft_pick_1.transformToDraftPick)
|
|
16
|
+
const picks = model.DraftPicks != null
|
|
17
|
+
? model.DraftPicks.map(draft_pick_1.transformToDraftPick)
|
|
18
|
+
: [];
|
|
18
19
|
return new service_1.Draft({
|
|
19
20
|
id: model.draft_id,
|
|
20
21
|
start: new Date(model.start_date),
|
|
@@ -4,10 +4,12 @@ exports.transformFromLeague = exports.transformToAPILeague = exports.transformTo
|
|
|
4
4
|
const service_1 = require("../../service");
|
|
5
5
|
const _1 = require(".");
|
|
6
6
|
function transformToAttributes(league) {
|
|
7
|
-
const LeagueSeasons = league.seasons != null
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const LeagueSeasons = league.seasons != null
|
|
8
|
+
? league.seasons.map(season => ({
|
|
9
|
+
league_id: league.id,
|
|
10
|
+
competition_id: season.id
|
|
11
|
+
}))
|
|
12
|
+
: undefined;
|
|
11
13
|
return {
|
|
12
14
|
league_id: league.id,
|
|
13
15
|
country_id: league.country.id,
|
|
@@ -20,10 +20,14 @@ function transformToAttributes(set, matchId) {
|
|
|
20
20
|
}
|
|
21
21
|
exports.transformFromMatchSet = transformToAttributes;
|
|
22
22
|
function transformToObject(model) {
|
|
23
|
-
const homePlayerPosition = model.SetPositions != null
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const homePlayerPosition = model.SetPositions != null
|
|
24
|
+
? model.SetPositions.filter(p => p.side === 'Home')
|
|
25
|
+
.map(_1.transformToPlayerPosition)
|
|
26
|
+
: [];
|
|
27
|
+
const awayPlayerPosition = model.SetPositions != null
|
|
28
|
+
? model.SetPositions.filter(p => p.side === 'Away')
|
|
29
|
+
.map(_1.transformToPlayerPosition)
|
|
30
|
+
: [];
|
|
27
31
|
const stats = model.MatchSetStats != null ? model.MatchSetStats.map(_1.transformToMatchSetStats) : [];
|
|
28
32
|
const rallies = model.Rallies != null ? model.Rallies.map(_1.transformToRally) : [];
|
|
29
33
|
rallies.sort((r1, r2) => r1.order - r2.order);
|
|
@@ -43,19 +47,24 @@ exports.transformToMatchSet = transformToObject;
|
|
|
43
47
|
function transformToAPIObject(model) {
|
|
44
48
|
const rallies = model.Rallies != null ? model.Rallies.map(_1.transformToAPIRally) : [];
|
|
45
49
|
rallies.sort((r1, r2) => r1.order - r2.order);
|
|
46
|
-
const homePlayerPosition = model.SetPositions != null
|
|
47
|
-
.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
model.
|
|
50
|
+
const homePlayerPosition = model.SetPositions != null
|
|
51
|
+
? model.SetPositions.filter(p => p.side === 'Home')
|
|
52
|
+
.map(_1.transformToPlayerPosition)
|
|
53
|
+
: [];
|
|
54
|
+
const awayPlayerPosition = model.SetPositions != null
|
|
55
|
+
? model.SetPositions.filter(p => p.side === 'Away')
|
|
56
|
+
.map(_1.transformToPlayerPosition)
|
|
57
|
+
: [];
|
|
58
|
+
const stats = model.MatchSetStats != null
|
|
59
|
+
? model.MatchSetStats.map(stats => (0, _1.transformToAPIMatchSetStats)(stats, model.order))
|
|
60
|
+
: [];
|
|
52
61
|
return {
|
|
53
62
|
id: model.match_id,
|
|
54
63
|
order: model.order,
|
|
55
64
|
homeScore: model.home_score,
|
|
56
65
|
awayScore: model.away_score,
|
|
57
66
|
isTieBreak: model.is_tie_break,
|
|
58
|
-
rallies
|
|
67
|
+
rallies,
|
|
59
68
|
homePlayerPosition,
|
|
60
69
|
awayPlayerPosition,
|
|
61
70
|
stats
|
|
@@ -15,22 +15,24 @@ function transformToAttributes(match) {
|
|
|
15
15
|
exports.transformFromMatch = transformToAttributes;
|
|
16
16
|
function transformToObject(model) {
|
|
17
17
|
const sets = model.MatchSets == null || model.MatchSets.length < 1
|
|
18
|
-
? []
|
|
19
|
-
.
|
|
18
|
+
? []
|
|
19
|
+
: model.MatchSets.map(_1.transformToMatchSet)
|
|
20
|
+
.sort((s1, s2) => s1.order - s2.order);
|
|
20
21
|
return new service_1.Match({
|
|
21
22
|
id: model.match_id,
|
|
22
23
|
homeTeam: (0, _1.transformToTeam)(model.HomeTeam),
|
|
23
24
|
awayTeam: (0, _1.transformToTeam)(model.AwayTeam),
|
|
24
25
|
scheduledDate: new Date(model.scheduled_date),
|
|
25
|
-
sets
|
|
26
|
+
sets,
|
|
26
27
|
isSimulated: model.is_simulated
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
exports.transformToMatch = transformToObject;
|
|
30
31
|
function transformToAPIObject(match, competition) {
|
|
31
32
|
const sets = match.MatchSets == null || match.MatchSets.length < 1
|
|
32
|
-
? []
|
|
33
|
-
.
|
|
33
|
+
? []
|
|
34
|
+
: match.MatchSets.map(_1.transformToAPIMatchSet)
|
|
35
|
+
.sort((s1, s2) => s1.order - s2.order);
|
|
34
36
|
return {
|
|
35
37
|
id: match.match_id,
|
|
36
38
|
homeTeam: (0, _1.transformToAPITeam)(match.HomeTeam),
|
|
@@ -29,10 +29,12 @@ function transformToObject(model) {
|
|
|
29
29
|
}
|
|
30
30
|
exports.transformToPlayer = transformToObject;
|
|
31
31
|
function transformToAPIObject(model, team, jerseyNumber) {
|
|
32
|
-
const generalStats = model.PerformanceStat != null
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const generalStats = model.PerformanceStat != null
|
|
33
|
+
? service_1.GeneralStat.getStats().map(stat => ({
|
|
34
|
+
name: stat,
|
|
35
|
+
value: service_1.GeneralStat.calculateScore((0, _1.transformToPerformanceStats)(model.PerformanceStat), stat)
|
|
36
|
+
}))
|
|
37
|
+
: [];
|
|
36
38
|
const gameStats = model.MatchSetStats != null ? model.MatchSetStats.map(_1.transformToAPIMatchSetStats) : [];
|
|
37
39
|
if (gameStats.length > 0) {
|
|
38
40
|
gameStats.push(calculateMatchStats(gameStats));
|
|
@@ -5,7 +5,26 @@ const service_1 = require("../../service");
|
|
|
5
5
|
const _1 = require(".");
|
|
6
6
|
const lz_string_1 = require("lz-string");
|
|
7
7
|
function transformToAttributes(rally, setId) {
|
|
8
|
-
const events = `[${rally.events.map(e =>
|
|
8
|
+
const events = `[${rally.events.map(e => {
|
|
9
|
+
switch (e.eventType) {
|
|
10
|
+
case service_1.EventTypeEnum.BLOCK:
|
|
11
|
+
return e.toString();
|
|
12
|
+
case service_1.EventTypeEnum.LIBERO_REPLACEMENT:
|
|
13
|
+
return e.toString();
|
|
14
|
+
case service_1.EventTypeEnum.SET:
|
|
15
|
+
return e.toString();
|
|
16
|
+
case service_1.EventTypeEnum.SERVE:
|
|
17
|
+
return e.toString();
|
|
18
|
+
case service_1.EventTypeEnum.SPIKE:
|
|
19
|
+
return e.toString();
|
|
20
|
+
case service_1.EventTypeEnum.RECEPTION:
|
|
21
|
+
return e.toString();
|
|
22
|
+
case service_1.EventTypeEnum.SUBSTITUTION:
|
|
23
|
+
return e.toString();
|
|
24
|
+
default:
|
|
25
|
+
throw new Error('UNKNOWN_EVENT_TYPE');
|
|
26
|
+
}
|
|
27
|
+
}).join(',')}]`;
|
|
9
28
|
return {
|
|
10
29
|
rally_id: rally.id,
|
|
11
30
|
match_set_id: setId,
|
|
@@ -4,16 +4,19 @@ exports.transformFromSeason = exports.transformToAPISeason = exports.transformTo
|
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const service_1 = require("../../service");
|
|
6
6
|
function transformToAttributes(season, leagueId) {
|
|
7
|
-
const matches = season.matches != null
|
|
8
|
-
season.matches.map((match, index) => (0, _1.transformFromSeasonMatch)(season.id, match, index))
|
|
7
|
+
const matches = season.matches != null
|
|
8
|
+
? season.matches.map((match, index) => (0, _1.transformFromSeasonMatch)(season.id, match, index))
|
|
9
|
+
: [];
|
|
9
10
|
const teams = season.teams.map(team => ({
|
|
10
11
|
competition_id: season.id,
|
|
11
12
|
team_id: team.id
|
|
12
13
|
}));
|
|
13
|
-
const champion = season.champion != null
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const champion = season.champion != null
|
|
15
|
+
? {
|
|
16
|
+
competition_id: season.id,
|
|
17
|
+
team_id: season.champion?.id
|
|
18
|
+
}
|
|
19
|
+
: undefined;
|
|
17
20
|
return {
|
|
18
21
|
competition_id: season.id,
|
|
19
22
|
type: 'LEAGUE',
|
|
@@ -26,8 +29,9 @@ function transformToAttributes(season, leagueId) {
|
|
|
26
29
|
}
|
|
27
30
|
exports.transformFromSeason = transformToAttributes;
|
|
28
31
|
function transformToObject(model) {
|
|
29
|
-
const matches = model.CompetitionMatches != null
|
|
30
|
-
model.CompetitionMatches.map(matches => (0, _1.transformToMatch)(matches.Match))
|
|
32
|
+
const matches = model.CompetitionMatches != null
|
|
33
|
+
? model.CompetitionMatches.map(matches => (0, _1.transformToMatch)(matches.Match))
|
|
34
|
+
: [];
|
|
31
35
|
return new service_1.Season({
|
|
32
36
|
id: model.competition_id,
|
|
33
37
|
matches,
|
|
@@ -39,31 +43,38 @@ function transformToObject(model) {
|
|
|
39
43
|
exports.transformToSeason = transformToObject;
|
|
40
44
|
function transformToAPIObject(model) {
|
|
41
45
|
const season = transformToObject(model);
|
|
42
|
-
const matches = model.CompetitionMatches != null
|
|
43
|
-
model.CompetitionMatches.map(matches => (0, _1.transformToAPIMatch)(matches.Match))
|
|
46
|
+
const matches = model.CompetitionMatches != null
|
|
47
|
+
? model.CompetitionMatches.map(matches => (0, _1.transformToAPIMatch)(matches.Match))
|
|
48
|
+
: [];
|
|
44
49
|
const teams = model.Teams != null ? model.Teams.map(_1.transformToAPITeam) : [];
|
|
45
|
-
const standings = season.standings.map(standing =>
|
|
46
|
-
team
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
const standings = season.standings.map(standing => {
|
|
51
|
+
const team = teams.find(t => standing.team.id === t.id);
|
|
52
|
+
if (team == null) {
|
|
53
|
+
throw new Error('TEAM_NOT_FOUND');
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
team,
|
|
57
|
+
lost03: standing.lost03,
|
|
58
|
+
lost13: standing.lost13,
|
|
59
|
+
lost23: standing.lost23,
|
|
60
|
+
matchesLost: standing.matchesLost,
|
|
61
|
+
matchesWon: standing.matchesWon,
|
|
62
|
+
points: standing.points,
|
|
63
|
+
pointsLost: standing.pointsLost,
|
|
64
|
+
pointsRatio: standing.pointsRatio,
|
|
65
|
+
pointsWon: standing.pointsWon,
|
|
66
|
+
setsLost: standing.setsLost,
|
|
67
|
+
setsRatio: standing.setsRatio,
|
|
68
|
+
setsWon: standing.setsWon,
|
|
69
|
+
won30: standing.won30,
|
|
70
|
+
won31: standing.won31,
|
|
71
|
+
won32: standing.won32,
|
|
72
|
+
totalMatches: standing.totalMatches
|
|
73
|
+
};
|
|
74
|
+
});
|
|
64
75
|
return {
|
|
65
76
|
id: model.competition_id,
|
|
66
|
-
matches
|
|
77
|
+
matches,
|
|
67
78
|
iteration: model.iteration,
|
|
68
79
|
league: model.LeagueSeason?.league != null ? (0, _1.transformToAPILeague)(model.LeagueSeason.league) : undefined,
|
|
69
80
|
champion: model.CompetitionChampion != null ? (0, _1.transformToAPITeam)(model.CompetitionChampion.team) : undefined,
|
|
@@ -21,9 +21,10 @@ function transformToObject(team) {
|
|
|
21
21
|
id: team.team_id,
|
|
22
22
|
name: team.name,
|
|
23
23
|
shortName: team.short_name,
|
|
24
|
-
country:
|
|
25
|
-
coach:
|
|
26
|
-
roster: team.PlayerTeams
|
|
24
|
+
country: (0, _1.transformToCountry)(team.country),
|
|
25
|
+
coach: (0, _1.transformToCoach)(team.coach),
|
|
26
|
+
roster: team.PlayerTeams.map(pt => (0, _1.transformToPlayer)(pt.player)),
|
|
27
|
+
league: (0, _1.transformToLeague)(team.league),
|
|
27
28
|
rating: team.rating
|
|
28
29
|
});
|
|
29
30
|
}
|
|
@@ -9,10 +9,12 @@ function transformToAttributes(tournament) {
|
|
|
9
9
|
competition_id: tournament.id,
|
|
10
10
|
team_id: team.id
|
|
11
11
|
}));
|
|
12
|
-
const champion = tournament.champion != null
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const champion = tournament.champion != null
|
|
13
|
+
? {
|
|
14
|
+
competition_id: tournament.id,
|
|
15
|
+
team_id: tournament.champion?.id
|
|
16
|
+
}
|
|
17
|
+
: undefined;
|
|
16
18
|
return {
|
|
17
19
|
competition_id: tournament.id,
|
|
18
20
|
type: 'TOURNAMENT',
|
|
@@ -32,6 +32,10 @@ function transformToAPIObject(model) {
|
|
|
32
32
|
}
|
|
33
33
|
exports.transformToAPITrait = transformToAPIObject;
|
|
34
34
|
function transformToObject(model) {
|
|
35
|
-
|
|
35
|
+
const trait = service_1.Trait.getTraits().find(trait => trait.id === model.trait_id);
|
|
36
|
+
if (trait == null) {
|
|
37
|
+
throw new Error('TRAIT_NOT_FOUND');
|
|
38
|
+
}
|
|
39
|
+
return trait;
|
|
36
40
|
}
|
|
37
41
|
exports.transformToTrait = transformToObject;
|
|
@@ -6,14 +6,14 @@ interface CoachOpts {
|
|
|
6
6
|
readonly name: Name;
|
|
7
7
|
readonly country: Country;
|
|
8
8
|
readonly formation: Formation;
|
|
9
|
-
readonly substitutionTolerance
|
|
9
|
+
readonly substitutionTolerance: number;
|
|
10
10
|
}
|
|
11
11
|
export declare class Coach {
|
|
12
12
|
readonly id: string;
|
|
13
13
|
readonly name: Name;
|
|
14
14
|
readonly country: Country;
|
|
15
15
|
readonly formation: Formation;
|
|
16
|
-
readonly substitutionTolerance
|
|
16
|
+
readonly substitutionTolerance: number;
|
|
17
17
|
constructor({ id, name, country, formation, substitutionTolerance }: CoachOpts);
|
|
18
18
|
}
|
|
19
19
|
export {};
|
|
@@ -25,6 +25,6 @@ export declare class Block extends InPlayEvent {
|
|
|
25
25
|
readonly blockers: string[];
|
|
26
26
|
constructor({ order, score, player, target, failure, type, modifier, eventType, blockers, activeTraits }: BlockOpts);
|
|
27
27
|
static getScore(blockers: Player[], modifier: number, activeTraits: Trait[]): number;
|
|
28
|
-
|
|
28
|
+
toString(): string;
|
|
29
29
|
}
|
|
30
30
|
export {};
|
|
@@ -13,6 +13,6 @@ export declare class LiberoReplacement extends RallyEvent {
|
|
|
13
13
|
readonly type: LiberoReplacementTypeEnum;
|
|
14
14
|
readonly libero: string;
|
|
15
15
|
constructor({ order, player, type, libero, eventType }: LiberoReplacementOpts);
|
|
16
|
-
|
|
16
|
+
toString(): string;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -22,6 +22,6 @@ export declare class Reception extends InPlayEvent {
|
|
|
22
22
|
readonly type: ReceptionTypeEnum;
|
|
23
23
|
constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: ReceptionOpts);
|
|
24
24
|
static getScore(stats: PerformanceStats, type: ReceptionTypeEnum, modifier: number, activeTraits: Trait[]): number;
|
|
25
|
-
|
|
25
|
+
toString(): string;
|
|
26
26
|
}
|
|
27
27
|
export {};
|
|
@@ -23,6 +23,6 @@ export declare class Serve extends InPlayEvent {
|
|
|
23
23
|
readonly type: ServeTypeEnum;
|
|
24
24
|
constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: ServeOpts);
|
|
25
25
|
static getScore(stats: PerformanceStats, type: ServeTypeEnum, modifier: number, activeTraits: Trait[]): number;
|
|
26
|
-
|
|
26
|
+
toString(): string;
|
|
27
27
|
}
|
|
28
28
|
export {};
|
|
@@ -22,6 +22,6 @@ export declare class Set extends InPlayEvent {
|
|
|
22
22
|
readonly type: SetTypeEnum;
|
|
23
23
|
constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: SetOpts);
|
|
24
24
|
static getScore(stats: PerformanceStats, type: SetTypeEnum, modifier: number, activeTraits: Trait[]): number;
|
|
25
|
-
|
|
25
|
+
toString(): string;
|
|
26
26
|
}
|
|
27
27
|
export {};
|
|
@@ -24,6 +24,6 @@ export declare class Spike extends InPlayEvent {
|
|
|
24
24
|
readonly type: SpikeTypeEnum;
|
|
25
25
|
constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: SpikeOpts);
|
|
26
26
|
static getScore(player: Player, type: SpikeTypeEnum, modifier: number, isBackRow: boolean, activeTraits: Trait[]): number;
|
|
27
|
-
|
|
27
|
+
toString(): string;
|
|
28
28
|
}
|
|
29
29
|
export {};
|
|
@@ -6,6 +6,6 @@ interface SubstitutionOpts extends RallyEventOpts {
|
|
|
6
6
|
export declare class Substitution extends RallyEvent {
|
|
7
7
|
readonly playerOut: string;
|
|
8
8
|
constructor({ order, playerOut, player, eventType }: SubstitutionOpts);
|
|
9
|
-
|
|
9
|
+
toString(): string;
|
|
10
10
|
}
|
|
11
11
|
export {};
|
|
@@ -8,18 +8,18 @@ interface TeamOpts {
|
|
|
8
8
|
readonly name: string;
|
|
9
9
|
readonly shortName: string;
|
|
10
10
|
readonly roster: Player[];
|
|
11
|
-
readonly country
|
|
12
|
-
readonly league
|
|
13
|
-
readonly coach
|
|
11
|
+
readonly country: Country;
|
|
12
|
+
readonly league: League;
|
|
13
|
+
readonly coach: Coach;
|
|
14
14
|
}
|
|
15
15
|
export declare class Team {
|
|
16
16
|
readonly id: string;
|
|
17
17
|
readonly roster: Player[];
|
|
18
18
|
readonly name: string;
|
|
19
19
|
readonly shortName: string;
|
|
20
|
-
readonly coach
|
|
21
|
-
readonly league
|
|
22
|
-
readonly country
|
|
20
|
+
readonly coach: Coach;
|
|
21
|
+
readonly league: League;
|
|
22
|
+
readonly country: Country;
|
|
23
23
|
private _rating;
|
|
24
24
|
constructor({ id, rating, name, shortName, country, roster, coach, league }: TeamOpts);
|
|
25
25
|
get rating(): number;
|
|
@@ -25,6 +25,9 @@ class Team {
|
|
|
25
25
|
return this.roster.some(p => p.id === player.id);
|
|
26
26
|
}
|
|
27
27
|
toString() {
|
|
28
|
+
if (this.country == null) {
|
|
29
|
+
throw new Error('UNKNOWN_COUNTRY');
|
|
30
|
+
}
|
|
28
31
|
return `${this.name} [${this.shortName}] (${this.country?.name}) ELO=${this._rating}`;
|
|
29
32
|
}
|
|
30
33
|
updateRating(ratingChange) {
|
|
@@ -1,36 +1,2 @@
|
|
|
1
1
|
import type { Sequelize } from 'sequelize';
|
|
2
|
-
|
|
3
|
-
export declare function initModels(sequelize: Sequelize): {
|
|
4
|
-
Coach: typeof CoachModel;
|
|
5
|
-
Competition: typeof CompetitionModel;
|
|
6
|
-
CompetitionChampion: typeof CompetitionChampionModel;
|
|
7
|
-
CompetitionMatch: typeof CompetitionMatchModel;
|
|
8
|
-
CompetitionTeams: typeof CompetitionTeamsModel;
|
|
9
|
-
Country: typeof CountryModel;
|
|
10
|
-
Draft: typeof DraftModel;
|
|
11
|
-
DraftPick: typeof DraftPickModel;
|
|
12
|
-
Event: {
|
|
13
|
-
new (type: string, eventInitDict?: EventInit | undefined): Event;
|
|
14
|
-
prototype: Event;
|
|
15
|
-
readonly AT_TARGET: number;
|
|
16
|
-
readonly BUBBLING_PHASE: number;
|
|
17
|
-
readonly CAPTURING_PHASE: number;
|
|
18
|
-
readonly NONE: number;
|
|
19
|
-
};
|
|
20
|
-
Iteration: typeof IterationModel;
|
|
21
|
-
League: typeof LeagueModel;
|
|
22
|
-
LeagueSeason: typeof LeagueSeasonModel;
|
|
23
|
-
Match: typeof MatchModel;
|
|
24
|
-
MatchRating: typeof MatchRatingModel;
|
|
25
|
-
MatchSet: typeof MatchSetModel;
|
|
26
|
-
MatchSetStats: typeof MatchSetStatsModel;
|
|
27
|
-
PerformanceStats: typeof PerformanceStatsModel;
|
|
28
|
-
Player: typeof PlayerModel;
|
|
29
|
-
PlayerTeam: typeof PlayerTeamModel;
|
|
30
|
-
PlayerTrait: typeof PlayerTraitModel;
|
|
31
|
-
Rally: typeof RallyModel;
|
|
32
|
-
SetPosition: typeof SetPositionModel;
|
|
33
|
-
Team: typeof TeamModel;
|
|
34
|
-
Trait: typeof TraitModel;
|
|
35
|
-
User: typeof UserModel;
|
|
36
|
-
};
|
|
2
|
+
export declare function initModels(sequelize: Sequelize): any;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as Sequelize from 'sequelize';
|
|
2
2
|
import { Model, Optional } from 'sequelize';
|
|
3
|
-
import { PlayerId, PlayerModel } from '.';
|
|
4
|
-
import { TeamId, TeamModel } from '.';
|
|
3
|
+
import { PlayerId, PlayerModel, TeamId, TeamModel } from '.';
|
|
5
4
|
export interface PlayerTeamAttributes {
|
|
6
5
|
player_id: string;
|
|
7
6
|
team_id: string;
|
|
@@ -6,7 +6,7 @@ function transformToAttributes(coach) {
|
|
|
6
6
|
country_id: coach.country.id,
|
|
7
7
|
first_name: coach.name.first,
|
|
8
8
|
last_name: coach.name.last,
|
|
9
|
-
substitution_tolerance: coach.substitutionTolerance,
|
|
9
|
+
substitution_tolerance: coach.substitutionTolerance != null ? coach.substitutionTolerance : 0,
|
|
10
10
|
formation: transformFromFormation(coach.formation)
|
|
11
11
|
};
|
|
12
12
|
}
|
|
@@ -18,7 +18,7 @@ function transformToObject(model) {
|
|
|
18
18
|
last: model.last_name
|
|
19
19
|
},
|
|
20
20
|
country: transformToCountry(model.country),
|
|
21
|
-
substitutionTolerance: model.substitution_tolerance
|
|
21
|
+
substitutionTolerance: model.substitution_tolerance,
|
|
22
22
|
formation: transformToFormation(model.formation)
|
|
23
23
|
});
|
|
24
24
|
}
|
|
@@ -9,8 +9,9 @@ function transformToAttributes(draft) {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
function transformToObject(model) {
|
|
12
|
-
const picks = model.DraftPicks != null
|
|
13
|
-
model.DraftPicks.map(transformToDraftPick)
|
|
12
|
+
const picks = model.DraftPicks != null
|
|
13
|
+
? model.DraftPicks.map(transformToDraftPick)
|
|
14
|
+
: [];
|
|
14
15
|
return new Draft({
|
|
15
16
|
id: model.draft_id,
|
|
16
17
|
start: new Date(model.start_date),
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { League } from '../../service';
|
|
2
2
|
import { transformToCountry, transformToSeason } from '.';
|
|
3
3
|
function transformToAttributes(league) {
|
|
4
|
-
const LeagueSeasons = league.seasons != null
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const LeagueSeasons = league.seasons != null
|
|
5
|
+
? league.seasons.map(season => ({
|
|
6
|
+
league_id: league.id,
|
|
7
|
+
competition_id: season.id
|
|
8
|
+
}))
|
|
9
|
+
: undefined;
|
|
8
10
|
return {
|
|
9
11
|
league_id: league.id,
|
|
10
12
|
country_id: league.country.id,
|
|
@@ -84,7 +84,7 @@ function transformToAPIObject(model, order) {
|
|
|
84
84
|
ralliesPlayed: model.rallies_played,
|
|
85
85
|
attempts: model.attempts,
|
|
86
86
|
playerId: model.player_id,
|
|
87
|
-
order
|
|
87
|
+
order
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
export { transformToObject as transformToMatchSetStats, transformToAPIObject as transformToAPIMatchSetStats, transformToAttributes as transformFromMatchSetStats };
|
|
@@ -16,10 +16,14 @@ function transformToAttributes(set, matchId) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function transformToObject(model) {
|
|
19
|
-
const homePlayerPosition = model.SetPositions != null
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const homePlayerPosition = model.SetPositions != null
|
|
20
|
+
? model.SetPositions.filter(p => p.side === 'Home')
|
|
21
|
+
.map(transformToPlayerPosition)
|
|
22
|
+
: [];
|
|
23
|
+
const awayPlayerPosition = model.SetPositions != null
|
|
24
|
+
? model.SetPositions.filter(p => p.side === 'Away')
|
|
25
|
+
.map(transformToPlayerPosition)
|
|
26
|
+
: [];
|
|
23
27
|
const stats = model.MatchSetStats != null ? model.MatchSetStats.map(transformToMatchSetStats) : [];
|
|
24
28
|
const rallies = model.Rallies != null ? model.Rallies.map(transformToRally) : [];
|
|
25
29
|
rallies.sort((r1, r2) => r1.order - r2.order);
|
|
@@ -38,19 +42,24 @@ function transformToObject(model) {
|
|
|
38
42
|
function transformToAPIObject(model) {
|
|
39
43
|
const rallies = model.Rallies != null ? model.Rallies.map(transformToAPIRally) : [];
|
|
40
44
|
rallies.sort((r1, r2) => r1.order - r2.order);
|
|
41
|
-
const homePlayerPosition = model.SetPositions != null
|
|
42
|
-
.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
model.
|
|
45
|
+
const homePlayerPosition = model.SetPositions != null
|
|
46
|
+
? model.SetPositions.filter(p => p.side === 'Home')
|
|
47
|
+
.map(transformToPlayerPosition)
|
|
48
|
+
: [];
|
|
49
|
+
const awayPlayerPosition = model.SetPositions != null
|
|
50
|
+
? model.SetPositions.filter(p => p.side === 'Away')
|
|
51
|
+
.map(transformToPlayerPosition)
|
|
52
|
+
: [];
|
|
53
|
+
const stats = model.MatchSetStats != null
|
|
54
|
+
? model.MatchSetStats.map(stats => transformToAPIMatchSetStats(stats, model.order))
|
|
55
|
+
: [];
|
|
47
56
|
return {
|
|
48
57
|
id: model.match_id,
|
|
49
58
|
order: model.order,
|
|
50
59
|
homeScore: model.home_score,
|
|
51
60
|
awayScore: model.away_score,
|
|
52
61
|
isTieBreak: model.is_tie_break,
|
|
53
|
-
rallies
|
|
62
|
+
rallies,
|
|
54
63
|
homePlayerPosition,
|
|
55
64
|
awayPlayerPosition,
|
|
56
65
|
stats
|
|
@@ -11,21 +11,23 @@ function transformToAttributes(match) {
|
|
|
11
11
|
}
|
|
12
12
|
function transformToObject(model) {
|
|
13
13
|
const sets = model.MatchSets == null || model.MatchSets.length < 1
|
|
14
|
-
? []
|
|
15
|
-
|
|
14
|
+
? []
|
|
15
|
+
: model.MatchSets.map(transformToMatchSet)
|
|
16
|
+
.sort((s1, s2) => s1.order - s2.order);
|
|
16
17
|
return new Match({
|
|
17
18
|
id: model.match_id,
|
|
18
19
|
homeTeam: transformToTeam(model.HomeTeam),
|
|
19
20
|
awayTeam: transformToTeam(model.AwayTeam),
|
|
20
21
|
scheduledDate: new Date(model.scheduled_date),
|
|
21
|
-
sets
|
|
22
|
+
sets,
|
|
22
23
|
isSimulated: model.is_simulated
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
function transformToAPIObject(match, competition) {
|
|
26
27
|
const sets = match.MatchSets == null || match.MatchSets.length < 1
|
|
27
|
-
? []
|
|
28
|
-
|
|
28
|
+
? []
|
|
29
|
+
: match.MatchSets.map(transformToAPIMatchSet)
|
|
30
|
+
.sort((s1, s2) => s1.order - s2.order);
|
|
29
31
|
return {
|
|
30
32
|
id: match.match_id,
|
|
31
33
|
homeTeam: transformToAPITeam(match.HomeTeam),
|
|
@@ -24,10 +24,12 @@ function transformToObject(model) {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
function transformToAPIObject(model, team, jerseyNumber) {
|
|
27
|
-
const generalStats = model.PerformanceStat != null
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const generalStats = model.PerformanceStat != null
|
|
28
|
+
? GeneralStat.getStats().map(stat => ({
|
|
29
|
+
name: stat,
|
|
30
|
+
value: GeneralStat.calculateScore(transformToPerformanceStats(model.PerformanceStat), stat)
|
|
31
|
+
}))
|
|
32
|
+
: [];
|
|
31
33
|
const gameStats = model.MatchSetStats != null ? model.MatchSetStats.map(transformToAPIMatchSetStats) : [];
|
|
32
34
|
if (gameStats.length > 0) {
|
|
33
35
|
gameStats.push(calculateMatchStats(gameStats));
|
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
import { Rally } from '../../service';
|
|
1
|
+
import { EventTypeEnum, Rally } from '../../service';
|
|
2
2
|
import { transformToAPIBlock, transformToAPILiberoReplacement, transformToAPIReception, transformToAPIServe, transformToAPISet, transformToAPISpike, transformToAPISubstitution, transformToTeam } from '.';
|
|
3
3
|
import { compressToBase64, decompressFromBase64 } from 'lz-string';
|
|
4
4
|
function transformToAttributes(rally, setId) {
|
|
5
|
-
const events = `[${rally.events.map(e =>
|
|
5
|
+
const events = `[${rally.events.map(e => {
|
|
6
|
+
switch (e.eventType) {
|
|
7
|
+
case EventTypeEnum.BLOCK:
|
|
8
|
+
return e.toString();
|
|
9
|
+
case EventTypeEnum.LIBERO_REPLACEMENT:
|
|
10
|
+
return e.toString();
|
|
11
|
+
case EventTypeEnum.SET:
|
|
12
|
+
return e.toString();
|
|
13
|
+
case EventTypeEnum.SERVE:
|
|
14
|
+
return e.toString();
|
|
15
|
+
case EventTypeEnum.SPIKE:
|
|
16
|
+
return e.toString();
|
|
17
|
+
case EventTypeEnum.RECEPTION:
|
|
18
|
+
return e.toString();
|
|
19
|
+
case EventTypeEnum.SUBSTITUTION:
|
|
20
|
+
return e.toString();
|
|
21
|
+
default:
|
|
22
|
+
throw new Error('UNKNOWN_EVENT_TYPE');
|
|
23
|
+
}
|
|
24
|
+
}).join(',')}]`;
|
|
6
25
|
return {
|
|
7
26
|
rally_id: rally.id,
|
|
8
27
|
match_set_id: setId,
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { transformFromSeasonMatch, transformToAPILeague, transformToAPIMatch, transformToAPITeam, transformToIteration, transformToMatch, transformToTeam } from '.';
|
|
2
2
|
import { Season } from '../../service';
|
|
3
3
|
function transformToAttributes(season, leagueId) {
|
|
4
|
-
const matches = season.matches != null
|
|
5
|
-
season.matches.map((match, index) => transformFromSeasonMatch(season.id, match, index))
|
|
4
|
+
const matches = season.matches != null
|
|
5
|
+
? season.matches.map((match, index) => transformFromSeasonMatch(season.id, match, index))
|
|
6
|
+
: [];
|
|
6
7
|
const teams = season.teams.map(team => ({
|
|
7
8
|
competition_id: season.id,
|
|
8
9
|
team_id: team.id
|
|
9
10
|
}));
|
|
10
|
-
const champion = season.champion != null
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const champion = season.champion != null
|
|
12
|
+
? {
|
|
13
|
+
competition_id: season.id,
|
|
14
|
+
team_id: season.champion?.id
|
|
15
|
+
}
|
|
16
|
+
: undefined;
|
|
14
17
|
return {
|
|
15
18
|
competition_id: season.id,
|
|
16
19
|
type: 'LEAGUE',
|
|
@@ -22,8 +25,9 @@ function transformToAttributes(season, leagueId) {
|
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
27
|
function transformToObject(model) {
|
|
25
|
-
const matches = model.CompetitionMatches != null
|
|
26
|
-
model.CompetitionMatches.map(matches => transformToMatch(matches.Match))
|
|
28
|
+
const matches = model.CompetitionMatches != null
|
|
29
|
+
? model.CompetitionMatches.map(matches => transformToMatch(matches.Match))
|
|
30
|
+
: [];
|
|
27
31
|
return new Season({
|
|
28
32
|
id: model.competition_id,
|
|
29
33
|
matches,
|
|
@@ -34,31 +38,38 @@ function transformToObject(model) {
|
|
|
34
38
|
}
|
|
35
39
|
function transformToAPIObject(model) {
|
|
36
40
|
const season = transformToObject(model);
|
|
37
|
-
const matches = model.CompetitionMatches != null
|
|
38
|
-
model.CompetitionMatches.map(matches => transformToAPIMatch(matches.Match))
|
|
41
|
+
const matches = model.CompetitionMatches != null
|
|
42
|
+
? model.CompetitionMatches.map(matches => transformToAPIMatch(matches.Match))
|
|
43
|
+
: [];
|
|
39
44
|
const teams = model.Teams != null ? model.Teams.map(transformToAPITeam) : [];
|
|
40
|
-
const standings = season.standings.map(standing =>
|
|
41
|
-
team
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
const standings = season.standings.map(standing => {
|
|
46
|
+
const team = teams.find(t => standing.team.id === t.id);
|
|
47
|
+
if (team == null) {
|
|
48
|
+
throw new Error('TEAM_NOT_FOUND');
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
team,
|
|
52
|
+
lost03: standing.lost03,
|
|
53
|
+
lost13: standing.lost13,
|
|
54
|
+
lost23: standing.lost23,
|
|
55
|
+
matchesLost: standing.matchesLost,
|
|
56
|
+
matchesWon: standing.matchesWon,
|
|
57
|
+
points: standing.points,
|
|
58
|
+
pointsLost: standing.pointsLost,
|
|
59
|
+
pointsRatio: standing.pointsRatio,
|
|
60
|
+
pointsWon: standing.pointsWon,
|
|
61
|
+
setsLost: standing.setsLost,
|
|
62
|
+
setsRatio: standing.setsRatio,
|
|
63
|
+
setsWon: standing.setsWon,
|
|
64
|
+
won30: standing.won30,
|
|
65
|
+
won31: standing.won31,
|
|
66
|
+
won32: standing.won32,
|
|
67
|
+
totalMatches: standing.totalMatches
|
|
68
|
+
};
|
|
69
|
+
});
|
|
59
70
|
return {
|
|
60
71
|
id: model.competition_id,
|
|
61
|
-
matches
|
|
72
|
+
matches,
|
|
62
73
|
iteration: model.iteration,
|
|
63
74
|
league: model.LeagueSeason?.league != null ? transformToAPILeague(model.LeagueSeason.league) : undefined,
|
|
64
75
|
champion: model.CompetitionChampion != null ? transformToAPITeam(model.CompetitionChampion.team) : undefined,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Team } from '../../service';
|
|
2
|
-
import { transformFromCoach, transformToAPICoach, transformToAPIPlayer, transformToCoach, transformToCountry, transformToPlayer } from '.';
|
|
2
|
+
import { transformFromCoach, transformToAPICoach, transformToAPIPlayer, transformToCoach, transformToCountry, transformToLeague, transformToPlayer } from '.';
|
|
3
3
|
function transformToAttributes(team) {
|
|
4
4
|
return {
|
|
5
5
|
team_id: team.id,
|
|
@@ -17,9 +17,10 @@ function transformToObject(team) {
|
|
|
17
17
|
id: team.team_id,
|
|
18
18
|
name: team.name,
|
|
19
19
|
shortName: team.short_name,
|
|
20
|
-
country:
|
|
21
|
-
coach:
|
|
22
|
-
roster: team.PlayerTeams
|
|
20
|
+
country: transformToCountry(team.country),
|
|
21
|
+
coach: transformToCoach(team.coach),
|
|
22
|
+
roster: team.PlayerTeams.map(pt => transformToPlayer(pt.player)),
|
|
23
|
+
league: transformToLeague(team.league),
|
|
23
24
|
rating: team.rating
|
|
24
25
|
});
|
|
25
26
|
}
|
|
@@ -6,10 +6,12 @@ function transformToAttributes(tournament) {
|
|
|
6
6
|
competition_id: tournament.id,
|
|
7
7
|
team_id: team.id
|
|
8
8
|
}));
|
|
9
|
-
const champion = tournament.champion != null
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const champion = tournament.champion != null
|
|
10
|
+
? {
|
|
11
|
+
competition_id: tournament.id,
|
|
12
|
+
team_id: tournament.champion?.id
|
|
13
|
+
}
|
|
14
|
+
: undefined;
|
|
13
15
|
return {
|
|
14
16
|
competition_id: tournament.id,
|
|
15
17
|
type: 'TOURNAMENT',
|
|
@@ -27,6 +27,10 @@ function transformToAPIObject(model) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
function transformToObject(model) {
|
|
30
|
-
|
|
30
|
+
const trait = Trait.getTraits().find(trait => trait.id === model.trait_id);
|
|
31
|
+
if (trait == null) {
|
|
32
|
+
throw new Error('TRAIT_NOT_FOUND');
|
|
33
|
+
}
|
|
34
|
+
return trait;
|
|
31
35
|
}
|
|
32
36
|
export { transformToObject as transformToTrait, transformToAPIObject as transformToAPITrait, transformToAttributes as transformFromTrait };
|
|
@@ -6,14 +6,14 @@ interface CoachOpts {
|
|
|
6
6
|
readonly name: Name;
|
|
7
7
|
readonly country: Country;
|
|
8
8
|
readonly formation: Formation;
|
|
9
|
-
readonly substitutionTolerance
|
|
9
|
+
readonly substitutionTolerance: number;
|
|
10
10
|
}
|
|
11
11
|
export declare class Coach {
|
|
12
12
|
readonly id: string;
|
|
13
13
|
readonly name: Name;
|
|
14
14
|
readonly country: Country;
|
|
15
15
|
readonly formation: Formation;
|
|
16
|
-
readonly substitutionTolerance
|
|
16
|
+
readonly substitutionTolerance: number;
|
|
17
17
|
constructor({ id, name, country, formation, substitutionTolerance }: CoachOpts);
|
|
18
18
|
}
|
|
19
19
|
export {};
|
|
@@ -25,6 +25,6 @@ export declare class Block extends InPlayEvent {
|
|
|
25
25
|
readonly blockers: string[];
|
|
26
26
|
constructor({ order, score, player, target, failure, type, modifier, eventType, blockers, activeTraits }: BlockOpts);
|
|
27
27
|
static getScore(blockers: Player[], modifier: number, activeTraits: Trait[]): number;
|
|
28
|
-
|
|
28
|
+
toString(): string;
|
|
29
29
|
}
|
|
30
30
|
export {};
|
|
@@ -13,6 +13,6 @@ export declare class LiberoReplacement extends RallyEvent {
|
|
|
13
13
|
readonly type: LiberoReplacementTypeEnum;
|
|
14
14
|
readonly libero: string;
|
|
15
15
|
constructor({ order, player, type, libero, eventType }: LiberoReplacementOpts);
|
|
16
|
-
|
|
16
|
+
toString(): string;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -22,6 +22,6 @@ export declare class Reception extends InPlayEvent {
|
|
|
22
22
|
readonly type: ReceptionTypeEnum;
|
|
23
23
|
constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: ReceptionOpts);
|
|
24
24
|
static getScore(stats: PerformanceStats, type: ReceptionTypeEnum, modifier: number, activeTraits: Trait[]): number;
|
|
25
|
-
|
|
25
|
+
toString(): string;
|
|
26
26
|
}
|
|
27
27
|
export {};
|
|
@@ -23,6 +23,6 @@ export declare class Serve extends InPlayEvent {
|
|
|
23
23
|
readonly type: ServeTypeEnum;
|
|
24
24
|
constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: ServeOpts);
|
|
25
25
|
static getScore(stats: PerformanceStats, type: ServeTypeEnum, modifier: number, activeTraits: Trait[]): number;
|
|
26
|
-
|
|
26
|
+
toString(): string;
|
|
27
27
|
}
|
|
28
28
|
export {};
|
|
@@ -22,6 +22,6 @@ export declare class Set extends InPlayEvent {
|
|
|
22
22
|
readonly type: SetTypeEnum;
|
|
23
23
|
constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: SetOpts);
|
|
24
24
|
static getScore(stats: PerformanceStats, type: SetTypeEnum, modifier: number, activeTraits: Trait[]): number;
|
|
25
|
-
|
|
25
|
+
toString(): string;
|
|
26
26
|
}
|
|
27
27
|
export {};
|
|
@@ -24,6 +24,6 @@ export declare class Spike extends InPlayEvent {
|
|
|
24
24
|
readonly type: SpikeTypeEnum;
|
|
25
25
|
constructor({ order, score, player, target, failure, type, eventType, modifier, activeTraits }: SpikeOpts);
|
|
26
26
|
static getScore(player: Player, type: SpikeTypeEnum, modifier: number, isBackRow: boolean, activeTraits: Trait[]): number;
|
|
27
|
-
|
|
27
|
+
toString(): string;
|
|
28
28
|
}
|
|
29
29
|
export {};
|
|
@@ -6,6 +6,6 @@ interface SubstitutionOpts extends RallyEventOpts {
|
|
|
6
6
|
export declare class Substitution extends RallyEvent {
|
|
7
7
|
readonly playerOut: string;
|
|
8
8
|
constructor({ order, playerOut, player, eventType }: SubstitutionOpts);
|
|
9
|
-
|
|
9
|
+
toString(): string;
|
|
10
10
|
}
|
|
11
11
|
export {};
|
|
@@ -8,18 +8,18 @@ interface TeamOpts {
|
|
|
8
8
|
readonly name: string;
|
|
9
9
|
readonly shortName: string;
|
|
10
10
|
readonly roster: Player[];
|
|
11
|
-
readonly country
|
|
12
|
-
readonly league
|
|
13
|
-
readonly coach
|
|
11
|
+
readonly country: Country;
|
|
12
|
+
readonly league: League;
|
|
13
|
+
readonly coach: Coach;
|
|
14
14
|
}
|
|
15
15
|
export declare class Team {
|
|
16
16
|
readonly id: string;
|
|
17
17
|
readonly roster: Player[];
|
|
18
18
|
readonly name: string;
|
|
19
19
|
readonly shortName: string;
|
|
20
|
-
readonly coach
|
|
21
|
-
readonly league
|
|
22
|
-
readonly country
|
|
20
|
+
readonly coach: Coach;
|
|
21
|
+
readonly league: League;
|
|
22
|
+
readonly country: Country;
|
|
23
23
|
private _rating;
|
|
24
24
|
constructor({ id, rating, name, shortName, country, roster, coach, league }: TeamOpts);
|
|
25
25
|
get rating(): number;
|
|
@@ -22,6 +22,9 @@ export class Team {
|
|
|
22
22
|
return this.roster.some(p => p.id === player.id);
|
|
23
23
|
}
|
|
24
24
|
toString() {
|
|
25
|
+
if (this.country == null) {
|
|
26
|
+
throw new Error('UNKNOWN_COUNTRY');
|
|
27
|
+
}
|
|
25
28
|
return `${this.name} [${this.shortName}] (${this.country?.name}) ELO=${this._rating}`;
|
|
26
29
|
}
|
|
27
30
|
updateRating(ratingChange) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volleyballsimtypes",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.124",
|
|
4
4
|
"description": "vbsim types",
|
|
5
5
|
"main": "./dist/cjs/src/index.js",
|
|
6
6
|
"module": "./dist/esm/src/index.js",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"madge": "npx madge --warning --circular --extensions ts ./",
|
|
12
12
|
"standard": "npx ts-standard --fix",
|
|
13
13
|
"clean": "rimraf dist",
|
|
14
|
-
"
|
|
14
|
+
"validate": "npm run standard && npm run madge",
|
|
15
15
|
"build": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json",
|
|
16
|
-
"preversion": "npm run build",
|
|
16
|
+
"preversion": "npm run validate && npm run build",
|
|
17
17
|
"postversion": "git push --follow-tags"
|
|
18
18
|
},
|
|
19
19
|
"author": "Francisco Farias <fariasfranciscoe@gmail.com>",
|