volleyballsimtypes 0.0.181 → 0.0.182
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.js +8 -8
- package/dist/cjs/src/data/models/box-score.d.ts +69 -0
- package/dist/cjs/src/data/models/{match-set-stats.js → box-score.js} +60 -23
- package/dist/cjs/src/data/models/index.d.ts +1 -1
- package/dist/cjs/src/data/models/index.js +1 -1
- package/dist/cjs/src/data/models/match-set.d.ts +13 -13
- package/dist/cjs/src/data/models/player.d.ts +13 -13
- package/dist/cjs/src/data/transformers/box-score.d.ts +5 -0
- package/dist/cjs/src/data/transformers/box-score.js +77 -0
- package/dist/cjs/src/data/transformers/index.d.ts +1 -1
- package/dist/cjs/src/data/transformers/index.js +1 -1
- package/dist/cjs/src/data/transformers/match-set.js +3 -4
- package/dist/cjs/src/data/transformers/player.d.ts +1 -3
- package/dist/cjs/src/data/transformers/player.js +2 -49
- package/dist/cjs/src/service/match/box-score.d.ts +75 -0
- package/dist/cjs/src/service/match/box-score.js +64 -0
- package/dist/cjs/src/service/match/index.d.ts +1 -0
- package/dist/cjs/src/service/match/index.js +1 -0
- package/dist/cjs/src/service/match/match-set.d.ts +5 -28
- package/dist/cjs/src/service/match/match-set.js +3 -8
- package/dist/cjs/src/service/match/match.d.ts +0 -1
- package/dist/cjs/src/service/match/match.js +2 -4
- package/dist/cjs/src/service/player/player.d.ts +4 -4
- package/dist/cjs/src/service/player/player.js +2 -2
- package/dist/esm/src/data/init-models.js +9 -9
- package/dist/esm/src/data/models/box-score.d.ts +69 -0
- package/dist/esm/src/data/models/{match-set-stats.js → box-score.js} +58 -21
- package/dist/esm/src/data/models/index.d.ts +1 -1
- package/dist/esm/src/data/models/index.js +1 -1
- package/dist/esm/src/data/models/match-set.d.ts +13 -13
- package/dist/esm/src/data/models/player.d.ts +13 -13
- package/dist/esm/src/data/transformers/box-score.d.ts +5 -0
- package/dist/esm/src/data/transformers/box-score.js +73 -0
- package/dist/esm/src/data/transformers/index.d.ts +1 -1
- package/dist/esm/src/data/transformers/index.js +1 -1
- package/dist/esm/src/data/transformers/match-set.js +4 -5
- package/dist/esm/src/data/transformers/player.d.ts +1 -3
- package/dist/esm/src/data/transformers/player.js +2 -47
- package/dist/esm/src/service/match/box-score.d.ts +75 -0
- package/dist/esm/src/service/match/box-score.js +53 -0
- package/dist/esm/src/service/match/index.d.ts +1 -0
- package/dist/esm/src/service/match/index.js +1 -0
- package/dist/esm/src/service/match/match-set.d.ts +5 -28
- package/dist/esm/src/service/match/match-set.js +3 -8
- package/dist/esm/src/service/match/match.d.ts +0 -1
- package/dist/esm/src/service/match/match.js +2 -4
- package/dist/esm/src/service/player/player.d.ts +4 -4
- package/dist/esm/src/service/player/player.js +2 -2
- package/package.json +1 -1
- package/dist/cjs/src/data/models/match-set-stats.d.ts +0 -58
- package/dist/cjs/src/data/transformers/match-set-stats.d.ts +0 -5
- package/dist/cjs/src/data/transformers/match-set-stats.js +0 -62
- package/dist/esm/src/data/models/match-set-stats.d.ts +0 -58
- package/dist/esm/src/data/transformers/match-set-stats.d.ts +0 -5
- package/dist/esm/src/data/transformers/match-set-stats.js +0 -58
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Sequelize from 'sequelize';
|
|
2
2
|
import { Model } from 'sequelize';
|
|
3
|
-
import {
|
|
3
|
+
import { BoxScoreAttributes, BoxScoreId, BoxScoreModel, MatchId, MatchModel, PlayerId, PlayerModel, RallyAttributes, RallyId, RallyModel, SetPositionAttributes, SetPositionId, SetPositionModel } from '.';
|
|
4
4
|
export interface MatchSetAttributes {
|
|
5
5
|
match_set_id: string;
|
|
6
6
|
match_id: string;
|
|
@@ -10,7 +10,7 @@ export interface MatchSetAttributes {
|
|
|
10
10
|
away_score: number;
|
|
11
11
|
SetPositions?: SetPositionAttributes[];
|
|
12
12
|
Rallies?: RallyAttributes[];
|
|
13
|
-
|
|
13
|
+
BoxScores?: BoxScoreAttributes[];
|
|
14
14
|
}
|
|
15
15
|
export type MatchSetPk = 'match_set_id';
|
|
16
16
|
export type MatchSetId = MatchSetModel[MatchSetPk];
|
|
@@ -26,17 +26,17 @@ export declare class MatchSetModel extends Model<MatchSetAttributes, MatchSetCre
|
|
|
26
26
|
getMatch: Sequelize.BelongsToGetAssociationMixin<MatchModel>;
|
|
27
27
|
setMatch: Sequelize.BelongsToSetAssociationMixin<MatchModel, MatchId>;
|
|
28
28
|
createMatch: Sequelize.BelongsToCreateAssociationMixin<MatchModel>;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
BoxScores: BoxScoreModel[];
|
|
30
|
+
getBoxScores: Sequelize.HasManyGetAssociationsMixin<BoxScoreModel>;
|
|
31
|
+
setBoxScores: Sequelize.HasManySetAssociationsMixin<BoxScoreModel, BoxScoreId>;
|
|
32
|
+
addBoxScore: Sequelize.HasManyAddAssociationMixin<BoxScoreModel, BoxScoreId>;
|
|
33
|
+
addBoxScores: Sequelize.HasManyAddAssociationsMixin<BoxScoreModel, BoxScoreId>;
|
|
34
|
+
createBoxScore: Sequelize.HasManyCreateAssociationMixin<BoxScoreModel>;
|
|
35
|
+
removeBoxScore: Sequelize.HasManyRemoveAssociationMixin<BoxScoreModel, BoxScoreId>;
|
|
36
|
+
removeBoxScores: Sequelize.HasManyRemoveAssociationsMixin<BoxScoreModel, BoxScoreId>;
|
|
37
|
+
hasBoxScore: Sequelize.HasManyHasAssociationMixin<BoxScoreModel, BoxScoreId>;
|
|
38
|
+
hasBoxScores: Sequelize.HasManyHasAssociationsMixin<BoxScoreModel, BoxScoreId>;
|
|
39
|
+
countBoxScores: Sequelize.HasManyCountAssociationsMixin;
|
|
40
40
|
SetStatsPlayers: PlayerModel[];
|
|
41
41
|
getSetStatsPlayers: Sequelize.BelongsToManyGetAssociationsMixin<PlayerModel>;
|
|
42
42
|
setSetStatsPlayers: Sequelize.BelongsToManySetAssociationsMixin<PlayerModel, PlayerId>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Sequelize from 'sequelize';
|
|
2
2
|
import { Model } from 'sequelize';
|
|
3
|
-
import { CountryId, CountryModel, DraftPickId, DraftPickModel, MatchSetId, MatchSetModel,
|
|
3
|
+
import { BoxScoreAttributes, BoxScoreId, BoxScoreModel, CountryId, CountryModel, DraftPickId, DraftPickModel, MatchSetId, MatchSetModel, PerformanceStatsAttributes, PerformanceStatsId, PerformanceStatsModel, PlayerTeamId, PlayerTeamModel, SetPositionId, SetPositionModel, TeamId, TeamModel } from '.';
|
|
4
4
|
import { Rarity, Role, Trait } from '../../service';
|
|
5
5
|
export interface PlayerAttributes {
|
|
6
6
|
player_id: string;
|
|
@@ -11,7 +11,7 @@ export interface PlayerAttributes {
|
|
|
11
11
|
last_name: string;
|
|
12
12
|
country_id: string;
|
|
13
13
|
PerformanceStat?: PerformanceStatsAttributes;
|
|
14
|
-
|
|
14
|
+
BoxScores?: BoxScoreAttributes[];
|
|
15
15
|
}
|
|
16
16
|
export type PlayerPk = 'player_id';
|
|
17
17
|
export type PlayerId = PlayerModel[PlayerPk];
|
|
@@ -54,17 +54,17 @@ export declare class PlayerModel extends Model<PlayerAttributes, PlayerCreationA
|
|
|
54
54
|
hasSetPositionSet: Sequelize.BelongsToManyHasAssociationMixin<MatchSetModel, MatchSetId>;
|
|
55
55
|
hasSetPositionSets: Sequelize.BelongsToManyHasAssociationsMixin<MatchSetModel, MatchSetId>;
|
|
56
56
|
countSetPositionSets: Sequelize.BelongsToManyCountAssociationsMixin;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
BoxScores: BoxScoreModel[];
|
|
58
|
+
getBoxScores: Sequelize.HasManyGetAssociationsMixin<BoxScoreModel>;
|
|
59
|
+
setBoxScores: Sequelize.HasManySetAssociationsMixin<BoxScoreModel, BoxScoreId>;
|
|
60
|
+
addBoxScore: Sequelize.HasManyAddAssociationMixin<BoxScoreModel, BoxScoreId>;
|
|
61
|
+
addBoxScores: Sequelize.HasManyAddAssociationsMixin<BoxScoreModel, BoxScoreId>;
|
|
62
|
+
createBoxScore: Sequelize.HasManyCreateAssociationMixin<BoxScoreModel>;
|
|
63
|
+
removeBoxScore: Sequelize.HasManyRemoveAssociationMixin<BoxScoreModel, BoxScoreId>;
|
|
64
|
+
removeBoxScores: Sequelize.HasManyRemoveAssociationsMixin<BoxScoreModel, BoxScoreId>;
|
|
65
|
+
hasBoxScore: Sequelize.HasManyHasAssociationMixin<BoxScoreModel, BoxScoreId>;
|
|
66
|
+
hasBoxScores: Sequelize.HasManyHasAssociationsMixin<BoxScoreModel, BoxScoreId>;
|
|
67
|
+
countBoxScores: Sequelize.HasManyCountAssociationsMixin;
|
|
68
68
|
PerformanceStat: PerformanceStatsModel;
|
|
69
69
|
getPerformanceStat: Sequelize.HasOneGetAssociationMixin<PerformanceStatsModel>;
|
|
70
70
|
setPerformanceStat: Sequelize.HasOneSetAssociationMixin<PerformanceStatsModel, PerformanceStatsId>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BoxScoreAttributes, BoxScoreModel } from '../models';
|
|
2
|
+
import { BoxScore } from '../../service';
|
|
3
|
+
declare function transformToAttributes(boxScore: BoxScore): BoxScoreAttributes;
|
|
4
|
+
declare function transformToObject(model: BoxScoreModel): BoxScore;
|
|
5
|
+
export { transformToObject as transformToBoxScore, transformToAttributes as transformFromBoxScore };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
function transformToAttributes(boxScore) {
|
|
2
|
+
return {
|
|
3
|
+
player_id: boxScore.playerId,
|
|
4
|
+
match_set_id: boxScore.matchSetId,
|
|
5
|
+
attack_attempts: boxScore.attack.attempts,
|
|
6
|
+
attack_kills: boxScore.attack.kills,
|
|
7
|
+
attack_errors: boxScore.attack.errors,
|
|
8
|
+
serve_attempts: boxScore.serve.attempts,
|
|
9
|
+
serve_aces: boxScore.serve.aces,
|
|
10
|
+
serve_errors: boxScore.serve.errors,
|
|
11
|
+
reception_attempts: boxScore.reception.attempts,
|
|
12
|
+
reception_perfect: boxScore.reception.perfect,
|
|
13
|
+
reception_positive: boxScore.reception.positive,
|
|
14
|
+
reception_overpasses: boxScore.reception.overpasses,
|
|
15
|
+
reception_errors: boxScore.reception.errors,
|
|
16
|
+
block_solo: boxScore.block.solo,
|
|
17
|
+
block_assists: boxScore.block.assists,
|
|
18
|
+
block_errors: boxScore.block.errors,
|
|
19
|
+
setting_assists: boxScore.setting.assists,
|
|
20
|
+
setting_errors: boxScore.setting.errors,
|
|
21
|
+
defense_digs: boxScore.defense.digs,
|
|
22
|
+
defense_errors: boxScore.defense.errors,
|
|
23
|
+
misc_points_played: boxScore.misc.pointsPlayed,
|
|
24
|
+
misc_points_won_on_court: boxScore.misc.pointsWonOnCourt,
|
|
25
|
+
misc_serve_turns: boxScore.misc.serveTurns,
|
|
26
|
+
misc_sideout_opportunities: boxScore.misc.sideoutOpportunities,
|
|
27
|
+
misc_successful_sideouts: boxScore.misc.successfulSideouts
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function transformToObject(model) {
|
|
31
|
+
return {
|
|
32
|
+
playerId: model.player_id,
|
|
33
|
+
matchSetId: model.match_set_id,
|
|
34
|
+
attack: {
|
|
35
|
+
attempts: model.attack_attempts,
|
|
36
|
+
kills: model.attack_kills,
|
|
37
|
+
errors: model.attack_errors
|
|
38
|
+
},
|
|
39
|
+
serve: {
|
|
40
|
+
attempts: model.serve_attempts,
|
|
41
|
+
aces: model.serve_aces,
|
|
42
|
+
errors: model.serve_errors
|
|
43
|
+
},
|
|
44
|
+
reception: {
|
|
45
|
+
attempts: model.reception_attempts,
|
|
46
|
+
perfect: model.reception_perfect,
|
|
47
|
+
positive: model.reception_positive,
|
|
48
|
+
overpasses: model.reception_overpasses,
|
|
49
|
+
errors: model.reception_errors
|
|
50
|
+
},
|
|
51
|
+
block: {
|
|
52
|
+
solo: model.block_solo,
|
|
53
|
+
assists: model.block_assists,
|
|
54
|
+
errors: model.block_errors
|
|
55
|
+
},
|
|
56
|
+
setting: {
|
|
57
|
+
assists: model.setting_assists,
|
|
58
|
+
errors: model.setting_errors
|
|
59
|
+
},
|
|
60
|
+
defense: {
|
|
61
|
+
digs: model.defense_digs,
|
|
62
|
+
errors: model.defense_errors
|
|
63
|
+
},
|
|
64
|
+
misc: {
|
|
65
|
+
pointsPlayed: model.misc_points_played,
|
|
66
|
+
pointsWonOnCourt: model.misc_points_won_on_court,
|
|
67
|
+
serveTurns: model.misc_serve_turns,
|
|
68
|
+
sideoutOpportunities: model.misc_sideout_opportunities,
|
|
69
|
+
successfulSideouts: model.misc_successful_sideouts
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export { transformToObject as transformToBoxScore, transformToAttributes as transformFromBoxScore };
|
|
@@ -11,7 +11,7 @@ export * from './tournament-match';
|
|
|
11
11
|
export * from './stage';
|
|
12
12
|
export * from './match';
|
|
13
13
|
export * from './match-set';
|
|
14
|
-
export * from './
|
|
14
|
+
export * from './box-score';
|
|
15
15
|
export * from './performance-stats';
|
|
16
16
|
export * from './player';
|
|
17
17
|
export * from './rally';
|
|
@@ -11,7 +11,7 @@ export * from './tournament-match';
|
|
|
11
11
|
export * from './stage';
|
|
12
12
|
export * from './match';
|
|
13
13
|
export * from './match-set';
|
|
14
|
-
export * from './
|
|
14
|
+
export * from './box-score';
|
|
15
15
|
export * from './performance-stats';
|
|
16
16
|
export * from './player';
|
|
17
17
|
export * from './rally';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MatchSet } from '../../service';
|
|
2
|
-
import {
|
|
2
|
+
import { transformFromBoxScore, transformFromPlayerPosition as fromPosition, transformFromRally, transformToBoxScore, transformToPlayerPosition as toPosition, transformToRally } from '.';
|
|
3
3
|
function transformToAttributes(set, matchId) {
|
|
4
4
|
const homeSetPositions = set.homePlayerPosition.map(position => fromPosition(position, 'HOME', set.id));
|
|
5
5
|
const awaySetPositions = set.awayPlayerPosition.map(position => fromPosition(position, 'AWAY', set.id));
|
|
@@ -11,14 +11,13 @@ function transformToAttributes(set, matchId) {
|
|
|
11
11
|
home_score: set.homeScore,
|
|
12
12
|
away_score: set.awayScore,
|
|
13
13
|
SetPositions: [...homeSetPositions, ...awaySetPositions],
|
|
14
|
-
|
|
14
|
+
BoxScores: (set.boxScores ?? []).map(transformFromBoxScore),
|
|
15
15
|
Rallies: (set.rallies ?? []).map((rally) => transformFromRally(rally, set.id))
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function transformToObject(model) {
|
|
19
19
|
const homePlayerPosition = (model.SetPositions ?? []).filter((p) => p.side === 'HOME').map(toPosition);
|
|
20
20
|
const awayPlayerPosition = (model.SetPositions ?? []).filter((p) => p.side === 'AWAY').map(toPosition);
|
|
21
|
-
const stats = (model.MatchSetStats ?? []).map(transformToMatchSetStats);
|
|
22
21
|
const rallies = (model.Rallies ?? []).map(transformToRally).sort((r1, r2) => r1.order - r2.order);
|
|
23
22
|
return new MatchSet({
|
|
24
23
|
id: model.match_id,
|
|
@@ -26,10 +25,10 @@ function transformToObject(model) {
|
|
|
26
25
|
homeScore: model.home_score,
|
|
27
26
|
awayScore: model.away_score,
|
|
28
27
|
isTieBreak: model.is_tie_break,
|
|
28
|
+
boxScores: (model.BoxScores ?? []).map(transformToBoxScore),
|
|
29
29
|
homePlayerPosition,
|
|
30
30
|
awayPlayerPosition,
|
|
31
|
-
rallies
|
|
32
|
-
stats
|
|
31
|
+
rallies
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
34
|
export { transformToObject as transformToMatchSet, transformToAttributes as transformFromMatchSet };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { PlayerAttributes, PlayerModel } from '../models';
|
|
2
|
-
import { Player
|
|
2
|
+
import { Player } from '../../service';
|
|
3
3
|
declare function transformToAttributes(player: Player): PlayerAttributes;
|
|
4
4
|
declare function transformToObject(model: PlayerModel): Player;
|
|
5
|
-
export declare function calculateMatchStats(gameStats: SetStatistics[]): SetStatistics;
|
|
6
|
-
export declare function reduceStatsFn(acc: SetStatistics, current: SetStatistics): SetStatistics;
|
|
7
5
|
export { transformToObject as transformToPlayer, transformToAttributes as transformFromPlayer };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Player } from '../../service';
|
|
2
|
-
import { transformFromPerformanceStats,
|
|
2
|
+
import { transformFromPerformanceStats, transformToBoxScore, transformToCountry, transformToPerformanceStats } from '.';
|
|
3
3
|
function transformToAttributes(player) {
|
|
4
4
|
return {
|
|
5
5
|
player_id: player.id,
|
|
@@ -13,10 +13,6 @@ function transformToAttributes(player) {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
function transformToObject(model) {
|
|
16
|
-
const gameStats = (model.MatchSetStats ?? []).map(transformToMatchSetStats);
|
|
17
|
-
if (gameStats.length > 0) {
|
|
18
|
-
gameStats.push(calculateMatchStats(gameStats));
|
|
19
|
-
}
|
|
20
16
|
return new Player({
|
|
21
17
|
id: model.player_id,
|
|
22
18
|
name: {
|
|
@@ -28,48 +24,7 @@ function transformToObject(model) {
|
|
|
28
24
|
traits: model.traits,
|
|
29
25
|
stats: transformToPerformanceStats(model.PerformanceStat),
|
|
30
26
|
rarity: model.rarity,
|
|
31
|
-
|
|
27
|
+
boxScores: (model.BoxScores ?? []).map(transformToBoxScore)
|
|
32
28
|
});
|
|
33
29
|
}
|
|
34
|
-
export function calculateMatchStats(gameStats) {
|
|
35
|
-
const emptyStats = {
|
|
36
|
-
playerId: gameStats[0].playerId,
|
|
37
|
-
attempts: 0,
|
|
38
|
-
contacts: 0,
|
|
39
|
-
ralliesPlayed: 0,
|
|
40
|
-
serve: { success: 0, error: 0 },
|
|
41
|
-
reception: { success: 0, error: 0 },
|
|
42
|
-
set: { success: 0, error: 0 },
|
|
43
|
-
attack: { success: 0, error: 0 },
|
|
44
|
-
block: { success: 0, error: 0 },
|
|
45
|
-
kills: 0,
|
|
46
|
-
killBlocks: 0,
|
|
47
|
-
ace: 0,
|
|
48
|
-
assists: 0,
|
|
49
|
-
order: gameStats.length,
|
|
50
|
-
setsPlayed: 0
|
|
51
|
-
};
|
|
52
|
-
return gameStats.reduce(reduceStatsFn, emptyStats);
|
|
53
|
-
}
|
|
54
|
-
export function reduceStatsFn(acc, current) {
|
|
55
|
-
acc.attempts += current.attempts;
|
|
56
|
-
acc.contacts += current.contacts;
|
|
57
|
-
acc.ralliesPlayed += current.ralliesPlayed;
|
|
58
|
-
acc.kills += current.kills;
|
|
59
|
-
acc.killBlocks += current.killBlocks;
|
|
60
|
-
acc.ace += current.ace;
|
|
61
|
-
acc.assists += current.assists;
|
|
62
|
-
acc.serve.success += current.serve.success;
|
|
63
|
-
acc.serve.error += current.serve.error;
|
|
64
|
-
acc.reception.success += current.reception.success;
|
|
65
|
-
acc.reception.error += current.reception.error;
|
|
66
|
-
acc.set.success += current.set.success;
|
|
67
|
-
acc.set.error += current.set.error;
|
|
68
|
-
acc.attack.success += current.attack.success;
|
|
69
|
-
acc.attack.error += current.attack.error;
|
|
70
|
-
acc.block.success += current.block.success;
|
|
71
|
-
acc.block.error += current.block.error;
|
|
72
|
-
acc.setsPlayed++;
|
|
73
|
-
return acc;
|
|
74
|
-
}
|
|
75
30
|
export { transformToObject as transformToPlayer, transformToAttributes as transformFromPlayer };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export interface AttackStats {
|
|
2
|
+
attempts: number;
|
|
3
|
+
kills: number;
|
|
4
|
+
errors: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ServeStats {
|
|
7
|
+
attempts: number;
|
|
8
|
+
aces: number;
|
|
9
|
+
errors: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ReceptionStats {
|
|
12
|
+
attempts: number;
|
|
13
|
+
perfect: number;
|
|
14
|
+
positive: number;
|
|
15
|
+
overpasses: number;
|
|
16
|
+
errors: number;
|
|
17
|
+
}
|
|
18
|
+
export interface BlockStats {
|
|
19
|
+
solo: number;
|
|
20
|
+
assists: number;
|
|
21
|
+
errors: number;
|
|
22
|
+
}
|
|
23
|
+
export interface SettingStats {
|
|
24
|
+
assists: number;
|
|
25
|
+
errors: number;
|
|
26
|
+
}
|
|
27
|
+
export interface DefenseStats {
|
|
28
|
+
digs: number;
|
|
29
|
+
errors: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Misc stats are about participation and rotation impact.
|
|
33
|
+
* These are *incredibly* useful for analytics and AI later.
|
|
34
|
+
*/
|
|
35
|
+
export interface MiscStats {
|
|
36
|
+
/** Number of rallies this player was on the court in this set */
|
|
37
|
+
pointsPlayed: number;
|
|
38
|
+
/** Rallies won by the team while this player was on the court in this set */
|
|
39
|
+
pointsWonOnCourt: number;
|
|
40
|
+
/** How many distinct serve turns the player had in this set (i.e. times they went back to serve) */
|
|
41
|
+
serveTurns: number;
|
|
42
|
+
/** Number of sideout opportunities while the player was on court (optional but handy) */
|
|
43
|
+
sideoutOpportunities: number;
|
|
44
|
+
/** Number of successful sideouts while the player was on court (optional but handy) */
|
|
45
|
+
successfulSideouts: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Per-player, per-set box score row
|
|
49
|
+
* =================================
|
|
50
|
+
* This is the fundamental unit you store.
|
|
51
|
+
*/
|
|
52
|
+
export interface BoxScore {
|
|
53
|
+
playerId: string;
|
|
54
|
+
matchSetId: string;
|
|
55
|
+
attack: AttackStats;
|
|
56
|
+
serve: ServeStats;
|
|
57
|
+
reception: ReceptionStats;
|
|
58
|
+
block: BlockStats;
|
|
59
|
+
setting: SettingStats;
|
|
60
|
+
defense: DefenseStats;
|
|
61
|
+
misc: MiscStats;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Utility: zeroed-out stat factories
|
|
65
|
+
* ==================================
|
|
66
|
+
* Handy to initialize objects when you start a new set.
|
|
67
|
+
*/
|
|
68
|
+
export declare const createEmptyAttackStats: () => AttackStats;
|
|
69
|
+
export declare const createEmptyServeStats: () => ServeStats;
|
|
70
|
+
export declare const createEmptyReceptionStats: () => ReceptionStats;
|
|
71
|
+
export declare const createEmptyBlockStats: () => BlockStats;
|
|
72
|
+
export declare const createEmptySettingStats: () => SettingStats;
|
|
73
|
+
export declare const createEmptyDefenseStats: () => DefenseStats;
|
|
74
|
+
export declare const createEmptyMiscStats: () => MiscStats;
|
|
75
|
+
export declare const createEmptyBoxScore: (playerId: string, matchSetId: string) => BoxScore;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility: zeroed-out stat factories
|
|
3
|
+
* ==================================
|
|
4
|
+
* Handy to initialize objects when you start a new set.
|
|
5
|
+
*/
|
|
6
|
+
export const createEmptyAttackStats = () => ({
|
|
7
|
+
attempts: 0,
|
|
8
|
+
kills: 0,
|
|
9
|
+
errors: 0
|
|
10
|
+
});
|
|
11
|
+
export const createEmptyServeStats = () => ({
|
|
12
|
+
attempts: 0,
|
|
13
|
+
aces: 0,
|
|
14
|
+
errors: 0
|
|
15
|
+
});
|
|
16
|
+
export const createEmptyReceptionStats = () => ({
|
|
17
|
+
attempts: 0,
|
|
18
|
+
perfect: 0,
|
|
19
|
+
positive: 0,
|
|
20
|
+
overpasses: 0,
|
|
21
|
+
errors: 0
|
|
22
|
+
});
|
|
23
|
+
export const createEmptyBlockStats = () => ({
|
|
24
|
+
solo: 0,
|
|
25
|
+
assists: 0,
|
|
26
|
+
errors: 0
|
|
27
|
+
});
|
|
28
|
+
export const createEmptySettingStats = () => ({
|
|
29
|
+
assists: 0,
|
|
30
|
+
errors: 0
|
|
31
|
+
});
|
|
32
|
+
export const createEmptyDefenseStats = () => ({
|
|
33
|
+
digs: 0,
|
|
34
|
+
errors: 0
|
|
35
|
+
});
|
|
36
|
+
export const createEmptyMiscStats = () => ({
|
|
37
|
+
pointsPlayed: 0,
|
|
38
|
+
pointsWonOnCourt: 0,
|
|
39
|
+
serveTurns: 0,
|
|
40
|
+
sideoutOpportunities: 0,
|
|
41
|
+
successfulSideouts: 0
|
|
42
|
+
});
|
|
43
|
+
export const createEmptyBoxScore = (playerId, matchSetId) => ({
|
|
44
|
+
playerId,
|
|
45
|
+
matchSetId,
|
|
46
|
+
attack: createEmptyAttackStats(),
|
|
47
|
+
serve: createEmptyServeStats(),
|
|
48
|
+
reception: createEmptyReceptionStats(),
|
|
49
|
+
block: createEmptyBlockStats(),
|
|
50
|
+
setting: createEmptySettingStats(),
|
|
51
|
+
defense: createEmptyDefenseStats(),
|
|
52
|
+
misc: createEmptyMiscStats()
|
|
53
|
+
});
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { PlayerPosition, Rally } from './rally';
|
|
2
2
|
import { MatchTeam } from './match-team';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
TIE_BREAK = 15
|
|
6
|
-
}
|
|
3
|
+
import { BoxScore } from './box-score';
|
|
4
|
+
type ScoreThreshold = 25 | 15;
|
|
7
5
|
interface MatchSetParams {
|
|
8
6
|
readonly id: string;
|
|
9
7
|
readonly order: number;
|
|
@@ -12,42 +10,21 @@ interface MatchSetParams {
|
|
|
12
10
|
readonly awayPlayerPosition: PlayerPosition[];
|
|
13
11
|
readonly homeScore: number;
|
|
14
12
|
readonly awayScore: number;
|
|
15
|
-
readonly
|
|
13
|
+
readonly boxScores: BoxScore[];
|
|
16
14
|
readonly rallies: Rally[];
|
|
17
15
|
}
|
|
18
|
-
export interface EventStat {
|
|
19
|
-
success: number;
|
|
20
|
-
error: number;
|
|
21
|
-
}
|
|
22
|
-
export interface SetStatistics {
|
|
23
|
-
readonly playerId: string;
|
|
24
|
-
order: number;
|
|
25
|
-
ace: number;
|
|
26
|
-
attempts: number;
|
|
27
|
-
contacts: number;
|
|
28
|
-
ralliesPlayed: number;
|
|
29
|
-
serve: EventStat;
|
|
30
|
-
reception: EventStat;
|
|
31
|
-
set: EventStat;
|
|
32
|
-
attack: EventStat;
|
|
33
|
-
block: EventStat;
|
|
34
|
-
kills: number;
|
|
35
|
-
killBlocks: number;
|
|
36
|
-
assists: number;
|
|
37
|
-
setsPlayed: number;
|
|
38
|
-
}
|
|
39
16
|
export declare class MatchSet {
|
|
40
17
|
readonly id: string;
|
|
41
18
|
readonly order: number;
|
|
42
19
|
readonly isTieBreak: boolean;
|
|
43
20
|
readonly homePlayerPosition: PlayerPosition[];
|
|
44
21
|
readonly awayPlayerPosition: PlayerPosition[];
|
|
45
|
-
readonly
|
|
22
|
+
readonly boxScores: BoxScore[];
|
|
46
23
|
readonly rallies: Rally[];
|
|
47
24
|
readonly scoreThreshold: ScoreThreshold;
|
|
48
25
|
private _homeScore;
|
|
49
26
|
private _awayScore;
|
|
50
|
-
constructor({ id, order, isTieBreak, homePlayerPosition, awayPlayerPosition,
|
|
27
|
+
constructor({ id, order, isTieBreak, homePlayerPosition, awayPlayerPosition, boxScores, rallies, homeScore, awayScore }: MatchSetParams);
|
|
51
28
|
get homeScore(): number;
|
|
52
29
|
get awayScore(): number;
|
|
53
30
|
increaseScore(team: MatchTeam): void;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { validateUUID } from '../utils';
|
|
2
2
|
import { MatchTeam } from './match-team';
|
|
3
|
-
var ScoreThreshold;
|
|
4
|
-
(function (ScoreThreshold) {
|
|
5
|
-
ScoreThreshold[ScoreThreshold["SET"] = 25] = "SET";
|
|
6
|
-
ScoreThreshold[ScoreThreshold["TIE_BREAK"] = 15] = "TIE_BREAK";
|
|
7
|
-
})(ScoreThreshold || (ScoreThreshold = {}));
|
|
8
3
|
export class MatchSet {
|
|
9
|
-
constructor({ id, order, isTieBreak, homePlayerPosition, awayPlayerPosition,
|
|
4
|
+
constructor({ id, order, isTieBreak, homePlayerPosition, awayPlayerPosition, boxScores, rallies, homeScore, awayScore }) {
|
|
10
5
|
validateUUID(id);
|
|
11
6
|
this.id = id;
|
|
12
7
|
this.order = order;
|
|
@@ -14,10 +9,10 @@ export class MatchSet {
|
|
|
14
9
|
this._awayScore = awayScore;
|
|
15
10
|
this.homePlayerPosition = homePlayerPosition;
|
|
16
11
|
this.awayPlayerPosition = awayPlayerPosition;
|
|
17
|
-
this.
|
|
12
|
+
this.boxScores = boxScores;
|
|
18
13
|
this.rallies = rallies;
|
|
19
14
|
this.isTieBreak = isTieBreak;
|
|
20
|
-
this.scoreThreshold = isTieBreak ?
|
|
15
|
+
this.scoreThreshold = isTieBreak ? 15 : 25;
|
|
21
16
|
}
|
|
22
17
|
get homeScore() {
|
|
23
18
|
return this._homeScore;
|
|
@@ -24,7 +24,7 @@ export class Match {
|
|
|
24
24
|
this.winner = winner;
|
|
25
25
|
}
|
|
26
26
|
addSet(set) {
|
|
27
|
-
if (this.sets.length >=
|
|
27
|
+
if (this.sets.length >= 5)
|
|
28
28
|
throw new Error('SET_AMOUNT_EXCEEDED');
|
|
29
29
|
this.sets.push(set);
|
|
30
30
|
}
|
|
@@ -35,13 +35,12 @@ export class Match {
|
|
|
35
35
|
return `${this.getTeamSets(MatchTeam.HOME)}-${this.getTeamSets(MatchTeam.AWAY)}`;
|
|
36
36
|
}
|
|
37
37
|
isOver() {
|
|
38
|
-
const gamesRequired =
|
|
38
|
+
const gamesRequired = 3;
|
|
39
39
|
const lastSet = this.sets.at(-1);
|
|
40
40
|
if (lastSet == null || !lastSet.isOver() || this.sets.length < gamesRequired)
|
|
41
41
|
return false;
|
|
42
42
|
const homeSets = this.getTeamSets(MatchTeam.HOME);
|
|
43
43
|
const awaySets = this.getTeamSets(MatchTeam.AWAY);
|
|
44
|
-
// Check if any of the teams has enough sets to win.
|
|
45
44
|
return !(homeSets < gamesRequired && awaySets < gamesRequired);
|
|
46
45
|
}
|
|
47
46
|
getWinner() {
|
|
@@ -61,4 +60,3 @@ export class Match {
|
|
|
61
60
|
return this.status === StatusEnum.COMPLETE;
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
|
-
Match.BEST_OF = 5;
|
|
@@ -4,7 +4,7 @@ import { Country } from '../country';
|
|
|
4
4
|
import { Rarity } from './rarity';
|
|
5
5
|
import { Stats } from './stats';
|
|
6
6
|
import { Role } from './role';
|
|
7
|
-
import {
|
|
7
|
+
import { BoxScore } from '../match';
|
|
8
8
|
export declare class Stat {
|
|
9
9
|
readonly name: Stats;
|
|
10
10
|
readonly value: number;
|
|
@@ -22,7 +22,7 @@ interface PlayerParams {
|
|
|
22
22
|
readonly roles: Role[];
|
|
23
23
|
readonly traits: Trait[];
|
|
24
24
|
readonly rarity: Rarity;
|
|
25
|
-
readonly
|
|
25
|
+
readonly boxScores?: BoxScore[];
|
|
26
26
|
}
|
|
27
27
|
export declare class Name {
|
|
28
28
|
readonly first: string;
|
|
@@ -42,8 +42,8 @@ export declare class Player {
|
|
|
42
42
|
readonly traits: Trait[];
|
|
43
43
|
readonly generalStats: Stat[];
|
|
44
44
|
readonly rarity: Rarity;
|
|
45
|
-
readonly
|
|
46
|
-
constructor({ id, name, country, stats, roles, traits, rarity,
|
|
45
|
+
readonly boxScores?: BoxScore[];
|
|
46
|
+
constructor({ id, name, country, stats, roles, traits, rarity, boxScores }: PlayerParams);
|
|
47
47
|
static sortPlayers(roles: Role[]): (p1: Player, p2: Player) => number;
|
|
48
48
|
static compareStats(p1: Player, p2: Player): number;
|
|
49
49
|
toString(): string;
|
|
@@ -20,7 +20,7 @@ export class Name {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
export class Player {
|
|
23
|
-
constructor({ id, name, country, stats, roles, traits, rarity,
|
|
23
|
+
constructor({ id, name, country, stats, roles, traits, rarity, boxScores }) {
|
|
24
24
|
validateUUID(id);
|
|
25
25
|
this.id = id;
|
|
26
26
|
this.name = name;
|
|
@@ -29,7 +29,7 @@ export class Player {
|
|
|
29
29
|
this.roles = roles;
|
|
30
30
|
this.traits = traits;
|
|
31
31
|
this.rarity = rarity;
|
|
32
|
-
this.
|
|
32
|
+
this.boxScores = boxScores;
|
|
33
33
|
this.generalStats = Object.values(StatsEnum).map((stat) => ({
|
|
34
34
|
name: stat,
|
|
35
35
|
value: calculateStatScore(stats, stat)
|