volleyballsimtypes 0.0.173 → 0.0.175
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/transformers/match-set-stats.d.ts +1 -1
- package/dist/cjs/src/data/transformers/match-set-stats.js +5 -4
- package/dist/cjs/src/data/transformers/player.d.ts +3 -1
- package/dist/cjs/src/data/transformers/player.js +50 -2
- package/dist/cjs/src/data/transformers/team.d.ts +1 -1
- package/dist/cjs/src/data/transformers/team.js +9 -8
- package/dist/cjs/src/service/match/match-set.d.ts +4 -3
- package/dist/cjs/src/service/match/match-set.js +1 -1
- package/dist/cjs/src/service/player/player.d.ts +4 -1
- package/dist/cjs/src/service/player/player.js +2 -1
- package/dist/cjs/src/service/player/role.js +7 -1
- package/dist/cjs/src/service/player/stats.js +7 -5
- package/dist/esm/src/data/transformers/match-set-stats.d.ts +1 -1
- package/dist/esm/src/data/transformers/match-set-stats.js +5 -4
- package/dist/esm/src/data/transformers/player.d.ts +3 -1
- package/dist/esm/src/data/transformers/player.js +48 -2
- package/dist/esm/src/data/transformers/team.d.ts +1 -1
- package/dist/esm/src/data/transformers/team.js +10 -9
- package/dist/esm/src/service/match/match-set.d.ts +4 -3
- package/dist/esm/src/service/match/match-set.js +1 -1
- package/dist/esm/src/service/player/player.d.ts +4 -1
- package/dist/esm/src/service/player/player.js +2 -1
- package/dist/esm/src/service/player/role.js +7 -1
- package/dist/esm/src/service/player/stats.js +7 -5
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MatchSetStatsAttributes, MatchSetStatsModel } from '../models';
|
|
2
2
|
import { SetStatistics } from '../../service';
|
|
3
3
|
declare function transformToAttributes(stats: SetStatistics, setId: string): MatchSetStatsAttributes;
|
|
4
|
-
declare function transformToObject(model: MatchSetStatsModel): SetStatistics;
|
|
4
|
+
declare function transformToObject(model: MatchSetStatsModel, index: number): SetStatistics;
|
|
5
5
|
export { transformToObject as transformToMatchSetStats, transformToAttributes as transformFromMatchSetStats };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformFromMatchSetStats = exports.transformToMatchSetStats = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
4
|
function transformToAttributes(stats, setId) {
|
|
6
5
|
return {
|
|
7
|
-
player_id: stats.
|
|
6
|
+
player_id: stats.playerId,
|
|
8
7
|
match_set_id: setId,
|
|
9
8
|
aces: stats.ace,
|
|
10
9
|
assists: stats.assists,
|
|
@@ -26,7 +25,7 @@ function transformToAttributes(stats, setId) {
|
|
|
26
25
|
};
|
|
27
26
|
}
|
|
28
27
|
exports.transformFromMatchSetStats = transformToAttributes;
|
|
29
|
-
function transformToObject(model) {
|
|
28
|
+
function transformToObject(model, index) {
|
|
30
29
|
return {
|
|
31
30
|
set: {
|
|
32
31
|
success: model.set_success,
|
|
@@ -55,7 +54,9 @@ function transformToObject(model) {
|
|
|
55
54
|
assists: model.assists,
|
|
56
55
|
ralliesPlayed: model.rallies_played,
|
|
57
56
|
attempts: model.attempts,
|
|
58
|
-
|
|
57
|
+
playerId: model.player_id,
|
|
58
|
+
order: index,
|
|
59
|
+
setsPlayed: 0
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
exports.transformToMatchSetStats = transformToObject;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { PlayerAttributes, PlayerModel } from '../models';
|
|
2
|
-
import { Player } from '../../service';
|
|
2
|
+
import { Player, SetStatistics } 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;
|
|
5
7
|
export { transformToObject as transformToPlayer, transformToAttributes as transformFromPlayer };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformFromPlayer = exports.transformToPlayer = void 0;
|
|
3
|
+
exports.transformFromPlayer = exports.transformToPlayer = exports.reduceStatsFn = exports.calculateMatchStats = void 0;
|
|
4
4
|
const service_1 = require("../../service");
|
|
5
5
|
const _1 = require(".");
|
|
6
6
|
function transformToAttributes(player) {
|
|
@@ -17,6 +17,10 @@ function transformToAttributes(player) {
|
|
|
17
17
|
}
|
|
18
18
|
exports.transformFromPlayer = transformToAttributes;
|
|
19
19
|
function transformToObject(model) {
|
|
20
|
+
const gameStats = (model.MatchSetStats ?? []).map(_1.transformToMatchSetStats);
|
|
21
|
+
if (gameStats.length > 0) {
|
|
22
|
+
gameStats.push(calculateMatchStats(gameStats));
|
|
23
|
+
}
|
|
20
24
|
return new service_1.Player({
|
|
21
25
|
id: model.player_id,
|
|
22
26
|
name: {
|
|
@@ -27,7 +31,51 @@ function transformToObject(model) {
|
|
|
27
31
|
roles: model.roles,
|
|
28
32
|
traits: model.traits,
|
|
29
33
|
stats: (0, _1.transformToPerformanceStats)(model.PerformanceStat),
|
|
30
|
-
rarity: model.rarity
|
|
34
|
+
rarity: model.rarity,
|
|
35
|
+
gameStats
|
|
31
36
|
});
|
|
32
37
|
}
|
|
33
38
|
exports.transformToPlayer = transformToObject;
|
|
39
|
+
function calculateMatchStats(gameStats) {
|
|
40
|
+
const emptyStats = {
|
|
41
|
+
playerId: gameStats[0].playerId,
|
|
42
|
+
attempts: 0,
|
|
43
|
+
contacts: 0,
|
|
44
|
+
ralliesPlayed: 0,
|
|
45
|
+
serve: { success: 0, error: 0 },
|
|
46
|
+
reception: { success: 0, error: 0 },
|
|
47
|
+
set: { success: 0, error: 0 },
|
|
48
|
+
attack: { success: 0, error: 0 },
|
|
49
|
+
block: { success: 0, error: 0 },
|
|
50
|
+
kills: 0,
|
|
51
|
+
killBlocks: 0,
|
|
52
|
+
ace: 0,
|
|
53
|
+
assists: 0,
|
|
54
|
+
order: gameStats.length,
|
|
55
|
+
setsPlayed: 0
|
|
56
|
+
};
|
|
57
|
+
return gameStats.reduce(reduceStatsFn, emptyStats);
|
|
58
|
+
}
|
|
59
|
+
exports.calculateMatchStats = calculateMatchStats;
|
|
60
|
+
function reduceStatsFn(acc, current) {
|
|
61
|
+
acc.attempts += current.attempts;
|
|
62
|
+
acc.contacts += current.contacts;
|
|
63
|
+
acc.ralliesPlayed += current.ralliesPlayed;
|
|
64
|
+
acc.kills += current.kills;
|
|
65
|
+
acc.killBlocks += current.killBlocks;
|
|
66
|
+
acc.ace += current.ace;
|
|
67
|
+
acc.assists += current.assists;
|
|
68
|
+
acc.serve.success += current.serve.success;
|
|
69
|
+
acc.serve.error += current.serve.error;
|
|
70
|
+
acc.reception.success += current.reception.success;
|
|
71
|
+
acc.reception.error += current.reception.error;
|
|
72
|
+
acc.set.success += current.set.success;
|
|
73
|
+
acc.set.error += current.set.error;
|
|
74
|
+
acc.attack.success += current.attack.success;
|
|
75
|
+
acc.attack.error += current.attack.error;
|
|
76
|
+
acc.block.success += current.block.success;
|
|
77
|
+
acc.block.error += current.block.error;
|
|
78
|
+
acc.setsPlayed++;
|
|
79
|
+
return acc;
|
|
80
|
+
}
|
|
81
|
+
exports.reduceStatsFn = reduceStatsFn;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Team } from '../../service';
|
|
2
2
|
import { TeamAttributes, TeamModel } from '../models';
|
|
3
3
|
declare function transformToAttributes(team: Team): TeamAttributes;
|
|
4
|
-
declare function transformToObject(
|
|
4
|
+
declare function transformToObject(model: TeamModel): Team;
|
|
5
5
|
export { transformToObject as transformToTeam, transformToAttributes as transformFromTeam };
|
|
@@ -16,15 +16,16 @@ function transformToAttributes(team) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
exports.transformFromTeam = transformToAttributes;
|
|
19
|
-
function transformToObject(
|
|
19
|
+
function transformToObject(model) {
|
|
20
20
|
return new service_1.Team({
|
|
21
|
-
id:
|
|
22
|
-
name:
|
|
23
|
-
shortName:
|
|
24
|
-
country:
|
|
25
|
-
coach:
|
|
26
|
-
roster: (
|
|
27
|
-
|
|
21
|
+
id: model.team_id,
|
|
22
|
+
name: model.name,
|
|
23
|
+
shortName: model.short_name,
|
|
24
|
+
country: model.country != null ? (0, _1.transformToCountry)(model.country) : undefined,
|
|
25
|
+
coach: model.coach != null ? (0, _1.transformToCoach)(model.coach) : undefined,
|
|
26
|
+
roster: (model.PlayerTeams ?? []).map((pt) => (0, _1.transformToPlayer)(pt.player)),
|
|
27
|
+
league: model.league != null ? (0, _1.transformToLeague)(model.league) : undefined,
|
|
28
|
+
rating: model.rating
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
31
|
exports.transformToTeam = transformToObject;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PlayerPosition, Rally } from './rally';
|
|
2
2
|
import { MatchTeam } from './match-team';
|
|
3
|
-
import { Player } from '../player';
|
|
4
3
|
declare enum ScoreThreshold {
|
|
5
4
|
SET = 25,
|
|
6
5
|
TIE_BREAK = 15
|
|
@@ -21,7 +20,8 @@ export interface EventStat {
|
|
|
21
20
|
error: number;
|
|
22
21
|
}
|
|
23
22
|
export interface SetStatistics {
|
|
24
|
-
|
|
23
|
+
readonly playerId: string;
|
|
24
|
+
order: number;
|
|
25
25
|
ace: number;
|
|
26
26
|
attempts: number;
|
|
27
27
|
contacts: number;
|
|
@@ -34,6 +34,7 @@ export interface SetStatistics {
|
|
|
34
34
|
kills: number;
|
|
35
35
|
killBlocks: number;
|
|
36
36
|
assists: number;
|
|
37
|
+
setsPlayed: number;
|
|
37
38
|
}
|
|
38
39
|
export declare class MatchSet {
|
|
39
40
|
readonly id: string;
|
|
@@ -52,7 +53,7 @@ export declare class MatchSet {
|
|
|
52
53
|
increaseScore(team: MatchTeam): void;
|
|
53
54
|
addRally(rally: Rally): void;
|
|
54
55
|
/**
|
|
55
|
-
* Has a team reached at least 25 points and is the score difference between both teams at least 2?
|
|
56
|
+
* Has a team reached at least 25 points, and is the score difference between both teams at least 2?
|
|
56
57
|
* @returns boolean
|
|
57
58
|
*/
|
|
58
59
|
isOver(): boolean;
|
|
@@ -40,7 +40,7 @@ class MatchSet {
|
|
|
40
40
|
this.rallies.push(rally);
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* Has a team reached at least 25 points and is the score difference between both teams at least 2?
|
|
43
|
+
* Has a team reached at least 25 points, and is the score difference between both teams at least 2?
|
|
44
44
|
* @returns boolean
|
|
45
45
|
*/
|
|
46
46
|
isOver() {
|
|
@@ -4,6 +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 { SetStatistics } from '../match';
|
|
7
8
|
export declare class Stat {
|
|
8
9
|
readonly name: Stats;
|
|
9
10
|
readonly value: number;
|
|
@@ -21,6 +22,7 @@ interface PlayerParams {
|
|
|
21
22
|
readonly roles: Role[];
|
|
22
23
|
readonly traits: Trait[];
|
|
23
24
|
readonly rarity: Rarity;
|
|
25
|
+
readonly gameStats?: SetStatistics[];
|
|
24
26
|
}
|
|
25
27
|
export declare class Name {
|
|
26
28
|
readonly first: string;
|
|
@@ -40,7 +42,8 @@ export declare class Player {
|
|
|
40
42
|
readonly traits: Trait[];
|
|
41
43
|
readonly generalStats: Stat[];
|
|
42
44
|
readonly rarity: Rarity;
|
|
43
|
-
|
|
45
|
+
readonly gameStats?: SetStatistics[];
|
|
46
|
+
constructor({ id, name, country, stats, roles, traits, rarity, gameStats }: PlayerParams);
|
|
44
47
|
static sortPlayers(roles: Role[]): (p1: Player, p2: Player) => number;
|
|
45
48
|
static compareStats(p1: Player, p2: Player): number;
|
|
46
49
|
toString(): string;
|
|
@@ -25,7 +25,7 @@ class Name {
|
|
|
25
25
|
}
|
|
26
26
|
exports.Name = Name;
|
|
27
27
|
class Player {
|
|
28
|
-
constructor({ id, name, country, stats, roles, traits, rarity }) {
|
|
28
|
+
constructor({ id, name, country, stats, roles, traits, rarity, gameStats }) {
|
|
29
29
|
(0, utils_1.validateUUID)(id);
|
|
30
30
|
this.id = id;
|
|
31
31
|
this.name = name;
|
|
@@ -34,6 +34,7 @@ class Player {
|
|
|
34
34
|
this.roles = roles;
|
|
35
35
|
this.traits = traits;
|
|
36
36
|
this.rarity = rarity;
|
|
37
|
+
this.gameStats = gameStats;
|
|
37
38
|
this.generalStats = Object.values(stats_1.StatsEnum).map((stat) => ({
|
|
38
39
|
name: stat,
|
|
39
40
|
value: (0, stats_1.calculateStatScore)(stats, stat)
|
|
@@ -40,9 +40,15 @@ function assignRoles(stats) {
|
|
|
40
40
|
if (scores[1].score >= 75) {
|
|
41
41
|
out.push(scores[1].role);
|
|
42
42
|
}
|
|
43
|
-
if (scores[2].score >=
|
|
43
|
+
if (scores[2].score >= 82) {
|
|
44
44
|
out.push(scores[2].role);
|
|
45
45
|
}
|
|
46
|
+
if (scores[3].score >= 89) {
|
|
47
|
+
out.push(scores[3].role);
|
|
48
|
+
}
|
|
49
|
+
if (scores[4].score >= 95) {
|
|
50
|
+
out.push(scores[4].role);
|
|
51
|
+
}
|
|
46
52
|
return out;
|
|
47
53
|
}
|
|
48
54
|
exports.assignRoles = assignRoles;
|
|
@@ -38,10 +38,11 @@ function getMultipliers(statName, performanceStats) {
|
|
|
38
38
|
case StatsEnum.RECEIVE:
|
|
39
39
|
return {
|
|
40
40
|
reception: 0.75,
|
|
41
|
-
overhand: 0.
|
|
41
|
+
overhand: 0.015,
|
|
42
42
|
bump: 0.15,
|
|
43
|
-
focus: 0.
|
|
44
|
-
defense: 0.
|
|
43
|
+
focus: 0.015,
|
|
44
|
+
defense: 0.055,
|
|
45
|
+
reflex: 0.015
|
|
45
46
|
};
|
|
46
47
|
case StatsEnum.SERVE:
|
|
47
48
|
return {
|
|
@@ -54,8 +55,9 @@ function getMultipliers(statName, performanceStats) {
|
|
|
54
55
|
block: 0.65,
|
|
55
56
|
read: performanceStats == null ? 0.125 : performanceStats.read > performanceStats.commit ? 0.2 : 0.05,
|
|
56
57
|
commit: performanceStats == null ? 0.125 : performanceStats.commit > performanceStats.read ? 0.2 : 0.05,
|
|
57
|
-
focus: 0.
|
|
58
|
-
defense: 0.
|
|
58
|
+
focus: 0.04,
|
|
59
|
+
defense: 0.04,
|
|
60
|
+
reflex: 0.02
|
|
59
61
|
};
|
|
60
62
|
case StatsEnum.STAMINA:
|
|
61
63
|
return { stamina: 1 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MatchSetStatsAttributes, MatchSetStatsModel } from '../models';
|
|
2
2
|
import { SetStatistics } from '../../service';
|
|
3
3
|
declare function transformToAttributes(stats: SetStatistics, setId: string): MatchSetStatsAttributes;
|
|
4
|
-
declare function transformToObject(model: MatchSetStatsModel): SetStatistics;
|
|
4
|
+
declare function transformToObject(model: MatchSetStatsModel, index: number): SetStatistics;
|
|
5
5
|
export { transformToObject as transformToMatchSetStats, transformToAttributes as transformFromMatchSetStats };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { transformToPlayer } from '.';
|
|
2
1
|
function transformToAttributes(stats, setId) {
|
|
3
2
|
return {
|
|
4
|
-
player_id: stats.
|
|
3
|
+
player_id: stats.playerId,
|
|
5
4
|
match_set_id: setId,
|
|
6
5
|
aces: stats.ace,
|
|
7
6
|
assists: stats.assists,
|
|
@@ -22,7 +21,7 @@ function transformToAttributes(stats, setId) {
|
|
|
22
21
|
kill_blocks: stats.killBlocks
|
|
23
22
|
};
|
|
24
23
|
}
|
|
25
|
-
function transformToObject(model) {
|
|
24
|
+
function transformToObject(model, index) {
|
|
26
25
|
return {
|
|
27
26
|
set: {
|
|
28
27
|
success: model.set_success,
|
|
@@ -51,7 +50,9 @@ function transformToObject(model) {
|
|
|
51
50
|
assists: model.assists,
|
|
52
51
|
ralliesPlayed: model.rallies_played,
|
|
53
52
|
attempts: model.attempts,
|
|
54
|
-
|
|
53
|
+
playerId: model.player_id,
|
|
54
|
+
order: index,
|
|
55
|
+
setsPlayed: 0
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
export { transformToObject as transformToMatchSetStats, transformToAttributes as transformFromMatchSetStats };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { PlayerAttributes, PlayerModel } from '../models';
|
|
2
|
-
import { Player } from '../../service';
|
|
2
|
+
import { Player, SetStatistics } 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;
|
|
5
7
|
export { transformToObject as transformToPlayer, transformToAttributes as transformFromPlayer };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Player } from '../../service';
|
|
2
|
-
import { transformFromPerformanceStats, transformToCountry, transformToPerformanceStats } from '.';
|
|
2
|
+
import { transformFromPerformanceStats, transformToCountry, transformToMatchSetStats, transformToPerformanceStats } from '.';
|
|
3
3
|
function transformToAttributes(player) {
|
|
4
4
|
return {
|
|
5
5
|
player_id: player.id,
|
|
@@ -13,6 +13,10 @@ 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
|
+
}
|
|
16
20
|
return new Player({
|
|
17
21
|
id: model.player_id,
|
|
18
22
|
name: {
|
|
@@ -23,7 +27,49 @@ function transformToObject(model) {
|
|
|
23
27
|
roles: model.roles,
|
|
24
28
|
traits: model.traits,
|
|
25
29
|
stats: transformToPerformanceStats(model.PerformanceStat),
|
|
26
|
-
rarity: model.rarity
|
|
30
|
+
rarity: model.rarity,
|
|
31
|
+
gameStats
|
|
27
32
|
});
|
|
28
33
|
}
|
|
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
|
+
}
|
|
29
75
|
export { transformToObject as transformToPlayer, transformToAttributes as transformFromPlayer };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Team } from '../../service';
|
|
2
2
|
import { TeamAttributes, TeamModel } from '../models';
|
|
3
3
|
declare function transformToAttributes(team: Team): TeamAttributes;
|
|
4
|
-
declare function transformToObject(
|
|
4
|
+
declare function transformToObject(model: TeamModel): Team;
|
|
5
5
|
export { transformToObject as transformToTeam, transformToAttributes as transformFromTeam };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Team } from '../../service';
|
|
2
|
-
import { transformFromCoach, transformToCoach, transformToCountry, transformToPlayer } from '.';
|
|
2
|
+
import { transformFromCoach, transformToCoach, transformToCountry, transformToLeague, transformToPlayer } from '.';
|
|
3
3
|
function transformToAttributes(team) {
|
|
4
4
|
return {
|
|
5
5
|
team_id: team.id,
|
|
@@ -12,15 +12,16 @@ function transformToAttributes(team) {
|
|
|
12
12
|
rating: team.rating
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function transformToObject(
|
|
15
|
+
function transformToObject(model) {
|
|
16
16
|
return new Team({
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
shortName:
|
|
20
|
-
country:
|
|
21
|
-
coach:
|
|
22
|
-
roster: (
|
|
23
|
-
|
|
17
|
+
id: model.team_id,
|
|
18
|
+
name: model.name,
|
|
19
|
+
shortName: model.short_name,
|
|
20
|
+
country: model.country != null ? transformToCountry(model.country) : undefined,
|
|
21
|
+
coach: model.coach != null ? transformToCoach(model.coach) : undefined,
|
|
22
|
+
roster: (model.PlayerTeams ?? []).map((pt) => transformToPlayer(pt.player)),
|
|
23
|
+
league: model.league != null ? transformToLeague(model.league) : undefined,
|
|
24
|
+
rating: model.rating
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
export { transformToObject as transformToTeam, transformToAttributes as transformFromTeam };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PlayerPosition, Rally } from './rally';
|
|
2
2
|
import { MatchTeam } from './match-team';
|
|
3
|
-
import { Player } from '../player';
|
|
4
3
|
declare enum ScoreThreshold {
|
|
5
4
|
SET = 25,
|
|
6
5
|
TIE_BREAK = 15
|
|
@@ -21,7 +20,8 @@ export interface EventStat {
|
|
|
21
20
|
error: number;
|
|
22
21
|
}
|
|
23
22
|
export interface SetStatistics {
|
|
24
|
-
|
|
23
|
+
readonly playerId: string;
|
|
24
|
+
order: number;
|
|
25
25
|
ace: number;
|
|
26
26
|
attempts: number;
|
|
27
27
|
contacts: number;
|
|
@@ -34,6 +34,7 @@ export interface SetStatistics {
|
|
|
34
34
|
kills: number;
|
|
35
35
|
killBlocks: number;
|
|
36
36
|
assists: number;
|
|
37
|
+
setsPlayed: number;
|
|
37
38
|
}
|
|
38
39
|
export declare class MatchSet {
|
|
39
40
|
readonly id: string;
|
|
@@ -52,7 +53,7 @@ export declare class MatchSet {
|
|
|
52
53
|
increaseScore(team: MatchTeam): void;
|
|
53
54
|
addRally(rally: Rally): void;
|
|
54
55
|
/**
|
|
55
|
-
* Has a team reached at least 25 points and is the score difference between both teams at least 2?
|
|
56
|
+
* Has a team reached at least 25 points, and is the score difference between both teams at least 2?
|
|
56
57
|
* @returns boolean
|
|
57
58
|
*/
|
|
58
59
|
isOver(): boolean;
|
|
@@ -37,7 +37,7 @@ export class MatchSet {
|
|
|
37
37
|
this.rallies.push(rally);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Has a team reached at least 25 points and is the score difference between both teams at least 2?
|
|
40
|
+
* Has a team reached at least 25 points, and is the score difference between both teams at least 2?
|
|
41
41
|
* @returns boolean
|
|
42
42
|
*/
|
|
43
43
|
isOver() {
|
|
@@ -4,6 +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 { SetStatistics } from '../match';
|
|
7
8
|
export declare class Stat {
|
|
8
9
|
readonly name: Stats;
|
|
9
10
|
readonly value: number;
|
|
@@ -21,6 +22,7 @@ interface PlayerParams {
|
|
|
21
22
|
readonly roles: Role[];
|
|
22
23
|
readonly traits: Trait[];
|
|
23
24
|
readonly rarity: Rarity;
|
|
25
|
+
readonly gameStats?: SetStatistics[];
|
|
24
26
|
}
|
|
25
27
|
export declare class Name {
|
|
26
28
|
readonly first: string;
|
|
@@ -40,7 +42,8 @@ export declare class Player {
|
|
|
40
42
|
readonly traits: Trait[];
|
|
41
43
|
readonly generalStats: Stat[];
|
|
42
44
|
readonly rarity: Rarity;
|
|
43
|
-
|
|
45
|
+
readonly gameStats?: SetStatistics[];
|
|
46
|
+
constructor({ id, name, country, stats, roles, traits, rarity, gameStats }: PlayerParams);
|
|
44
47
|
static sortPlayers(roles: Role[]): (p1: Player, p2: Player) => number;
|
|
45
48
|
static compareStats(p1: Player, p2: Player): number;
|
|
46
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, gameStats }) {
|
|
24
24
|
validateUUID(id);
|
|
25
25
|
this.id = id;
|
|
26
26
|
this.name = name;
|
|
@@ -29,6 +29,7 @@ export class Player {
|
|
|
29
29
|
this.roles = roles;
|
|
30
30
|
this.traits = traits;
|
|
31
31
|
this.rarity = rarity;
|
|
32
|
+
this.gameStats = gameStats;
|
|
32
33
|
this.generalStats = Object.values(StatsEnum).map((stat) => ({
|
|
33
34
|
name: stat,
|
|
34
35
|
value: calculateStatScore(stats, stat)
|
|
@@ -33,8 +33,14 @@ export function assignRoles(stats) {
|
|
|
33
33
|
if (scores[1].score >= 75) {
|
|
34
34
|
out.push(scores[1].role);
|
|
35
35
|
}
|
|
36
|
-
if (scores[2].score >=
|
|
36
|
+
if (scores[2].score >= 82) {
|
|
37
37
|
out.push(scores[2].role);
|
|
38
38
|
}
|
|
39
|
+
if (scores[3].score >= 89) {
|
|
40
|
+
out.push(scores[3].role);
|
|
41
|
+
}
|
|
42
|
+
if (scores[4].score >= 95) {
|
|
43
|
+
out.push(scores[4].role);
|
|
44
|
+
}
|
|
39
45
|
return out;
|
|
40
46
|
}
|
|
@@ -34,10 +34,11 @@ export function getMultipliers(statName, performanceStats) {
|
|
|
34
34
|
case StatsEnum.RECEIVE:
|
|
35
35
|
return {
|
|
36
36
|
reception: 0.75,
|
|
37
|
-
overhand: 0.
|
|
37
|
+
overhand: 0.015,
|
|
38
38
|
bump: 0.15,
|
|
39
|
-
focus: 0.
|
|
40
|
-
defense: 0.
|
|
39
|
+
focus: 0.015,
|
|
40
|
+
defense: 0.055,
|
|
41
|
+
reflex: 0.015
|
|
41
42
|
};
|
|
42
43
|
case StatsEnum.SERVE:
|
|
43
44
|
return {
|
|
@@ -50,8 +51,9 @@ export function getMultipliers(statName, performanceStats) {
|
|
|
50
51
|
block: 0.65,
|
|
51
52
|
read: performanceStats == null ? 0.125 : performanceStats.read > performanceStats.commit ? 0.2 : 0.05,
|
|
52
53
|
commit: performanceStats == null ? 0.125 : performanceStats.commit > performanceStats.read ? 0.2 : 0.05,
|
|
53
|
-
focus: 0.
|
|
54
|
-
defense: 0.
|
|
54
|
+
focus: 0.04,
|
|
55
|
+
defense: 0.04,
|
|
56
|
+
reflex: 0.02
|
|
55
57
|
};
|
|
56
58
|
case StatsEnum.STAMINA:
|
|
57
59
|
return { stamina: 1 };
|