volleyballsimtypes 0.0.65 → 0.0.67
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 +0 -2
- package/dist/cjs/src/data/transformers/match-rating.d.ts +2 -2
- package/dist/cjs/src/data/transformers/match-rating.js +4 -5
- package/dist/cjs/src/service/match/match-rating.d.ts +9 -6
- package/dist/cjs/src/service/match/match-rating.js +11 -10
- package/dist/esm/src/data/init-models.js +0 -2
- package/dist/esm/src/data/transformers/match-rating.d.ts +2 -2
- package/dist/esm/src/data/transformers/match-rating.js +4 -5
- package/dist/esm/src/service/match/match-rating.d.ts +9 -6
- package/dist/esm/src/service/match/match-rating.js +11 -10
- package/package.json +1 -1
|
@@ -89,7 +89,6 @@ function initModels(sequelize) {
|
|
|
89
89
|
MatchSetStats.belongsTo(Player, { as: 'player', foreignKey: 'player_id' });
|
|
90
90
|
PerformanceStats.belongsTo(Player, { as: 'player', foreignKey: 'player_id' });
|
|
91
91
|
Player.belongsTo(Country, { as: 'country', foreignKey: 'country_id' });
|
|
92
|
-
Player.belongsTo(Team, { as: 'team', foreignKey: 'team_id' });
|
|
93
92
|
Player.hasMany(Block, { as: 'Blocks', foreignKey: 'player_id' });
|
|
94
93
|
Player.hasMany(Block, { as: 'blocker_1_Blocks', foreignKey: 'blocker_1' });
|
|
95
94
|
Player.hasMany(Block, { as: 'blocker_2_Blocks', foreignKey: 'blocker_2' });
|
|
@@ -179,7 +178,6 @@ function initModels(sequelize) {
|
|
|
179
178
|
Team.belongsTo(League, { as: 'league', foreignKey: 'league_id' });
|
|
180
179
|
Team.hasMany(Match, { as: 'Matches', foreignKey: 'home_team' });
|
|
181
180
|
Team.hasMany(Match, { as: 'away_team_Matches', foreignKey: 'away_team' });
|
|
182
|
-
Team.hasMany(Player, { as: 'Players', foreignKey: 'team_id' });
|
|
183
181
|
Team.hasMany(Rally, { as: 'Rallies', foreignKey: 'serving_team' });
|
|
184
182
|
Team.hasMany(Score, { as: 'Scores', foreignKey: 'team_id' });
|
|
185
183
|
Team.hasMany(Season, { as: 'season_titles', foreignKey: 'champion' });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { MatchRatingAttributes } from '../models';
|
|
2
|
-
import {
|
|
3
|
-
declare function transformToAttributes(
|
|
2
|
+
import { MatchRating, MatchTeam } from '../../service';
|
|
3
|
+
declare function transformToAttributes(team: MatchTeam, rating: MatchRating): MatchRatingAttributes;
|
|
4
4
|
export { transformToAttributes as transformFromMatchRating };
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformFromMatchRating = void 0;
|
|
4
4
|
const service_1 = require("../../service");
|
|
5
|
-
function transformToAttributes(
|
|
6
|
-
const
|
|
7
|
-
match.awayTeam.id === teamId ? service_1.MatchTeam.AWAY : undefined;
|
|
5
|
+
function transformToAttributes(team, rating) {
|
|
6
|
+
const teamId = team === service_1.MatchTeam.HOME ? rating.home.id : rating.away.id;
|
|
8
7
|
if (team == null)
|
|
9
8
|
throw new Error(`INVALID_TEAM: ${teamId}`);
|
|
10
9
|
return {
|
|
11
|
-
match_id: match.id,
|
|
10
|
+
match_id: rating.match.id,
|
|
12
11
|
team_id: teamId,
|
|
13
12
|
p: rating.getWinProbability(team),
|
|
14
|
-
dR: rating.getRatingChange(team
|
|
13
|
+
dR: rating.getRatingChange(team)
|
|
15
14
|
};
|
|
16
15
|
}
|
|
17
16
|
exports.transformFromMatchRating = transformToAttributes;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Match, MatchTeam } from '.';
|
|
2
|
+
import { Team } from '../team';
|
|
2
3
|
interface MatchRatingOpts {
|
|
3
|
-
readonly
|
|
4
|
-
readonly
|
|
4
|
+
readonly home: Team;
|
|
5
|
+
readonly away: Team;
|
|
6
|
+
readonly match: Match;
|
|
5
7
|
}
|
|
6
8
|
export declare class MatchRating {
|
|
7
9
|
static K: number;
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
10
|
-
|
|
10
|
+
readonly home: Team;
|
|
11
|
+
readonly away: Team;
|
|
12
|
+
readonly match: Match;
|
|
13
|
+
constructor({ home, away, match }: MatchRatingOpts);
|
|
11
14
|
getWinProbability(team: MatchTeam): number;
|
|
12
|
-
getRatingChange(team: MatchTeam
|
|
15
|
+
getRatingChange(team: MatchTeam): number;
|
|
13
16
|
}
|
|
14
17
|
export {};
|
|
@@ -3,26 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MatchRating = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
class MatchRating {
|
|
6
|
-
constructor({
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
6
|
+
constructor({ home, away, match }) {
|
|
7
|
+
this.home = home;
|
|
8
|
+
this.away = away;
|
|
9
|
+
this.match = match;
|
|
9
10
|
}
|
|
10
11
|
getWinProbability(team) {
|
|
11
12
|
let rA;
|
|
12
13
|
let rB;
|
|
13
14
|
if (team === _1.MatchTeam.HOME) {
|
|
14
|
-
rA = this.
|
|
15
|
-
rB = this.
|
|
15
|
+
rA = this.home.rating;
|
|
16
|
+
rB = this.away.rating;
|
|
16
17
|
}
|
|
17
18
|
else {
|
|
18
|
-
rA = this.
|
|
19
|
-
rB = this.
|
|
19
|
+
rA = this.away.rating;
|
|
20
|
+
rB = this.home.rating;
|
|
20
21
|
}
|
|
21
22
|
return 1 / (1 + Math.pow(10, ((rB - rA) / 400)));
|
|
22
23
|
}
|
|
23
|
-
getRatingChange(team
|
|
24
|
-
const t = match[team === _1.MatchTeam.HOME ? 'homeTeam' : 'awayTeam'];
|
|
25
|
-
const score = match.getWinner().id === t.id ? 1 : 0;
|
|
24
|
+
getRatingChange(team) {
|
|
25
|
+
const t = this.match[team === _1.MatchTeam.HOME ? 'homeTeam' : 'awayTeam'];
|
|
26
|
+
const score = this.match.getWinner().id === t.id ? 1 : 0;
|
|
26
27
|
return MatchRating.K * (score - this.getWinProbability(team));
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -86,7 +86,6 @@ export function initModels(sequelize) {
|
|
|
86
86
|
MatchSetStats.belongsTo(Player, { as: 'player', foreignKey: 'player_id' });
|
|
87
87
|
PerformanceStats.belongsTo(Player, { as: 'player', foreignKey: 'player_id' });
|
|
88
88
|
Player.belongsTo(Country, { as: 'country', foreignKey: 'country_id' });
|
|
89
|
-
Player.belongsTo(Team, { as: 'team', foreignKey: 'team_id' });
|
|
90
89
|
Player.hasMany(Block, { as: 'Blocks', foreignKey: 'player_id' });
|
|
91
90
|
Player.hasMany(Block, { as: 'blocker_1_Blocks', foreignKey: 'blocker_1' });
|
|
92
91
|
Player.hasMany(Block, { as: 'blocker_2_Blocks', foreignKey: 'blocker_2' });
|
|
@@ -176,7 +175,6 @@ export function initModels(sequelize) {
|
|
|
176
175
|
Team.belongsTo(League, { as: 'league', foreignKey: 'league_id' });
|
|
177
176
|
Team.hasMany(Match, { as: 'Matches', foreignKey: 'home_team' });
|
|
178
177
|
Team.hasMany(Match, { as: 'away_team_Matches', foreignKey: 'away_team' });
|
|
179
|
-
Team.hasMany(Player, { as: 'Players', foreignKey: 'team_id' });
|
|
180
178
|
Team.hasMany(Rally, { as: 'Rallies', foreignKey: 'serving_team' });
|
|
181
179
|
Team.hasMany(Score, { as: 'Scores', foreignKey: 'team_id' });
|
|
182
180
|
Team.hasMany(Season, { as: 'season_titles', foreignKey: 'champion' });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { MatchRatingAttributes } from '../models';
|
|
2
|
-
import {
|
|
3
|
-
declare function transformToAttributes(
|
|
2
|
+
import { MatchRating, MatchTeam } from '../../service';
|
|
3
|
+
declare function transformToAttributes(team: MatchTeam, rating: MatchRating): MatchRatingAttributes;
|
|
4
4
|
export { transformToAttributes as transformFromMatchRating };
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { MatchTeam } from '../../service';
|
|
2
|
-
function transformToAttributes(
|
|
3
|
-
const
|
|
4
|
-
match.awayTeam.id === teamId ? MatchTeam.AWAY : undefined;
|
|
2
|
+
function transformToAttributes(team, rating) {
|
|
3
|
+
const teamId = team === MatchTeam.HOME ? rating.home.id : rating.away.id;
|
|
5
4
|
if (team == null)
|
|
6
5
|
throw new Error(`INVALID_TEAM: ${teamId}`);
|
|
7
6
|
return {
|
|
8
|
-
match_id: match.id,
|
|
7
|
+
match_id: rating.match.id,
|
|
9
8
|
team_id: teamId,
|
|
10
9
|
p: rating.getWinProbability(team),
|
|
11
|
-
dR: rating.getRatingChange(team
|
|
10
|
+
dR: rating.getRatingChange(team)
|
|
12
11
|
};
|
|
13
12
|
}
|
|
14
13
|
export { transformToAttributes as transformFromMatchRating };
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Match, MatchTeam } from '.';
|
|
2
|
+
import { Team } from '../team';
|
|
2
3
|
interface MatchRatingOpts {
|
|
3
|
-
readonly
|
|
4
|
-
readonly
|
|
4
|
+
readonly home: Team;
|
|
5
|
+
readonly away: Team;
|
|
6
|
+
readonly match: Match;
|
|
5
7
|
}
|
|
6
8
|
export declare class MatchRating {
|
|
7
9
|
static K: number;
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
10
|
-
|
|
10
|
+
readonly home: Team;
|
|
11
|
+
readonly away: Team;
|
|
12
|
+
readonly match: Match;
|
|
13
|
+
constructor({ home, away, match }: MatchRatingOpts);
|
|
11
14
|
getWinProbability(team: MatchTeam): number;
|
|
12
|
-
getRatingChange(team: MatchTeam
|
|
15
|
+
getRatingChange(team: MatchTeam): number;
|
|
13
16
|
}
|
|
14
17
|
export {};
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { MatchTeam } from '.';
|
|
2
2
|
export class MatchRating {
|
|
3
|
-
constructor({
|
|
4
|
-
this.
|
|
5
|
-
this.
|
|
3
|
+
constructor({ home, away, match }) {
|
|
4
|
+
this.home = home;
|
|
5
|
+
this.away = away;
|
|
6
|
+
this.match = match;
|
|
6
7
|
}
|
|
7
8
|
getWinProbability(team) {
|
|
8
9
|
let rA;
|
|
9
10
|
let rB;
|
|
10
11
|
if (team === MatchTeam.HOME) {
|
|
11
|
-
rA = this.
|
|
12
|
-
rB = this.
|
|
12
|
+
rA = this.home.rating;
|
|
13
|
+
rB = this.away.rating;
|
|
13
14
|
}
|
|
14
15
|
else {
|
|
15
|
-
rA = this.
|
|
16
|
-
rB = this.
|
|
16
|
+
rA = this.away.rating;
|
|
17
|
+
rB = this.home.rating;
|
|
17
18
|
}
|
|
18
19
|
return 1 / (1 + Math.pow(10, ((rB - rA) / 400)));
|
|
19
20
|
}
|
|
20
|
-
getRatingChange(team
|
|
21
|
-
const t = match[team === MatchTeam.HOME ? 'homeTeam' : 'awayTeam'];
|
|
22
|
-
const score = match.getWinner().id === t.id ? 1 : 0;
|
|
21
|
+
getRatingChange(team) {
|
|
22
|
+
const t = this.match[team === MatchTeam.HOME ? 'homeTeam' : 'awayTeam'];
|
|
23
|
+
const score = this.match.getWinner().id === t.id ? 1 : 0;
|
|
23
24
|
return MatchRating.K * (score - this.getWinProbability(team));
|
|
24
25
|
}
|
|
25
26
|
}
|