jl-sprt-core 1.0.7 → 1.1.0
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/Match/A_Match.d.ts +21 -14
- package/dist/Match/A_Match.js +8 -17
- package/dist/Match/A_Match.js.map +1 -1
- package/dist/Match/A_MatchPlay.d.ts +10 -8
- package/dist/Match/A_MatchPlay.js +8 -4
- package/dist/Match/A_MatchPlay.js.map +1 -1
- package/dist/Match/A_Result.d.ts +19 -9
- package/dist/Match/A_Result.js +17 -4
- package/dist/Match/A_Result.js.map +1 -1
- package/dist/Match/A_Serie.d.ts +57 -15
- package/dist/Match/A_Serie.js +84 -17
- package/dist/Match/A_Serie.js.map +1 -1
- package/dist/Match/scores.d.ts +2 -3
- package/dist/Match/scores.js +1 -0
- package/dist/Match/scores.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/profiles/ISportProfile.d.ts +10 -37
- package/package.json +1 -1
- package/dist/Match/A_ResultSerie.d.ts +0 -28
- package/dist/Match/A_ResultSerie.js +0 -21
- package/dist/Match/A_ResultSerie.js.map +0 -1
package/dist/Match/A_Match.d.ts
CHANGED
|
@@ -1,41 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A_ResultSerie } from './A_ResultSerie';
|
|
1
|
+
import { A_Result } from './A_Result';
|
|
3
2
|
import { A_MatchPlay } from './A_MatchPlay';
|
|
4
3
|
import { TMatchScore } from './scores';
|
|
5
4
|
import { A_Team } from '../A_Team';
|
|
6
5
|
import { A_TeamRoster } from '../A_TeamRoster';
|
|
7
6
|
import { JDateTime, TypeHalfWeekOfYear } from 'jl-calendar';
|
|
7
|
+
import { type MatchContextProvider } from './A_Serie';
|
|
8
|
+
/**
|
|
9
|
+
* Info genérica para crear un Match desde el profile.
|
|
10
|
+
* Contiene solo datos estructurales/de scheduling, no lógica de deporte.
|
|
11
|
+
* Para matches dentro de una serie, A_Serie los crea internamente.
|
|
12
|
+
*/
|
|
13
|
+
export interface IMatchCreationInfo<MS extends TMatchScore, TR extends A_TeamRoster> {
|
|
14
|
+
id: string;
|
|
15
|
+
hw: TypeHalfWeekOfYear;
|
|
16
|
+
season: number;
|
|
17
|
+
homeTeam: A_Team<TR>;
|
|
18
|
+
awayTeam: A_Team<TR>;
|
|
19
|
+
contextProvider?: MatchContextProvider<MS>;
|
|
20
|
+
isNeutral: boolean;
|
|
21
|
+
}
|
|
8
22
|
export type TypeMatchState = 'created' | 'scheduled' | 'postponed' | 'reschuduled' | 'prev' | 'playing' | 'finished';
|
|
9
23
|
/**
|
|
10
24
|
* Clase abstracta que representa un partido genérico.
|
|
11
25
|
* La lógica de start/advance/finish es común a todos los deportes.
|
|
12
26
|
* Cada deporte extiende esta clase y provee su propio A_MatchPlay.
|
|
13
27
|
*/
|
|
14
|
-
export declare abstract class A_Match<
|
|
28
|
+
export declare abstract class A_Match<MS extends TMatchScore, TR extends A_TeamRoster> {
|
|
15
29
|
protected _state: TypeMatchState;
|
|
16
30
|
protected _id: string;
|
|
17
31
|
protected _homeTeam: A_Team<TR>;
|
|
18
32
|
protected _awayTeam: A_Team<TR>;
|
|
19
33
|
protected _date: JDateTime;
|
|
20
|
-
protected
|
|
21
|
-
|
|
22
|
-
protected _serieResult?: A_ResultSerie<unknown>;
|
|
23
|
-
protected _serieFirstMatchState?: () => TypeMatchState;
|
|
24
|
-
constructor(id: string, homeTeam: A_Team<TR>, awayTeam: A_Team<TR>, hw: TypeHalfWeekOfYear, season: number, allowedDraw: boolean, playing: A_MatchPlay<ScoreType, TR>);
|
|
34
|
+
protected _playing: A_MatchPlay<MS, TR>;
|
|
35
|
+
constructor(info: IMatchCreationInfo<MS, TR>, getPlaying: (contextProvider?: MatchContextProvider<MS>) => A_MatchPlay<MS, TR>);
|
|
25
36
|
get id(): string;
|
|
26
37
|
get homeTeam(): A_Team<TR>;
|
|
27
38
|
get awayTeam(): A_Team<TR>;
|
|
28
39
|
get date(): JDateTime;
|
|
29
40
|
get state(): TypeMatchState;
|
|
30
41
|
get isFinished(): boolean;
|
|
31
|
-
get result():
|
|
32
|
-
/**
|
|
33
|
-
* Configura la referencia a la serie (resultado de serie y estado del primer match).
|
|
34
|
-
* Llamado por la serie concreta al crear los matches.
|
|
35
|
-
*/
|
|
36
|
-
setSerieContext(serieResult: A_ResultSerie<unknown>, firstMatchState: () => TypeMatchState): void;
|
|
42
|
+
get result(): A_Result<MS> | undefined;
|
|
37
43
|
schedule(dt: JDateTime): void;
|
|
38
44
|
finish(): void;
|
|
39
45
|
start(): void;
|
|
40
46
|
abstract advance(): void;
|
|
41
47
|
}
|
|
48
|
+
export type AnyMatch = A_Match<any, any>;
|
package/dist/Match/A_Match.js
CHANGED
|
@@ -8,14 +8,13 @@ const jl_calendar_1 = require("jl-calendar");
|
|
|
8
8
|
* Cada deporte extiende esta clase y provee su propio A_MatchPlay.
|
|
9
9
|
*/
|
|
10
10
|
class A_Match {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(info, getPlaying) {
|
|
12
12
|
this._state = 'created';
|
|
13
|
-
this._id = id;
|
|
14
|
-
this._homeTeam = homeTeam;
|
|
15
|
-
this._awayTeam = awayTeam;
|
|
16
|
-
this._date = jl_calendar_1.JDateTime.createFromHalfWeekOfYearAndYear(hw, season, 'middle');
|
|
17
|
-
this.
|
|
18
|
-
this._playing = playing;
|
|
13
|
+
this._id = info.id;
|
|
14
|
+
this._homeTeam = info.homeTeam;
|
|
15
|
+
this._awayTeam = info.awayTeam;
|
|
16
|
+
this._date = jl_calendar_1.JDateTime.createFromHalfWeekOfYearAndYear(info.hw, info.season, 'middle');
|
|
17
|
+
this._playing = getPlaying(info.contextProvider);
|
|
19
18
|
this._homeTeam.addNewMatch(this);
|
|
20
19
|
this._awayTeam.addNewMatch(this);
|
|
21
20
|
}
|
|
@@ -26,15 +25,7 @@ class A_Match {
|
|
|
26
25
|
get state() { return this._state; }
|
|
27
26
|
get isFinished() { return this._state === 'finished'; }
|
|
28
27
|
get result() {
|
|
29
|
-
return this._playing.result
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Configura la referencia a la serie (resultado de serie y estado del primer match).
|
|
33
|
-
* Llamado por la serie concreta al crear los matches.
|
|
34
|
-
*/
|
|
35
|
-
setSerieContext(serieResult, firstMatchState) {
|
|
36
|
-
this._serieResult = serieResult;
|
|
37
|
-
this._serieFirstMatchState = firstMatchState;
|
|
28
|
+
return this._playing.result;
|
|
38
29
|
}
|
|
39
30
|
schedule(dt) {
|
|
40
31
|
this._state =
|
|
@@ -50,7 +41,7 @@ class A_Match {
|
|
|
50
41
|
if (!(this._state === 'scheduled' || this._state === 'reschuduled'))
|
|
51
42
|
throw new Error('Match is none scheduled');
|
|
52
43
|
this._state = 'playing';
|
|
53
|
-
this._playing.
|
|
44
|
+
this._playing.start(this._homeTeam.getTeamMatch(), this._awayTeam.getTeamMatch());
|
|
54
45
|
}
|
|
55
46
|
}
|
|
56
47
|
exports.A_Match = A_Match;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A_Match.js","sourceRoot":"","sources":["../../src/Match/A_Match.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"A_Match.js","sourceRoot":"","sources":["../../src/Match/A_Match.ts"],"names":[],"mappings":";;;AAKA,6CAA4D;AA4B5D;;;;GAIG;AACH,MAAsB,OAAO;IAS5B,YAAY,IAAgC,EAAE,UAA+E;QAPnH,WAAM,GAAmB,SAAS,CAAC;QAQ5C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAE,IAAI,CAAE,QAAQ,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,uBAAS,CAAC,+BAA+B,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACvF,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAEjD,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,EAAE,KAAa,OAAO,IAAI,CAAC,GAAG,CAAA,CAAC,CAAC;IACpC,IAAI,QAAQ,KAAiB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACrD,IAAI,QAAQ,KAAiB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACrD,IAAI,IAAI,KAAgB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5C,IAAI,KAAK,KAAqB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACnD,IAAI,UAAU,KAAc,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC;IAEhE,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,QAAQ,CAAC,EAAa;QACrB,IAAI,CAAC,MAAM;YACV,IAAI,CAAC,MAAM,IAAI,WAAW,IAAI,IAAI,CAAC,MAAM,IAAI,WAAW;gBACvD,CAAC,CAAC,aAAa;gBACf,CAAC,CAAC,WAAW,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IAED,MAAM;QACL,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;IAC1B,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW,IAAI,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC;YAClE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAClB,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,EAC7B,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAC7B,CAAC;IACH,CAAC;CAGD;AAtDD,0BAsDC"}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
+
import { TMatchScore } from './scores';
|
|
1
2
|
import { A_Result } from './A_Result';
|
|
2
3
|
import { A_TeamRoster } from '../A_TeamRoster';
|
|
4
|
+
import type { MatchContext, MatchContextProvider } from './A_Serie';
|
|
3
5
|
/**
|
|
4
6
|
* Clase abstracta que define el contrato de la simulación de un partido.
|
|
5
7
|
* Cada deporte debe implementar su propia lógica de simulación.
|
|
6
8
|
*
|
|
7
|
-
*
|
|
9
|
+
* MS: number para futbol/basketball, IVolleyballScore para volleyball, etc.
|
|
8
10
|
*/
|
|
9
|
-
export declare abstract class A_MatchPlay<
|
|
11
|
+
export declare abstract class A_MatchPlay<MS extends TMatchScore, TR extends A_TeamRoster> {
|
|
10
12
|
protected _time: number;
|
|
11
|
-
protected _result: A_Result<
|
|
12
|
-
protected _globalResult: A_Result<ScoreType> | undefined;
|
|
13
|
+
protected _result: A_Result<MS> | undefined;
|
|
13
14
|
protected _teamOne: TR | undefined;
|
|
14
15
|
protected _teamTwo: TR | undefined;
|
|
15
|
-
|
|
16
|
+
protected _contextProvider?: MatchContextProvider<MS>;
|
|
17
|
+
constructor(contextProvider?: MatchContextProvider<MS>);
|
|
16
18
|
get time(): number;
|
|
17
|
-
get result(): A_Result<
|
|
18
|
-
get
|
|
19
|
-
abstract
|
|
19
|
+
get result(): A_Result<MS> | undefined;
|
|
20
|
+
get context(): MatchContext<MS> | undefined;
|
|
21
|
+
abstract start(one: TR, two: TR): void;
|
|
20
22
|
abstract advance(): void;
|
|
21
23
|
}
|
|
@@ -5,16 +5,20 @@ exports.A_MatchPlay = void 0;
|
|
|
5
5
|
* Clase abstracta que define el contrato de la simulación de un partido.
|
|
6
6
|
* Cada deporte debe implementar su propia lógica de simulación.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* MS: number para futbol/basketball, IVolleyballScore para volleyball, etc.
|
|
9
9
|
*/
|
|
10
10
|
class A_MatchPlay {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(contextProvider) {
|
|
12
12
|
this._time = -1;
|
|
13
|
-
this.
|
|
13
|
+
this._contextProvider = contextProvider;
|
|
14
14
|
}
|
|
15
15
|
get time() { return this._time; }
|
|
16
16
|
get result() { return this._result; }
|
|
17
|
-
get
|
|
17
|
+
get context() {
|
|
18
|
+
if (this._contextProvider) {
|
|
19
|
+
return this._contextProvider();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
23
|
exports.A_MatchPlay = A_MatchPlay;
|
|
20
24
|
//# sourceMappingURL=A_MatchPlay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A_MatchPlay.js","sourceRoot":"","sources":["../../src/Match/A_MatchPlay.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"A_MatchPlay.js","sourceRoot":"","sources":["../../src/Match/A_MatchPlay.ts"],"names":[],"mappings":";;;AAIA;;;;;GAKG;AACH,MAAsB,WAAW;IAOhC,YAAY,eAA0C;QACrD,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAChB,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IACzC,CAAC;IAED,IAAI,IAAI,KAAa,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACzC,IAAI,MAAM,KAA+B,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,IAAI,OAAO;QACV,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAChC,CAAC;IACF,CAAC;CAID;AAtBD,kCAsBC"}
|
package/dist/Match/A_Result.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { TMatchScore } from './scores';
|
|
2
|
+
export type TypeTotalScore<MS extends TMatchScore> = {
|
|
2
3
|
team: string;
|
|
3
|
-
score:
|
|
4
|
+
score: MS;
|
|
4
5
|
};
|
|
5
|
-
export interface
|
|
6
|
-
teamOneScore: TypeTotalScore<
|
|
7
|
-
teamTwoScore: TypeTotalScore<
|
|
6
|
+
export interface IResultInfo<MS extends TMatchScore> {
|
|
7
|
+
teamOneScore: TypeTotalScore<MS>;
|
|
8
|
+
teamTwoScore: TypeTotalScore<MS>;
|
|
9
|
+
teamWinner: string | 'none';
|
|
10
|
+
teamLoser: string | 'none';
|
|
11
|
+
}
|
|
12
|
+
export interface IWinnerInfo {
|
|
8
13
|
teamWinner: string | 'none';
|
|
9
14
|
teamLoser: string | 'none';
|
|
10
15
|
}
|
|
@@ -12,13 +17,18 @@ export interface IA_ResultInfo<ScoreType> {
|
|
|
12
17
|
* Clase abstracta que define el contrato de un resultado de partido.
|
|
13
18
|
* Cada deporte debe implementar su propia lógica de score y determinación de ganador.
|
|
14
19
|
*
|
|
15
|
-
* ScoreType: number para futbol/basketball,
|
|
20
|
+
* ScoreType: number para futbol/basketball, IVolleyballScore para volleyball, etc.
|
|
16
21
|
*/
|
|
17
|
-
export declare abstract class A_Result<
|
|
22
|
+
export declare abstract class A_Result<MS extends TMatchScore> {
|
|
18
23
|
protected _teamOneId: string;
|
|
19
24
|
protected _teamTwoId: string;
|
|
20
|
-
|
|
25
|
+
_teamOneScore: TypeTotalScore<MS>;
|
|
26
|
+
_teamTwoScore: TypeTotalScore<MS>;
|
|
27
|
+
constructor(teamOneId: string, teamTwoId: string, startScore: () => MS);
|
|
28
|
+
abstract addScore(id: string): void;
|
|
29
|
+
getScore(id: string): MS;
|
|
21
30
|
get teamOneId(): string;
|
|
22
31
|
get teamTwoId(): string;
|
|
23
|
-
abstract getResultInfo():
|
|
32
|
+
abstract getResultInfo(): IResultInfo<MS>;
|
|
33
|
+
abstract getWinnerInfo(): IWinnerInfo;
|
|
24
34
|
}
|
package/dist/Match/A_Result.js
CHANGED
|
@@ -5,15 +5,28 @@ exports.A_Result = void 0;
|
|
|
5
5
|
* Clase abstracta que define el contrato de un resultado de partido.
|
|
6
6
|
* Cada deporte debe implementar su propia lógica de score y determinación de ganador.
|
|
7
7
|
*
|
|
8
|
-
* ScoreType: number para futbol/basketball,
|
|
8
|
+
* ScoreType: number para futbol/basketball, IVolleyballScore para volleyball, etc.
|
|
9
9
|
*/
|
|
10
10
|
class A_Result {
|
|
11
|
-
constructor(teamOneId, teamTwoId) {
|
|
11
|
+
constructor(teamOneId, teamTwoId, startScore) {
|
|
12
12
|
this._teamOneId = teamOneId;
|
|
13
13
|
this._teamTwoId = teamTwoId;
|
|
14
|
+
this._teamOneScore = { team: teamOneId, score: startScore() };
|
|
15
|
+
this._teamTwoScore = { team: teamTwoId, score: startScore() };
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
getScore(id) {
|
|
18
|
+
if (id === this._teamOneScore.team) {
|
|
19
|
+
return this._teamOneScore.score;
|
|
20
|
+
}
|
|
21
|
+
else if (id === this._teamTwoScore.team) {
|
|
22
|
+
return this._teamTwoScore.score;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw new Error(`en get score`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
get teamOneId() { return this._teamOneScore.team; }
|
|
29
|
+
get teamTwoId() { return this._teamTwoScore.team; }
|
|
17
30
|
}
|
|
18
31
|
exports.A_Result = A_Result;
|
|
19
32
|
//# sourceMappingURL=A_Result.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A_Result.js","sourceRoot":"","sources":["../../src/Match/A_Result.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"A_Result.js","sourceRoot":"","sources":["../../src/Match/A_Result.ts"],"names":[],"mappings":";;;AAmBA;;;;;GAKG;AACH,MAAsB,QAAQ;IAQ7B,YAAY,SAAiB,EAAE,SAAiB,EAAE,UAAoB;QACrE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,CAAC,aAAa,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC;QAC9D,IAAI,CAAC,aAAa,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC;IAC/D,CAAC;IAID,QAAQ,CAAC,EAAU;QAChB,IAAI,EAAE,KAAK,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;QAClC,CAAC;aAAM,IAAI,EAAE,KAAK,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAA;QACjC,CAAC;IACH,CAAC;IAEF,IAAI,SAAS,KAAa,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAA,CAAC,CAAC;IAC1D,IAAI,SAAS,KAAa,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAA,CAAC,CAAC;CAI1D;AAjCD,4BAiCC"}
|
package/dist/Match/A_Serie.d.ts
CHANGED
|
@@ -1,33 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A_Match } from './A_Match';
|
|
3
|
-
import {
|
|
1
|
+
import { TypeHalfWeekOfYear } from 'jl-calendar';
|
|
2
|
+
import { A_Match, IMatchCreationInfo } from './A_Match';
|
|
3
|
+
import { A_Result } from './A_Result';
|
|
4
|
+
import { TMatchScore } from './scores';
|
|
4
5
|
import { A_Team } from '../A_Team';
|
|
5
6
|
import { A_TeamRoster } from '../A_TeamRoster';
|
|
6
|
-
import { TypeBaseStageOption } from '../types';
|
|
7
|
+
import { arr2, TypeBaseStageOption } from '../types';
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* Info genérica para crear una Serie desde el profile.
|
|
10
|
+
*/
|
|
11
|
+
export interface ISerieCreationInfo<TR extends A_TeamRoster> {
|
|
12
|
+
id: string;
|
|
13
|
+
teamOne: A_Team<TR>;
|
|
14
|
+
teamTwo: A_Team<TR>;
|
|
15
|
+
hws: arr2<TypeHalfWeekOfYear>;
|
|
16
|
+
season: number;
|
|
17
|
+
opt: TypeBaseStageOption;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
export type MatchContext<MS extends TMatchScore> = {
|
|
23
|
+
results: A_Result<MS>[];
|
|
24
|
+
totalMatches: number;
|
|
25
|
+
totalWins: number;
|
|
26
|
+
mustProduceWinner: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type MatchContextProvider<MS extends TMatchScore> = () => MatchContext<MS>;
|
|
29
|
+
/**
|
|
30
|
+
* Serie genérica de partidos.
|
|
31
|
+
*
|
|
32
|
+
* Una serie está compuesta por uno o más partidos entre los mismos equipos.
|
|
33
|
+
* La serie es responsable de:
|
|
34
|
+
*
|
|
35
|
+
* - mantener los partidos que la componen;
|
|
36
|
+
* - determinar cuándo terminó la serie;
|
|
37
|
+
* - determinar ganador y perdedor;
|
|
38
|
+
* - proporcionar al partido su contexto de serie.
|
|
9
39
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
40
|
+
* El resultado de la serie no se almacena separadamente:
|
|
41
|
+
* se obtiene a partir de los resultados de los partidos.
|
|
12
42
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* - Cómo se determina el ganador/perdedor (winner/loser abstractos)
|
|
16
|
-
* - Cuándo la serie está terminada (isFinished abstracto)
|
|
43
|
+
* MS: tipo del score de cada partido.
|
|
44
|
+
* TR: tipo de roster utilizado por los equipos.
|
|
17
45
|
*/
|
|
18
|
-
export declare abstract class A_Serie<MS extends TMatchScore,
|
|
46
|
+
export declare abstract class A_Serie<MS extends TMatchScore, TR extends A_TeamRoster> {
|
|
19
47
|
protected _id: string;
|
|
20
48
|
protected _teamOne: A_Team<TR>;
|
|
21
49
|
protected _teamTwo: A_Team<TR>;
|
|
22
50
|
protected _opt: TypeBaseStageOption;
|
|
23
|
-
protected _resultSerie: A_ResultSerie<SS>;
|
|
24
51
|
protected _matches: A_Match<MS, TR>[];
|
|
25
|
-
constructor(
|
|
52
|
+
constructor(info: ISerieCreationInfo<TR>, matchCreator: (info: IMatchCreationInfo<MS, TR>) => A_Match<MS, TR>);
|
|
26
53
|
get id(): string;
|
|
54
|
+
get teamOne(): A_Team<TR>;
|
|
55
|
+
get teamTwo(): A_Team<TR>;
|
|
27
56
|
get opt(): TypeBaseStageOption;
|
|
28
|
-
get resultSerie(): A_ResultSerie<SS>;
|
|
29
57
|
get matches(): A_Match<MS, TR>[];
|
|
58
|
+
/**
|
|
59
|
+
* Indica si todos los partidos necesarios para resolver
|
|
60
|
+
* la serie han terminado.
|
|
61
|
+
*/
|
|
30
62
|
abstract get isFinished(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Equipo ganador de la serie.
|
|
65
|
+
*
|
|
66
|
+
* Debe lanzar un error si la serie todavía no tiene ganador.
|
|
67
|
+
*/
|
|
31
68
|
abstract get winner(): A_Team<TR>;
|
|
69
|
+
/**
|
|
70
|
+
* Equipo perdedor de la serie.
|
|
71
|
+
*
|
|
72
|
+
* Debe lanzar un error si la serie todavía no tiene ganador.
|
|
73
|
+
*/
|
|
32
74
|
abstract get loser(): A_Team<TR>;
|
|
33
75
|
}
|
package/dist/Match/A_Serie.js
CHANGED
|
@@ -2,29 +2,96 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.A_Serie = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Serie genérica de partidos.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Una serie está compuesta por uno o más partidos entre los mismos equipos.
|
|
8
|
+
* La serie es responsable de:
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
10
|
+
* - mantener los partidos que la componen;
|
|
11
|
+
* - determinar cuándo terminó la serie;
|
|
12
|
+
* - determinar ganador y perdedor;
|
|
13
|
+
* - proporcionar al partido su contexto de serie.
|
|
14
|
+
*
|
|
15
|
+
* El resultado de la serie no se almacena separadamente:
|
|
16
|
+
* se obtiene a partir de los resultados de los partidos.
|
|
17
|
+
*
|
|
18
|
+
* MS: tipo del score de cada partido.
|
|
19
|
+
* TR: tipo de roster utilizado por los equipos.
|
|
14
20
|
*/
|
|
15
21
|
class A_Serie {
|
|
16
|
-
constructor(
|
|
17
|
-
this._id = id;
|
|
18
|
-
this._teamOne = teamOne;
|
|
19
|
-
this._teamTwo = teamTwo;
|
|
20
|
-
this._opt = opt;
|
|
21
|
-
|
|
22
|
+
constructor(info, matchCreator) {
|
|
23
|
+
this._id = info.id;
|
|
24
|
+
this._teamOne = info.teamOne;
|
|
25
|
+
this._teamTwo = info.teamTwo;
|
|
26
|
+
this._opt = info.opt;
|
|
27
|
+
const isHandA = info.opt === 'h&a';
|
|
28
|
+
const matches = [
|
|
29
|
+
matchCreator({
|
|
30
|
+
id: `${info.id}-M1`, homeTeam: info.teamOne, awayTeam: info.teamTwo,
|
|
31
|
+
hw: info.hws[0], season: info.season,
|
|
32
|
+
contextProvider: isHandA ? fisrtH_ASerieMatchProvider() : UniqueMatchProvider(),
|
|
33
|
+
isNeutral: info.opt == 'neutral'
|
|
34
|
+
})
|
|
35
|
+
];
|
|
36
|
+
if (isHandA) {
|
|
37
|
+
matches.push(matchCreator({
|
|
38
|
+
id: `${info.id}-M2`, homeTeam: info.teamTwo, awayTeam: info.teamOne,
|
|
39
|
+
hw: info.hws[1], season: info.season,
|
|
40
|
+
contextProvider: LastH_ASerieMatchProvider(matches[0]),
|
|
41
|
+
isNeutral: false
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
22
44
|
this._matches = matches;
|
|
23
45
|
}
|
|
24
|
-
get id() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
get
|
|
46
|
+
get id() {
|
|
47
|
+
return this._id;
|
|
48
|
+
}
|
|
49
|
+
get teamOne() {
|
|
50
|
+
return this._teamOne;
|
|
51
|
+
}
|
|
52
|
+
get teamTwo() {
|
|
53
|
+
return this._teamTwo;
|
|
54
|
+
}
|
|
55
|
+
get opt() {
|
|
56
|
+
return this._opt;
|
|
57
|
+
}
|
|
58
|
+
get matches() {
|
|
59
|
+
return this._matches;
|
|
60
|
+
}
|
|
28
61
|
}
|
|
29
62
|
exports.A_Serie = A_Serie;
|
|
63
|
+
function UniqueMatchProvider() {
|
|
64
|
+
return () => {
|
|
65
|
+
return {
|
|
66
|
+
results: [],
|
|
67
|
+
totalMatches: 1,
|
|
68
|
+
totalWins: 0,
|
|
69
|
+
mustProduceWinner: true
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function fisrtH_ASerieMatchProvider() {
|
|
74
|
+
return () => {
|
|
75
|
+
return {
|
|
76
|
+
results: [],
|
|
77
|
+
totalMatches: 2,
|
|
78
|
+
totalWins: 0,
|
|
79
|
+
mustProduceWinner: false
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function LastH_ASerieMatchProvider(match) {
|
|
84
|
+
return () => {
|
|
85
|
+
if (!match.isFinished) {
|
|
86
|
+
throw new Error(``);
|
|
87
|
+
}
|
|
88
|
+
const res = match.result;
|
|
89
|
+
return {
|
|
90
|
+
results: [res],
|
|
91
|
+
totalMatches: 2,
|
|
92
|
+
totalWins: 0,
|
|
93
|
+
mustProduceWinner: true
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
}
|
|
30
97
|
//# sourceMappingURL=A_Serie.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A_Serie.js","sourceRoot":"","sources":["../../src/Match/A_Serie.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"A_Serie.js","sourceRoot":"","sources":["../../src/Match/A_Serie.ts"],"names":[],"mappings":"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"}
|
package/dist/Match/scores.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Score de un partido de volleyball.
|
|
3
3
|
* Cada equipo tiene sets ganados y los puntos de cada set.
|
|
4
4
|
*/
|
|
5
|
-
export interface
|
|
5
|
+
export interface IVolleyballScore {
|
|
6
6
|
setsWon: number;
|
|
7
7
|
setPoints: number[];
|
|
8
8
|
}
|
|
@@ -17,5 +17,4 @@ export interface IAmericanFootballScore {
|
|
|
17
17
|
twoPointConversions: number;
|
|
18
18
|
safeties: number;
|
|
19
19
|
}
|
|
20
|
-
export type TMatchScore =
|
|
21
|
-
export type TSerieScore = number | IVolleyScore | IFootballScore | IAmericanFootballScore;
|
|
20
|
+
export type TMatchScore = IVolleyballScore | IFootballScore | IAmericanFootballScore;
|
package/dist/Match/scores.js
CHANGED
package/dist/Match/scores.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scores.js","sourceRoot":"","sources":["../../src/Match/scores.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"scores.js","sourceRoot":"","sources":["../../src/Match/scores.ts"],"names":[],"mappings":";AAAA,gBAAgB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { A_Match } from './Match/A_Match';
|
|
1
|
+
export { A_Match, AnyMatch } from './Match/A_Match';
|
|
2
2
|
export { A_MatchPlay } from './Match/A_MatchPlay';
|
|
3
3
|
export { A_Result } from './Match/A_Result';
|
|
4
|
-
export { A_ResultSerie } from './Match/A_ResultSerie';
|
|
5
4
|
export { A_Serie } from './Match/A_Serie';
|
|
6
5
|
export { Person } from './Person';
|
|
7
|
-
export type { IPersonData } from './Person';
|
|
8
6
|
export { A_Team, AnyTeam } from './A_Team';
|
|
9
7
|
export { A_TeamRoster } from './A_TeamRoster';
|
|
10
|
-
export type { ITeamCreator, ITeamOwner } from './A_Team';
|
|
11
8
|
export { CATEGORIES, getCategoryList } from './types';
|
|
12
|
-
export
|
|
13
|
-
export type {
|
|
14
|
-
export type {
|
|
15
|
-
export type {
|
|
16
|
-
export type {
|
|
17
|
-
export
|
|
9
|
+
export { A_TeamTableItem } from './profiles/A_TeamTableItem';
|
|
10
|
+
export type { IMatchCreationInfo, TypeMatchState } from './Match/A_Match';
|
|
11
|
+
export type { IResultInfo, IWinnerInfo, TypeTotalScore } from './Match/A_Result';
|
|
12
|
+
export type { ISerieCreationInfo, MatchContext, MatchContextProvider } from './Match/A_Serie';
|
|
13
|
+
export type { IFootballScore, IAmericanFootballScore, IVolleyballScore, TMatchScore } from './Match/scores';
|
|
14
|
+
export type { IPersonData } from './Person';
|
|
15
|
+
export type { ITeamCreator, ITeamOwner } from './A_Team';
|
|
16
|
+
export type { ISportProfile, AnySportProfile } from './profiles/ISportProfile';
|
|
17
|
+
export type { AnyTeamTableItem, IA_TeamTableItemBase, SortFunc } from './profiles/A_TeamTableItem';
|
|
18
18
|
export type { arr2, TypeBaseStageOption, TypeCategory, TypeCategoryList } from './types';
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.A_TeamTableItem = exports.getCategoryList = exports.CATEGORIES = exports.A_TeamRoster = exports.A_Team = exports.Person = exports.A_Serie = exports.
|
|
3
|
+
exports.A_TeamTableItem = exports.getCategoryList = exports.CATEGORIES = exports.A_TeamRoster = exports.A_Team = exports.Person = exports.A_Serie = exports.A_Result = exports.A_MatchPlay = exports.A_Match = void 0;
|
|
4
|
+
// Classes
|
|
4
5
|
var A_Match_1 = require("./Match/A_Match");
|
|
5
6
|
Object.defineProperty(exports, "A_Match", { enumerable: true, get: function () { return A_Match_1.A_Match; } });
|
|
6
7
|
var A_MatchPlay_1 = require("./Match/A_MatchPlay");
|
|
7
8
|
Object.defineProperty(exports, "A_MatchPlay", { enumerable: true, get: function () { return A_MatchPlay_1.A_MatchPlay; } });
|
|
8
9
|
var A_Result_1 = require("./Match/A_Result");
|
|
9
10
|
Object.defineProperty(exports, "A_Result", { enumerable: true, get: function () { return A_Result_1.A_Result; } });
|
|
10
|
-
var A_ResultSerie_1 = require("./Match/A_ResultSerie");
|
|
11
|
-
Object.defineProperty(exports, "A_ResultSerie", { enumerable: true, get: function () { return A_ResultSerie_1.A_ResultSerie; } });
|
|
12
11
|
var A_Serie_1 = require("./Match/A_Serie");
|
|
13
12
|
Object.defineProperty(exports, "A_Serie", { enumerable: true, get: function () { return A_Serie_1.A_Serie; } });
|
|
14
13
|
var Person_1 = require("./Person");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,UAAU;AACV,2CAAoD;AAA3C,kGAAA,OAAO,OAAA;AAChB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AACpB,6CAA4C;AAAnC,oGAAA,QAAQ,OAAA;AACjB,2CAA0C;AAAjC,kGAAA,OAAO,OAAA;AAEhB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,mCAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAErB,iCAAsD;AAA7C,mGAAA,UAAU,OAAA;AAAE,wGAAA,eAAe,OAAA;AACpC,8DAEoC;AADnC,kHAAA,eAAe,OAAA"}
|
|
@@ -1,58 +1,31 @@
|
|
|
1
|
-
import { TypeHalfWeekOfYear } from "jl-calendar";
|
|
2
1
|
import { A_Team } from "../A_Team";
|
|
3
2
|
import { A_TeamRoster } from "../A_TeamRoster";
|
|
4
3
|
import { A_TeamTableItem } from "./A_TeamTableItem";
|
|
5
|
-
import { A_Result,
|
|
4
|
+
import { A_Result, IResultInfo } from "../Match/A_Result";
|
|
6
5
|
import { A_MatchPlay } from "../Match/A_MatchPlay";
|
|
7
|
-
import { A_Match } from "../Match/A_Match";
|
|
8
|
-
import { A_Serie } from "../Match/A_Serie";
|
|
9
|
-
import { TMatchScore
|
|
10
|
-
import { arr2, TypeBaseStageOption } from '../types';
|
|
11
|
-
/**
|
|
12
|
-
* Info genérica para crear un Match desde el profile.
|
|
13
|
-
* Contiene solo datos estructurales/de scheduling, no lógica de deporte.
|
|
14
|
-
* Para matches dentro de una serie, A_Serie los crea internamente.
|
|
15
|
-
*/
|
|
16
|
-
export interface IMatchCreationInfo<TR extends A_TeamRoster> {
|
|
17
|
-
id: string;
|
|
18
|
-
hw: TypeHalfWeekOfYear;
|
|
19
|
-
season: number;
|
|
20
|
-
homeTeam: A_Team<TR>;
|
|
21
|
-
awayTeam: A_Team<TR>;
|
|
22
|
-
allowedDraw: boolean;
|
|
23
|
-
isNeutral: boolean;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Info genérica para crear una Serie desde el profile.
|
|
27
|
-
*/
|
|
28
|
-
export interface ISerieCreationInfo<TR extends A_TeamRoster> {
|
|
29
|
-
teamOne: A_Team<TR>;
|
|
30
|
-
teamTwo: A_Team<TR>;
|
|
31
|
-
hws: arr2<TypeHalfWeekOfYear>;
|
|
32
|
-
season: number;
|
|
33
|
-
id: string;
|
|
34
|
-
opt: TypeBaseStageOption;
|
|
35
|
-
}
|
|
6
|
+
import { A_Match, IMatchCreationInfo } from "../Match/A_Match";
|
|
7
|
+
import { A_Serie, ISerieCreationInfo } from "../Match/A_Serie";
|
|
8
|
+
import { TMatchScore } from "../Match/scores";
|
|
36
9
|
/**
|
|
37
10
|
* Interfaz que encapsula todo lo específico de un deporte.
|
|
38
11
|
* Cada deporte implementa su propio profile.
|
|
39
12
|
* El profile es la fábrica completa: crea Match, Serie, Result, MatchPlay, TableItem.
|
|
40
13
|
* Agregar un nuevo deporte = crear un nuevo profile + sus clases concretas.
|
|
41
14
|
*
|
|
42
|
-
* MS: tipo del score del partido (number para futbol/basketball,
|
|
15
|
+
* MS: tipo del score del partido (number para futbol/basketball, IVolleyballScore para volleyball, etc.)
|
|
43
16
|
* Res: tipos de resultado posibles ('W' | 'D' | 'L' para futbol, 'W' | 'L' para basketball, etc.)
|
|
44
17
|
* Punt: tipos de puntuación ('gf' | 'ga' para futbol, 'pf' | 'pa' para basketball, etc.)
|
|
45
18
|
*/
|
|
46
|
-
export interface ISportProfile<MS extends TMatchScore,
|
|
19
|
+
export interface ISportProfile<MS extends TMatchScore, Res extends string, Punt extends string, TR extends A_TeamRoster> {
|
|
47
20
|
/**
|
|
48
21
|
* Crea un partido completo con toda la lógica específica del deporte.
|
|
49
22
|
*/
|
|
50
|
-
createMatch(info: IMatchCreationInfo<TR>): A_Match<MS, TR>;
|
|
23
|
+
createMatch(info: IMatchCreationInfo<MS, TR>): A_Match<MS, TR>;
|
|
51
24
|
/**
|
|
52
25
|
* Crea una serie (ida/vuelta o partido único) con la lógica específica del deporte.
|
|
53
26
|
* Cada deporte define cómo se resuelve el desempate de una serie.
|
|
54
27
|
*/
|
|
55
|
-
createSerie(info: ISerieCreationInfo<TR>): A_Serie<MS,
|
|
28
|
+
createSerie(info: ISerieCreationInfo<TR>): A_Serie<MS, TR>;
|
|
56
29
|
/**
|
|
57
30
|
* Crea un resultado vacío para un partido entre dos equipos.
|
|
58
31
|
*/
|
|
@@ -69,10 +42,10 @@ export interface ISportProfile<MS extends TMatchScore, SS extends TSerieScore, R
|
|
|
69
42
|
/**
|
|
70
43
|
* Actualiza un item de tabla a partir del resultado de un partido.
|
|
71
44
|
*/
|
|
72
|
-
updateTableFromResult(tti: A_TeamTableItem<Res, Punt>, resultInfo:
|
|
45
|
+
updateTableFromResult(tti: A_TeamTableItem<Res, Punt>, resultInfo: IResultInfo<MS>, // mejor usar result?
|
|
73
46
|
teamId: string): void;
|
|
74
47
|
}
|
|
75
48
|
/**
|
|
76
49
|
* Tipo para usar ISportProfile de forma genérica sin propagar los tipos Res/Punt.
|
|
77
50
|
*/
|
|
78
|
-
export type AnySportProfile = ISportProfile<any,
|
|
51
|
+
export type AnySportProfile = ISportProfile<any, string, string, any>;
|
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export interface IA_ResultSerieInfo<SerieScoreType> {
|
|
2
|
-
teamOneScore: {
|
|
3
|
-
team: string;
|
|
4
|
-
score: SerieScoreType;
|
|
5
|
-
};
|
|
6
|
-
teamTwoScore: {
|
|
7
|
-
team: string;
|
|
8
|
-
score: SerieScoreType;
|
|
9
|
-
};
|
|
10
|
-
teamWinner: string | 'none';
|
|
11
|
-
teamLoser: string | 'none';
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Clase abstracta que define el contrato del resultado de una serie.
|
|
15
|
-
*
|
|
16
|
-
* SerieScoreType: el tipo de score de la serie, que no necesariamente
|
|
17
|
-
* coincide con el ScoreType del match individual.
|
|
18
|
-
* Ej: en volleyball, el match score es IVolleyScore (sets + puntos por set),
|
|
19
|
-
* pero el serie score podría ser number (puntos de partido: 3 por 3-0, 2 por 3-1, etc.).
|
|
20
|
-
*/
|
|
21
|
-
export declare abstract class A_ResultSerie<SerieScoreType> {
|
|
22
|
-
protected _teamOneId: string;
|
|
23
|
-
protected _teamTwoId: string;
|
|
24
|
-
constructor(teamOneId: string, teamTwoId: string);
|
|
25
|
-
get teamOneId(): string;
|
|
26
|
-
get teamTwoId(): string;
|
|
27
|
-
abstract getResultSerieInfo(): IA_ResultSerieInfo<SerieScoreType>;
|
|
28
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.A_ResultSerie = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Clase abstracta que define el contrato del resultado de una serie.
|
|
6
|
-
*
|
|
7
|
-
* SerieScoreType: el tipo de score de la serie, que no necesariamente
|
|
8
|
-
* coincide con el ScoreType del match individual.
|
|
9
|
-
* Ej: en volleyball, el match score es IVolleyScore (sets + puntos por set),
|
|
10
|
-
* pero el serie score podría ser number (puntos de partido: 3 por 3-0, 2 por 3-1, etc.).
|
|
11
|
-
*/
|
|
12
|
-
class A_ResultSerie {
|
|
13
|
-
constructor(teamOneId, teamTwoId) {
|
|
14
|
-
this._teamOneId = teamOneId;
|
|
15
|
-
this._teamTwoId = teamTwoId;
|
|
16
|
-
}
|
|
17
|
-
get teamOneId() { return this._teamOneId; }
|
|
18
|
-
get teamTwoId() { return this._teamTwoId; }
|
|
19
|
-
}
|
|
20
|
-
exports.A_ResultSerie = A_ResultSerie;
|
|
21
|
-
//# sourceMappingURL=A_ResultSerie.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A_ResultSerie.js","sourceRoot":"","sources":["../../src/Match/A_ResultSerie.ts"],"names":[],"mappings":";;;AAOA;;;;;;;GAOG;AACH,MAAsB,aAAa;IAKlC,YAAY,SAAiB,EAAE,SAAiB;QAC/C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,IAAI,SAAS,KAAa,OAAO,IAAI,CAAC,UAAU,CAAA,CAAC,CAAC;IAClD,IAAI,SAAS,KAAa,OAAO,IAAI,CAAC,UAAU,CAAA,CAAC,CAAC;CAGlD;AAdD,sCAcC"}
|