jl-sprt-match 1.0.1
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/engines/types.d.ts +0 -0
- package/dist/engines/types.js +2 -0
- package/dist/engines/types.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/profiles/americanFootball/AmericanFootballMatch.d.ts +13 -0
- package/dist/profiles/americanFootball/AmericanFootballMatch.js +21 -0
- package/dist/profiles/americanFootball/AmericanFootballMatch.js.map +1 -0
- package/dist/profiles/americanFootball/AmericanFootballMatchPlay.d.ts +84 -0
- package/dist/profiles/americanFootball/AmericanFootballMatchPlay.js +273 -0
- package/dist/profiles/americanFootball/AmericanFootballMatchPlay.js.map +1 -0
- package/dist/profiles/americanFootball/AmericanFootballProfile.d.ts +20 -0
- package/dist/profiles/americanFootball/AmericanFootballProfile.js +50 -0
- package/dist/profiles/americanFootball/AmericanFootballProfile.js.map +1 -0
- package/dist/profiles/americanFootball/AmericanFootballResult.d.ts +14 -0
- package/dist/profiles/americanFootball/AmericanFootballResult.js +94 -0
- package/dist/profiles/americanFootball/AmericanFootballResult.js.map +1 -0
- package/dist/profiles/americanFootball/AmericanFootballRoster.d.ts +3 -0
- package/dist/profiles/americanFootball/AmericanFootballRoster.js +8 -0
- package/dist/profiles/americanFootball/AmericanFootballRoster.js.map +1 -0
- package/dist/profiles/americanFootball/AmericanFootballScore.d.ts +8 -0
- package/dist/profiles/americanFootball/AmericanFootballScore.js +3 -0
- package/dist/profiles/americanFootball/AmericanFootballScore.js.map +1 -0
- package/dist/profiles/americanFootball/AmericanFootballSerie.d.ts +21 -0
- package/dist/profiles/americanFootball/AmericanFootballSerie.js +64 -0
- package/dist/profiles/americanFootball/AmericanFootballSerie.js.map +1 -0
- package/dist/profiles/americanFootball/AmericanFootballTeam.d.ts +6 -0
- package/dist/profiles/americanFootball/AmericanFootballTeam.js +15 -0
- package/dist/profiles/americanFootball/AmericanFootballTeam.js.map +1 -0
- package/dist/profiles/americanFootball/AmericanFootballTeamTableItem.d.ts +36 -0
- package/dist/profiles/americanFootball/AmericanFootballTeamTableItem.js +65 -0
- package/dist/profiles/americanFootball/AmericanFootballTeamTableItem.js.map +1 -0
- package/dist/profiles/football/FootballMatch.d.ts +13 -0
- package/dist/profiles/football/FootballMatch.js +21 -0
- package/dist/profiles/football/FootballMatch.js.map +1 -0
- package/dist/profiles/football/FootballMatchPlay.d.ts +70 -0
- package/dist/profiles/football/FootballMatchPlay.js +265 -0
- package/dist/profiles/football/FootballMatchPlay.js.map +1 -0
- package/dist/profiles/football/FootballProfile.d.ts +20 -0
- package/dist/profiles/football/FootballProfile.js +50 -0
- package/dist/profiles/football/FootballProfile.js.map +1 -0
- package/dist/profiles/football/FootballResult.d.ts +14 -0
- package/dist/profiles/football/FootballResult.js +72 -0
- package/dist/profiles/football/FootballResult.js.map +1 -0
- package/dist/profiles/football/FootballRoster.d.ts +3 -0
- package/dist/profiles/football/FootballRoster.js +8 -0
- package/dist/profiles/football/FootballRoster.js.map +1 -0
- package/dist/profiles/football/FootballScore.d.ts +4 -0
- package/dist/profiles/football/FootballScore.js +3 -0
- package/dist/profiles/football/FootballScore.js.map +1 -0
- package/dist/profiles/football/FootballSerie.d.ts +16 -0
- package/dist/profiles/football/FootballSerie.js +57 -0
- package/dist/profiles/football/FootballSerie.js.map +1 -0
- package/dist/profiles/football/FootballTeam.d.ts +6 -0
- package/dist/profiles/football/FootballTeam.js +15 -0
- package/dist/profiles/football/FootballTeam.js.map +1 -0
- package/dist/profiles/football/FootballTeamTableItem.d.ts +36 -0
- package/dist/profiles/football/FootballTeamTableItem.js +65 -0
- package/dist/profiles/football/FootballTeamTableItem.js.map +1 -0
- package/dist/profiles/types.d.ts +4 -0
- package/dist/profiles/types.js +3 -0
- package/dist/profiles/types.js.map +1 -0
- package/dist/profiles/volleyball/VolleyballMatch.d.ts +14 -0
- package/dist/profiles/volleyball/VolleyballMatch.js +22 -0
- package/dist/profiles/volleyball/VolleyballMatch.js.map +1 -0
- package/dist/profiles/volleyball/VolleyballMatchPlay.d.ts +43 -0
- package/dist/profiles/volleyball/VolleyballMatchPlay.js +234 -0
- package/dist/profiles/volleyball/VolleyballMatchPlay.js.map +1 -0
- package/dist/profiles/volleyball/VolleyballProfile.d.ts +22 -0
- package/dist/profiles/volleyball/VolleyballProfile.js +77 -0
- package/dist/profiles/volleyball/VolleyballProfile.js.map +1 -0
- package/dist/profiles/volleyball/VolleyballResult.d.ts +29 -0
- package/dist/profiles/volleyball/VolleyballResult.js +93 -0
- package/dist/profiles/volleyball/VolleyballResult.js.map +1 -0
- package/dist/profiles/volleyball/VolleyballRoster.d.ts +3 -0
- package/dist/profiles/volleyball/VolleyballRoster.js +8 -0
- package/dist/profiles/volleyball/VolleyballRoster.js.map +1 -0
- package/dist/profiles/volleyball/VolleyballScore.d.ts +5 -0
- package/dist/profiles/volleyball/VolleyballScore.js +3 -0
- package/dist/profiles/volleyball/VolleyballScore.js.map +1 -0
- package/dist/profiles/volleyball/VolleyballSerie.d.ts +25 -0
- package/dist/profiles/volleyball/VolleyballSerie.js +82 -0
- package/dist/profiles/volleyball/VolleyballSerie.js.map +1 -0
- package/dist/profiles/volleyball/VolleyballTeam.d.ts +6 -0
- package/dist/profiles/volleyball/VolleyballTeam.js +15 -0
- package/dist/profiles/volleyball/VolleyballTeam.js.map +1 -0
- package/dist/profiles/volleyball/VolleyballTeamTableItem.d.ts +47 -0
- package/dist/profiles/volleyball/VolleyballTeamTableItem.js +73 -0
- package/dist/profiles/volleyball/VolleyballTeamTableItem.js.map +1 -0
- package/dist/randomSource.d.ts +10 -0
- package/dist/randomSource.js +32 -0
- package/dist/randomSource.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.footballSortFunc = exports.FootballTeamTableItem = void 0;
|
|
4
|
+
const jl_sprt_core_1 = require("jl-sprt-core");
|
|
5
|
+
class FootballTeamTableItem extends jl_sprt_core_1.A_TeamTableItem {
|
|
6
|
+
constructor(t, bsId) {
|
|
7
|
+
super(t, bsId);
|
|
8
|
+
}
|
|
9
|
+
get ps() {
|
|
10
|
+
const { W, D } = this.matchResults;
|
|
11
|
+
return 3 * W + D;
|
|
12
|
+
}
|
|
13
|
+
getInitialCountOfMathResults() {
|
|
14
|
+
return { W: 0, D: 0, L: 0 };
|
|
15
|
+
}
|
|
16
|
+
getInitialCountOfMathPuntuations() {
|
|
17
|
+
return { gf: 0, ga: 0 };
|
|
18
|
+
}
|
|
19
|
+
get W() { return this.matchResults.W; }
|
|
20
|
+
get D() { return this.matchResults.D; }
|
|
21
|
+
get L() { return this.matchResults.L; }
|
|
22
|
+
get gf() { return this.matchPuntuations.gf; }
|
|
23
|
+
get ga() { return this.matchPuntuations.ga; }
|
|
24
|
+
get sg() { return this.gf - this.ga; }
|
|
25
|
+
addWM() { this.addMatchResult('W'); }
|
|
26
|
+
addDM() { this.addMatchResult('D'); }
|
|
27
|
+
addLM() { this.addMatchResult('L'); }
|
|
28
|
+
addGf(g) { this.matchPuntuations.gf += g; }
|
|
29
|
+
addGa(g) { this.matchPuntuations.ga += g; }
|
|
30
|
+
getSortFunc() {
|
|
31
|
+
return exports.footballSortFunc;
|
|
32
|
+
}
|
|
33
|
+
getInterface() {
|
|
34
|
+
return {
|
|
35
|
+
...super.getInterface(),
|
|
36
|
+
W: this.W,
|
|
37
|
+
D: this.D,
|
|
38
|
+
L: this.L,
|
|
39
|
+
gf: this.gf,
|
|
40
|
+
ga: this.ga,
|
|
41
|
+
sg: this.sg,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.FootballTeamTableItem = FootballTeamTableItem;
|
|
46
|
+
const footballSortFunc = (a, b, isSE) => {
|
|
47
|
+
if (isSE) {
|
|
48
|
+
if (a.P - b.P !== 0)
|
|
49
|
+
return b.P - a.P;
|
|
50
|
+
}
|
|
51
|
+
if (b.pos - a.pos !== 0)
|
|
52
|
+
return a.pos - b.pos;
|
|
53
|
+
if (!isSE) {
|
|
54
|
+
if (a.pm - b.pm !== 0)
|
|
55
|
+
return b.pm - a.pm;
|
|
56
|
+
}
|
|
57
|
+
if (a.ps - b.ps !== 0)
|
|
58
|
+
return b.ps - a.ps;
|
|
59
|
+
if (a.sg - b.sg !== 0) {
|
|
60
|
+
return b.sg - a.sg;
|
|
61
|
+
}
|
|
62
|
+
return b.gf - a.gf;
|
|
63
|
+
};
|
|
64
|
+
exports.footballSortFunc = footballSortFunc;
|
|
65
|
+
//# sourceMappingURL=FootballTeamTableItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FootballTeamTableItem.js","sourceRoot":"","sources":["../../../src/profiles/football/FootballTeamTableItem.ts"],"names":[],"mappings":";;;AACA,+CAAiG;AAejG,MAAa,qBAAsB,SAAQ,8BAA+D;IAExG,YAAY,CAAe,EAAE,IAAY;QACvC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACjB,CAAC;IAED,IAAI,EAAE;QACJ,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,4BAA4B;QAC1B,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAC9B,CAAC;IAED,gCAAgC;QAC9B,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,KAAa,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAA,CAAC,CAAC;IAC9C,IAAI,CAAC,KAAa,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAA,CAAC,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AC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;IAC9C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;IAC5C,CAAC;IACD,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;IAC1C,IAAK,CAAS,CAAC,EAAE,GAAI,CAAS,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QACxC,OAAQ,CAAS,CAAC,EAAE,GAAI,CAAS,CAAC,EAAE,CAAC;IACvC,CAAC;IACD,OAAQ,CAAS,CAAC,EAAE,GAAI,CAAS,CAAC,EAAE,CAAC;AACvC,CAAC,CAAC;AAbW,QAAA,gBAAgB,oBAa3B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IAmericanFootballScore } from './americanFootball/AmericanFootballScore';
|
|
2
|
+
import { IFootballScore } from './football/FootballScore';
|
|
3
|
+
import { IVolleyballScore } from './volleyball/VolleyballScore';
|
|
4
|
+
export type TMatchScore = IVolleyballScore | IFootballScore | IAmericanFootballScore;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/profiles/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { A_Match, IVolleyballScore, IMatchCreationInfo } from 'jl-sprt-core';
|
|
2
|
+
import { VolleyballRoster } from './VolleyballRoster';
|
|
3
|
+
export interface IVolleyballMatchCreationInfo extends IMatchCreationInfo<IVolleyballScore, VolleyballRoster> {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Partido de volleyball.
|
|
7
|
+
* Extiende A_Match con VolleyMatchPlay como simulación.
|
|
8
|
+
* Lógica de advance: se juegan rallies hasta que un equipo gane 3 sets.
|
|
9
|
+
* No hay concepto de "tiempo" como en fútbol — el partido termina cuando
|
|
10
|
+
* se completan los sets necesarios.
|
|
11
|
+
*/
|
|
12
|
+
export declare class VolleyballMatch extends A_Match<IVolleyballScore, VolleyballRoster> {
|
|
13
|
+
constructor(info: IVolleyballMatchCreationInfo);
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolleyballMatch = void 0;
|
|
4
|
+
const jl_sprt_core_1 = require("jl-sprt-core");
|
|
5
|
+
const VolleyballMatchPlay_1 = require("./VolleyballMatchPlay");
|
|
6
|
+
const getPlaying = (contextProvider) => {
|
|
7
|
+
return new VolleyballMatchPlay_1.VolleyballMatchPlay(contextProvider);
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Partido de volleyball.
|
|
11
|
+
* Extiende A_Match con VolleyMatchPlay como simulación.
|
|
12
|
+
* Lógica de advance: se juegan rallies hasta que un equipo gane 3 sets.
|
|
13
|
+
* No hay concepto de "tiempo" como en fútbol — el partido termina cuando
|
|
14
|
+
* se completan los sets necesarios.
|
|
15
|
+
*/
|
|
16
|
+
class VolleyballMatch extends jl_sprt_core_1.A_Match {
|
|
17
|
+
constructor(info) {
|
|
18
|
+
super(info, getPlaying);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.VolleyballMatch = VolleyballMatch;
|
|
22
|
+
//# sourceMappingURL=VolleyballMatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VolleyballMatch.js","sourceRoot":"","sources":["../../../src/profiles/volleyball/VolleyballMatch.ts"],"names":[],"mappings":";;;AACA,+CAAmG;AAInG,+DAA4D;AAK5D,MAAM,UAAU,GAAG,CAAC,eAAwD,EAAE,EAAE;IAC9E,OAAO,IAAI,yCAAmB,CAAC,eAAe,CAAC,CAAC;AAClD,CAAC,CAAA;AACD;;;;;;GAMG;AACH,MAAa,eAAgB,SAAQ,sBAA2C;IAC9E,YAAY,IAAkC;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IACzB,CAAC;CACF;AAJD,0CAIC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { A_MatchPlay, IVolleyballScore, MatchContextProvider } from "jl-sprt-core";
|
|
2
|
+
import { VolleyballRoster } from "./VolleyballRoster";
|
|
3
|
+
/**
|
|
4
|
+
* Simulación de un partido de volleyball.
|
|
5
|
+
*
|
|
6
|
+
* En condiciones normales se juegan sets hasta que un equipo
|
|
7
|
+
* gane 3 (best of 5).
|
|
8
|
+
*
|
|
9
|
+
* Sets 1-4: a 25 puntos con diferencia mínima de 2.
|
|
10
|
+
* Set 5: a 15 puntos con diferencia mínima de 2.
|
|
11
|
+
*
|
|
12
|
+
* En un partido de vuelta de una serie, si cada equipo ganó
|
|
13
|
+
* uno de los dos partidos, se juega un set adicional a 15
|
|
14
|
+
* puntos para determinar el ganador de la serie. En ese caso
|
|
15
|
+
* el resultado del partido puede quedar 3-3.
|
|
16
|
+
*/
|
|
17
|
+
export declare class VolleyballMatchPlay extends A_MatchPlay<IVolleyballScore, VolleyballRoster> {
|
|
18
|
+
/** Rallies (puntos) que se juegan por intervalo. Ajustable. */
|
|
19
|
+
private static readonly RALLIES_PER_INTERVAL;
|
|
20
|
+
/** Intervalos de descanso entre sets (5 min / 5 = 1). */
|
|
21
|
+
private static readonly SET_BREAK_INTERVALS;
|
|
22
|
+
private _currentSetPointsOne;
|
|
23
|
+
private _currentSetPointsTwo;
|
|
24
|
+
private _serieTieBreak;
|
|
25
|
+
/** Intervalos de descanso entre sets pendientes por consumir. */
|
|
26
|
+
private _breakLeft;
|
|
27
|
+
get breakLeft(): number;
|
|
28
|
+
constructor(contextProvider?: MatchContextProvider<IVolleyballScore>);
|
|
29
|
+
start(one: VolleyballRoster, two: VolleyballRoster): void;
|
|
30
|
+
get isFinished(): boolean;
|
|
31
|
+
/** Avanza un intervalo: descanso entre sets, o RALLIES_PER_INTERVAL rallies. */
|
|
32
|
+
advance(): void;
|
|
33
|
+
private mustPlaySerieTieBreak;
|
|
34
|
+
/**
|
|
35
|
+
* Simula un rally y cierra el set si corresponde.
|
|
36
|
+
*
|
|
37
|
+
* El objetivo es:
|
|
38
|
+
* - 25 puntos para los sets 1-4;
|
|
39
|
+
* - 15 puntos para el quinto set;
|
|
40
|
+
* - 15 puntos para el set extra de desempate de la serie.
|
|
41
|
+
*/
|
|
42
|
+
private playRally;
|
|
43
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolleyballMatchPlay = void 0;
|
|
4
|
+
const jl_sprt_core_1 = require("jl-sprt-core");
|
|
5
|
+
const randomSource_1 = require("../../randomSource");
|
|
6
|
+
const VolleyballResult_1 = require("./VolleyballResult");
|
|
7
|
+
/**
|
|
8
|
+
* Simulación de un partido de volleyball.
|
|
9
|
+
*
|
|
10
|
+
* En condiciones normales se juegan sets hasta que un equipo
|
|
11
|
+
* gane 3 (best of 5).
|
|
12
|
+
*
|
|
13
|
+
* Sets 1-4: a 25 puntos con diferencia mínima de 2.
|
|
14
|
+
* Set 5: a 15 puntos con diferencia mínima de 2.
|
|
15
|
+
*
|
|
16
|
+
* En un partido de vuelta de una serie, si cada equipo ganó
|
|
17
|
+
* uno de los dos partidos, se juega un set adicional a 15
|
|
18
|
+
* puntos para determinar el ganador de la serie. En ese caso
|
|
19
|
+
* el resultado del partido puede quedar 3-3.
|
|
20
|
+
*/
|
|
21
|
+
class VolleyballMatchPlay extends jl_sprt_core_1.A_MatchPlay {
|
|
22
|
+
get breakLeft() {
|
|
23
|
+
return this._breakLeft;
|
|
24
|
+
}
|
|
25
|
+
constructor(contextProvider) {
|
|
26
|
+
super(contextProvider);
|
|
27
|
+
// esto lo debe gestionar en realidad el propio result
|
|
28
|
+
this._currentSetPointsOne = 0;
|
|
29
|
+
this._currentSetPointsTwo = 0;
|
|
30
|
+
this._serieTieBreak = false;
|
|
31
|
+
/** Intervalos de descanso entre sets pendientes por consumir. */
|
|
32
|
+
this._breakLeft = 0;
|
|
33
|
+
}
|
|
34
|
+
start(one, two) {
|
|
35
|
+
this._time = 0;
|
|
36
|
+
this._teamOne = one;
|
|
37
|
+
this._teamTwo = two;
|
|
38
|
+
this._result = new VolleyballResult_1.VolleyballResult(this._teamOne.id, this._teamTwo.id);
|
|
39
|
+
this._currentSetPointsOne = 0;
|
|
40
|
+
this._currentSetPointsTwo = 0;
|
|
41
|
+
// Indica que el partido de vuelta necesita un set adicional
|
|
42
|
+
// para resolver la serie.
|
|
43
|
+
// this._serieTieBreak = false;
|
|
44
|
+
this._breakLeft = 0;
|
|
45
|
+
}
|
|
46
|
+
get isFinished() {
|
|
47
|
+
if (!this._result || !this._teamOne || !this._teamTwo)
|
|
48
|
+
return false;
|
|
49
|
+
const result = this._result;
|
|
50
|
+
const s1 = result.getScore(this._teamOne.id).setsWon;
|
|
51
|
+
const s2 = result.getScore(this._teamTwo.id).setsWon;
|
|
52
|
+
// El set extra está pendiente.
|
|
53
|
+
if (this._serieTieBreak)
|
|
54
|
+
return false;
|
|
55
|
+
// El partido normal todavía no terminó.
|
|
56
|
+
if (s1 < 3 && s2 < 3)
|
|
57
|
+
return false;
|
|
58
|
+
const context = this.context;
|
|
59
|
+
// Partido independiente o primer partido de la serie.
|
|
60
|
+
if (!context || context.results.length === 0)
|
|
61
|
+
return true;
|
|
62
|
+
/*
|
|
63
|
+
* Segundo partido.
|
|
64
|
+
*
|
|
65
|
+
* Si el mismo equipo ganó ambos partidos,
|
|
66
|
+
* la serie ya está resuelta.
|
|
67
|
+
*/
|
|
68
|
+
const previousResult = context.results[0];
|
|
69
|
+
const previousWinner = previousResult.getWinnerInfo().teamWinner;
|
|
70
|
+
const currentWinner = s1 > s2
|
|
71
|
+
? this._teamOne.id
|
|
72
|
+
: this._teamTwo.id;
|
|
73
|
+
if (currentWinner === previousWinner)
|
|
74
|
+
return true;
|
|
75
|
+
/*
|
|
76
|
+
* Cada equipo ganó un partido.
|
|
77
|
+
*
|
|
78
|
+
* El partido normal ya terminó, pero falta el
|
|
79
|
+
* set extra de desempate de la serie.
|
|
80
|
+
*
|
|
81
|
+
* Si _serieTieBreak es false aquí, significa que
|
|
82
|
+
* ese set extra ya terminó.
|
|
83
|
+
*/
|
|
84
|
+
const score = result.getScore(this._teamOne.id);
|
|
85
|
+
return score.extraSetPoints !== undefined;
|
|
86
|
+
}
|
|
87
|
+
/** Avanza un intervalo: descanso entre sets, o RALLIES_PER_INTERVAL rallies. */
|
|
88
|
+
advance() {
|
|
89
|
+
if (!this._result || !this._teamOne || !this._teamTwo)
|
|
90
|
+
throw new Error('No se inició el match');
|
|
91
|
+
if (this.isFinished)
|
|
92
|
+
return;
|
|
93
|
+
this._time++;
|
|
94
|
+
/*
|
|
95
|
+
* Descanso entre sets.
|
|
96
|
+
*/
|
|
97
|
+
if (this._breakLeft > 0) {
|
|
98
|
+
this._breakLeft--;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
/*
|
|
102
|
+
* Se juegan hasta RALLIES_PER_INTERVAL rallies.
|
|
103
|
+
* playRally() se encarga de distinguir entre:
|
|
104
|
+
* - set normal
|
|
105
|
+
* - set extra de desempate de la serie
|
|
106
|
+
*/
|
|
107
|
+
for (let r = 0; r < VolleyballMatchPlay.RALLIES_PER_INTERVAL; r++) {
|
|
108
|
+
const setClosed = this.playRally();
|
|
109
|
+
if (!setClosed)
|
|
110
|
+
continue;
|
|
111
|
+
/*
|
|
112
|
+
* Si era el set extra, ya quedó registrado en el
|
|
113
|
+
* VolleyballResult como extraSetPoints.
|
|
114
|
+
*/
|
|
115
|
+
if (this._serieTieBreak) {
|
|
116
|
+
this._serieTieBreak = false;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
const result = this._result;
|
|
120
|
+
const s1 = result.getScore(this._teamOne.id).setsWon;
|
|
121
|
+
const s2 = result.getScore(this._teamTwo.id).setsWon;
|
|
122
|
+
/*
|
|
123
|
+
* Terminó el partido normal.
|
|
124
|
+
*/
|
|
125
|
+
if (s1 >= 3 || s2 >= 3) {
|
|
126
|
+
/*
|
|
127
|
+
* Si cada equipo ganó un partido de la serie,
|
|
128
|
+
* queda pendiente el set extra.
|
|
129
|
+
*/
|
|
130
|
+
if (this.mustPlaySerieTieBreak()) {
|
|
131
|
+
this._serieTieBreak = true;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
/*
|
|
135
|
+
* El partido y la serie ya están resueltos.
|
|
136
|
+
*/
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
/*
|
|
140
|
+
* El partido continúa con otro set normal.
|
|
141
|
+
*/
|
|
142
|
+
this._breakLeft = VolleyballMatchPlay.SET_BREAK_INTERVALS;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
mustPlaySerieTieBreak() {
|
|
147
|
+
const context = this.context;
|
|
148
|
+
/*
|
|
149
|
+
* Sin contexto: partido independiente.
|
|
150
|
+
*/
|
|
151
|
+
if (!context)
|
|
152
|
+
return false;
|
|
153
|
+
/*
|
|
154
|
+
* Primer partido de una serie:
|
|
155
|
+
* todavía no existen resultados anteriores o es a partido unico.
|
|
156
|
+
* TAL VEZ DEBE RETORNARN ERROR
|
|
157
|
+
*/
|
|
158
|
+
if (context.results.length === 0)
|
|
159
|
+
return false;
|
|
160
|
+
/*
|
|
161
|
+
* Actualmente solo soportamos ida y vuelta.
|
|
162
|
+
*/
|
|
163
|
+
if (context.results.length !== 1)
|
|
164
|
+
throw new Error('Unsupported series context');
|
|
165
|
+
const previousResult = context.results[0];
|
|
166
|
+
const previousWinner = previousResult.getWinnerInfo().teamWinner;
|
|
167
|
+
const currentResult = this._result;
|
|
168
|
+
const currentWinner = currentResult.getWinnerInfo().teamWinner;
|
|
169
|
+
/*
|
|
170
|
+
* Si ganó el mismo equipo ambos partidos, la serie
|
|
171
|
+
* ya está resuelta.
|
|
172
|
+
*
|
|
173
|
+
* Si ganó cada equipo un partido, hace falta el set
|
|
174
|
+
* extra de desempate.
|
|
175
|
+
*/
|
|
176
|
+
return (previousWinner !== 'none' &&
|
|
177
|
+
currentWinner !== 'none' &&
|
|
178
|
+
previousWinner !== currentWinner);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Simula un rally y cierra el set si corresponde.
|
|
182
|
+
*
|
|
183
|
+
* El objetivo es:
|
|
184
|
+
* - 25 puntos para los sets 1-4;
|
|
185
|
+
* - 15 puntos para el quinto set;
|
|
186
|
+
* - 15 puntos para el set extra de desempate de la serie.
|
|
187
|
+
*/
|
|
188
|
+
playRally() {
|
|
189
|
+
const result = this._result;
|
|
190
|
+
const s1 = result.getScore(this._teamOne.id).setsWon;
|
|
191
|
+
const s2 = result.getScore(this._teamTwo.id).setsWon;
|
|
192
|
+
const targetPoints = this._serieTieBreak || (s1 + s2) === 4
|
|
193
|
+
? 15
|
|
194
|
+
: 25;
|
|
195
|
+
if ((0, randomSource_1.randomFloat)() < 0.52) {
|
|
196
|
+
this._currentSetPointsOne++;
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
this._currentSetPointsTwo++;
|
|
200
|
+
}
|
|
201
|
+
const p1 = this._currentSetPointsOne;
|
|
202
|
+
const p2 = this._currentSetPointsTwo;
|
|
203
|
+
if ((p1 >= targetPoints || p2 >= targetPoints) &&
|
|
204
|
+
Math.abs(p1 - p2) >= 2) {
|
|
205
|
+
const setWinner = p1 > p2
|
|
206
|
+
? this._teamOne.id
|
|
207
|
+
: this._teamTwo.id;
|
|
208
|
+
if (this._serieTieBreak) {
|
|
209
|
+
result.addScore(setWinner, {
|
|
210
|
+
type: 'extraSet',
|
|
211
|
+
winnerPoints: Math.max(p1, p2),
|
|
212
|
+
loserPoints: Math.min(p1, p2)
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
result.addScore(setWinner, {
|
|
217
|
+
type: 'set',
|
|
218
|
+
winnerPoints: Math.max(p1, p2),
|
|
219
|
+
loserPoints: Math.min(p1, p2)
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
this._currentSetPointsOne = 0;
|
|
223
|
+
this._currentSetPointsTwo = 0;
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.VolleyballMatchPlay = VolleyballMatchPlay;
|
|
230
|
+
/** Rallies (puntos) que se juegan por intervalo. Ajustable. */
|
|
231
|
+
VolleyballMatchPlay.RALLIES_PER_INTERVAL = 9;
|
|
232
|
+
/** Intervalos de descanso entre sets (5 min / 5 = 1). */
|
|
233
|
+
VolleyballMatchPlay.SET_BREAK_INTERVALS = 1;
|
|
234
|
+
//# sourceMappingURL=VolleyballMatchPlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VolleyballMatchPlay.js","sourceRoot":"","sources":["../../../src/profiles/volleyball/VolleyballMatchPlay.ts"],"names":[],"mappings":";;;AACA,+CAAiG;AAEjG,qDAAiD;AACjD,yDAAsD;AAEtD;;;;;;;;;;;;;GAaG;AACH,MAAa,mBAAoB,SAAQ,0BAA+C;IActF,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,YAAY,eAAwD;QAClE,KAAK,CAAC,eAAe,CAAC,CAAC;QAZzB,sDAAsD;QAC9C,yBAAoB,GAAW,CAAC,CAAC;QACjC,yBAAoB,GA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AAC,QAAQ,CAAC,SAAS,EAAE;oBACzB,IAAI,EAAE,UAAU;oBAChB,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;oBAC9B,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;iBAC9B,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE;oBACzB,IAAI,EAAE,KAAK;oBACX,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;oBAC9B,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;iBAC9B,CAAC,CAAC;YACL,CAAC;YAED,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC;YAC9B,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC;YAE9B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;;AApQH,kDAqQC;AAnQC,+DAA+D;AACvC,wCAAoB,GAAG,CAAC,AAAJ,CAAK;AACjD,yDAAyD;AACjC,uCAAmB,GAAG,CAAC,AAAJ,CAAK"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IResultInfo, ISportProfile, IMatchCreationInfo, ISerieCreationInfo, IVolleyballScore } from "jl-sprt-core";
|
|
2
|
+
import { VolleyballTeam } from './VolleyballTeam';
|
|
3
|
+
import { VolleyballRoster } from './VolleyballRoster';
|
|
4
|
+
import { VolleyballResult } from "./VolleyballResult";
|
|
5
|
+
import { VolleyballMatchPlay } from "./VolleyballMatchPlay";
|
|
6
|
+
import { VolleyballMatch } from "./VolleyballMatch";
|
|
7
|
+
import { VolleyballSerie } from "./VolleyballSerie";
|
|
8
|
+
import { VolleyballTeamTableItem, VolleyballMatchResults, VolleyballMatchPuntuations } from "./VolleyballTeamTableItem";
|
|
9
|
+
/**
|
|
10
|
+
* Profile para Volleyball.
|
|
11
|
+
* Score: IVolleyScore (sets ganados + puntos por set)
|
|
12
|
+
* Resultados: W3_0, W3_1, W3_2, L2_3, L1_3, L0_3
|
|
13
|
+
* Puntuaciones: sw (sets won), sl (sets lost), pf (points for), pa (points against)
|
|
14
|
+
*/
|
|
15
|
+
export declare class VolleyballProfile implements ISportProfile<IVolleyballScore, VolleyballMatchResults, VolleyballMatchPuntuations, VolleyballRoster> {
|
|
16
|
+
createMatch(info: IMatchCreationInfo<IVolleyballScore, VolleyballRoster>): VolleyballMatch;
|
|
17
|
+
createSerie(info: ISerieCreationInfo<VolleyballRoster>): VolleyballSerie;
|
|
18
|
+
createResult(teamOneId: string, teamTwoId: string): VolleyballResult;
|
|
19
|
+
createMatchPlay(globalResult?: VolleyballResult): VolleyballMatchPlay;
|
|
20
|
+
createTableItem(team: VolleyballTeam, bsId: string): VolleyballTeamTableItem;
|
|
21
|
+
updateTableFromResult(tti: VolleyballTeamTableItem, resultInfo: IResultInfo<IVolleyballScore>): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolleyballProfile = void 0;
|
|
4
|
+
const VolleyballMatch_1 = require("./VolleyballMatch");
|
|
5
|
+
const VolleyballSerie_1 = require("./VolleyballSerie");
|
|
6
|
+
const VolleyballTeamTableItem_1 = require("./VolleyballTeamTableItem");
|
|
7
|
+
/**
|
|
8
|
+
* Profile para Volleyball.
|
|
9
|
+
* Score: IVolleyScore (sets ganados + puntos por set)
|
|
10
|
+
* Resultados: W3_0, W3_1, W3_2, L2_3, L1_3, L0_3
|
|
11
|
+
* Puntuaciones: sw (sets won), sl (sets lost), pf (points for), pa (points against)
|
|
12
|
+
*/
|
|
13
|
+
class VolleyballProfile {
|
|
14
|
+
createMatch(info) {
|
|
15
|
+
return new VolleyballMatch_1.VolleyballMatch(info);
|
|
16
|
+
}
|
|
17
|
+
createSerie(info) {
|
|
18
|
+
return new VolleyballSerie_1.VolleyballSerie(info);
|
|
19
|
+
}
|
|
20
|
+
createResult(teamOneId, teamTwoId) {
|
|
21
|
+
throw new Error(`no hace falta implementar esto, el propio Match crea sus MatchPlay`);
|
|
22
|
+
}
|
|
23
|
+
createMatchPlay(globalResult) {
|
|
24
|
+
throw new Error(`no hace falta implementar esto, el propio Match crea sus MatchPlay`);
|
|
25
|
+
}
|
|
26
|
+
createTableItem(team, bsId) {
|
|
27
|
+
return new VolleyballTeamTableItem_1.VolleyballTeamTableItem(team, bsId);
|
|
28
|
+
}
|
|
29
|
+
updateTableFromResult(tti, resultInfo) {
|
|
30
|
+
const tid = tti.team.id;
|
|
31
|
+
const isHome = resultInfo.teamOneScore.team === tid;
|
|
32
|
+
const myScore = isHome
|
|
33
|
+
? resultInfo.teamOneScore.score
|
|
34
|
+
: resultInfo.teamTwoScore.score;
|
|
35
|
+
const theirScore = isHome
|
|
36
|
+
? resultInfo.teamTwoScore.score
|
|
37
|
+
: resultInfo.teamOneScore.score;
|
|
38
|
+
tti.addSw(myScore.setsWon);
|
|
39
|
+
tti.addSl(theirScore.setsWon);
|
|
40
|
+
const myPoints = myScore.setPoints.reduce((sum, p) => sum + p, 0);
|
|
41
|
+
const theirPoints = theirScore.setPoints.reduce((sum, p) => sum + p, 0);
|
|
42
|
+
tti.addPf(myPoints);
|
|
43
|
+
tti.addPa(theirPoints);
|
|
44
|
+
if (myScore.setsWon > theirScore.setsWon) {
|
|
45
|
+
switch (theirScore.setsWon) {
|
|
46
|
+
case 0:
|
|
47
|
+
tti.addW3_0();
|
|
48
|
+
break;
|
|
49
|
+
case 1:
|
|
50
|
+
tti.addW3_1();
|
|
51
|
+
break;
|
|
52
|
+
case 2:
|
|
53
|
+
tti.addW3_2();
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
throw new Error(``);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
switch (myScore.setsWon) {
|
|
61
|
+
case 0:
|
|
62
|
+
tti.addL0_3();
|
|
63
|
+
break;
|
|
64
|
+
case 1:
|
|
65
|
+
tti.addL1_3();
|
|
66
|
+
break;
|
|
67
|
+
case 2:
|
|
68
|
+
tti.addL2_3();
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
throw new Error(``);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.VolleyballProfile = VolleyballProfile;
|
|
77
|
+
//# sourceMappingURL=VolleyballProfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VolleyballProfile.js","sourceRoot":"","sources":["../../../src/profiles/volleyball/VolleyballProfile.ts"],"names":[],"mappings":";;;AAMA,uDAAoD;AACpD,uDAAoD;AACpD,uEAAwH;AAExH;;;;;GAKG;AACH,MAAa,iBAAiB;IAE5B,WAAW,CAAC,IAA4D;QACtE,OAAO,IAAI,iCAAe,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,WAAW,CAAC,IAA0C;QACpD,OAAO,IAAI,iCAAe,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,YAAY,CAAC,SAAiB,EAAE,SAAiB;QAC/C,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAA;IACvF,CAAC;IAED,eAAe,CAAC,YAA+B;QAC7C,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAA;IACvF,CAAC;IAED,eAAe,CAAC,IAAoB,EAAE,IAAY;QAChD,OAAO,IAAI,iDAAuB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,qBAAqB,CAAC,GAA4B,EAAE,UAAyC;QAC3F,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,KAAK,GAAG,CAAC;QACpD,MAAM,OAAO,GAAG,MAAM;YAC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AO,EAAE,CAAC;oBACd,MAAM;gBACR,KAAK,CAAC;oBACJ,GAAG,CAAC,OAAO,EAAE,CAAC;oBACd,MAAM;gBACR,KAAK,CAAC;oBACJ,GAAG,CAAC,OAAO,EAAE,CAAC;oBACd,MAAK;gBACP;oBACE,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;IACH,CAAC;CAEF;AAvED,8CAuEC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { A_Result, IResultInfo, IWinnerInfo, IVolleyballScore } from 'jl-sprt-core';
|
|
2
|
+
type VolleyballScoreUpdate = {
|
|
3
|
+
type: 'set';
|
|
4
|
+
winnerPoints: number;
|
|
5
|
+
loserPoints: number;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'extraSet';
|
|
8
|
+
winnerPoints: number;
|
|
9
|
+
loserPoints: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Resultado de un partido de volleyball.
|
|
13
|
+
* Score: IVolleyScore (sets ganados + puntos por set).
|
|
14
|
+
* Gana el equipo que llega primero a 3 sets.
|
|
15
|
+
*/
|
|
16
|
+
export declare class VolleyballResult extends A_Result<IVolleyballScore> {
|
|
17
|
+
constructor(teamOneId: string, teamTwoId: string);
|
|
18
|
+
/**
|
|
19
|
+
* Agrega el resultado de un set.
|
|
20
|
+
* @param teamId equipo que ganó el set
|
|
21
|
+
* @param winnerPoints puntos del ganador en el set
|
|
22
|
+
* @param loserPoints puntos del perdedor en el set
|
|
23
|
+
*/
|
|
24
|
+
addScore(teamId: string, val: VolleyballScoreUpdate): void;
|
|
25
|
+
getScore(teamId: string): IVolleyballScore;
|
|
26
|
+
getResultInfo(): IResultInfo<IVolleyballScore>;
|
|
27
|
+
getWinnerInfo(): IWinnerInfo;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolleyballResult = void 0;
|
|
4
|
+
const jl_sprt_core_1 = require("jl-sprt-core");
|
|
5
|
+
const startScore = () => {
|
|
6
|
+
return {
|
|
7
|
+
setsWon: 0,
|
|
8
|
+
setPoints: [],
|
|
9
|
+
extraSetPoints: 0,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Resultado de un partido de volleyball.
|
|
14
|
+
* Score: IVolleyScore (sets ganados + puntos por set).
|
|
15
|
+
* Gana el equipo que llega primero a 3 sets.
|
|
16
|
+
*/
|
|
17
|
+
class VolleyballResult extends jl_sprt_core_1.A_Result {
|
|
18
|
+
constructor(teamOneId, teamTwoId) {
|
|
19
|
+
super(teamOneId, teamTwoId, startScore);
|
|
20
|
+
// this._teamOneScore = { team: teamOneId, score: { setsWon: 0, setPoints: [] } };
|
|
21
|
+
// this._teamTwoScore = { team: teamTwoId, score: { setsWon: 0, setPoints: [] } };
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Agrega el resultado de un set.
|
|
25
|
+
* @param teamId equipo que ganó el set
|
|
26
|
+
* @param winnerPoints puntos del ganador en el set
|
|
27
|
+
* @param loserPoints puntos del perdedor en el set
|
|
28
|
+
*/
|
|
29
|
+
addScore(teamId, val) {
|
|
30
|
+
if (val.type === 'extraSet') {
|
|
31
|
+
if (teamId === this._teamOneScore.team) {
|
|
32
|
+
this._teamOneScore.score.extraSetPoints = val.winnerPoints;
|
|
33
|
+
this._teamTwoScore.score.extraSetPoints = val.loserPoints;
|
|
34
|
+
}
|
|
35
|
+
else if (teamId === this._teamTwoScore.team) {
|
|
36
|
+
this._teamTwoScore.score.extraSetPoints = val.winnerPoints;
|
|
37
|
+
this._teamOneScore.score.extraSetPoints = val.loserPoints;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
throw new Error(`en addScore: team ${teamId} no encontrado`);
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// type === 'set'
|
|
45
|
+
if (teamId === this._teamOneScore.team) {
|
|
46
|
+
this._teamOneScore.score.setsWon++;
|
|
47
|
+
this._teamOneScore.score.setPoints.push(val.winnerPoints);
|
|
48
|
+
this._teamTwoScore.score.setPoints.push(val.loserPoints);
|
|
49
|
+
}
|
|
50
|
+
else if (teamId === this._teamTwoScore.team) {
|
|
51
|
+
this._teamTwoScore.score.setsWon++;
|
|
52
|
+
this._teamTwoScore.score.setPoints.push(val.winnerPoints);
|
|
53
|
+
this._teamOneScore.score.setPoints.push(val.loserPoints);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw new Error(`en addScore: team ${teamId} no encontrado`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
getScore(teamId) {
|
|
60
|
+
if (teamId === this._teamOneScore.team)
|
|
61
|
+
return this._teamOneScore.score;
|
|
62
|
+
if (teamId === this._teamTwoScore.team)
|
|
63
|
+
return this._teamTwoScore.score;
|
|
64
|
+
throw new Error(`en getScore: team ${teamId} no encontrado`);
|
|
65
|
+
}
|
|
66
|
+
getResultInfo() {
|
|
67
|
+
const s1 = this._teamOneScore.score.setsWon;
|
|
68
|
+
const s2 = this._teamTwoScore.score.setsWon;
|
|
69
|
+
const tw = s1 > s2 ? this._teamOneScore.team
|
|
70
|
+
: s2 > s1 ? this._teamTwoScore.team : 'none';
|
|
71
|
+
const tl = s1 < s2 ? this._teamOneScore.team
|
|
72
|
+
: s2 < s1 ? this._teamTwoScore.team : 'none';
|
|
73
|
+
return {
|
|
74
|
+
teamOneScore: this._teamOneScore,
|
|
75
|
+
teamTwoScore: this._teamTwoScore,
|
|
76
|
+
teamWinner: tw,
|
|
77
|
+
teamLoser: tl,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
getWinnerInfo() {
|
|
81
|
+
const resInfo = this.getResultInfo();
|
|
82
|
+
const tw = resInfo.teamWinner;
|
|
83
|
+
const tl = resInfo.teamLoser;
|
|
84
|
+
// verificar que si hay un ganador debe haber un perdedor y
|
|
85
|
+
// si no hay un ganador no debe haber un perdedo
|
|
86
|
+
return {
|
|
87
|
+
teamWinner: tw,
|
|
88
|
+
teamLoser: tl,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.VolleyballResult = VolleyballResult;
|
|
93
|
+
//# sourceMappingURL=VolleyballResult.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VolleyballResult.js","sourceRoot":"","sources":["../../../src/profiles/volleyball/VolleyballResult.ts"],"names":[],"mappings":";;;AACA,+CAAoG;AAEpG,MAAM,UAAU,GAAG,GAAqB,EAAE;IACxC,OAAO;QACL,OAAO,EAAE,CAAC;QACV,SAAS,EAAE,EAAE;QACb,cAAc,EAAE,CAAC;KAClB,CAAA;AACH,CAAC,CAAA;AAcD;;;;GAIG;AACH,MAAa,gBAAiB,SAAQ,uBAA0B;IAE9D,YAAY,SAAiB,EAAE,SAAiB;QAC9C,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QACxC,kFAAkF;QAClF,kFAAkF;IACpF,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,MAAc,EAAE,GAA0B;QACjD,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC5B,IAAI,MAAM,KAAK,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;gBACvC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,cAAc,GAAG,GAAG,CAAC,YAAY,CAAC;gBAC3D,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,cAAc,GAAG,GAAG,CAAC,WAAW,CAAC;YAC5D,CAAC;iBAAM,IAAI,MAAM,KAAK,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;gBAC9C,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,cAAc,GAAG,GAAG,CAAC,YAAY,CAAC;gBAC3D,IAAI,CAAC,aAA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