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,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FootballMatchPlay = void 0;
|
|
4
|
+
const jl_sprt_core_1 = require("jl-sprt-core");
|
|
5
|
+
const FootballResult_1 = require("./FootballResult");
|
|
6
|
+
const randomSource_1 = require("../../randomSource");
|
|
7
|
+
/**
|
|
8
|
+
* Simulación de un partido de fútbol.
|
|
9
|
+
*
|
|
10
|
+
* Tiempo reglamentario:
|
|
11
|
+
* 80 minutos.
|
|
12
|
+
*
|
|
13
|
+
* Si el partido corresponde a una serie y el acumulado queda empatado:
|
|
14
|
+
* - se juegan 20 minutos de tiempo extra;
|
|
15
|
+
* - si continúa el empate, se ejecuta una tanda de penales.
|
|
16
|
+
*
|
|
17
|
+
* Cada advance() representa un intervalo de 5 minutos de juego.
|
|
18
|
+
*
|
|
19
|
+
* El entretiempo consume 3 intervalos de 5 minutos, pero no incrementa
|
|
20
|
+
* el tiempo de juego.
|
|
21
|
+
*/
|
|
22
|
+
class FootballMatchPlay extends jl_sprt_core_1.A_MatchPlay {
|
|
23
|
+
constructor(contextProvider) {
|
|
24
|
+
super(contextProvider);
|
|
25
|
+
/** Intervalos de descanso pendientes por consumir. */
|
|
26
|
+
this._breakLeft = 0;
|
|
27
|
+
/** Indica si el entretiempo ya fue realizado. */
|
|
28
|
+
this._halftimeDone = false;
|
|
29
|
+
/** Indica que se está jugando el tiempo extra. */
|
|
30
|
+
this._extraTime = false;
|
|
31
|
+
/** Indica que se está ejecutando la tanda de penales. */
|
|
32
|
+
this._penalties = false;
|
|
33
|
+
/** Cantidad de penales ejecutados por cada equipo. */
|
|
34
|
+
this._penaltiesTaken = 0;
|
|
35
|
+
this._penaltyRound = 0;
|
|
36
|
+
}
|
|
37
|
+
start(one, two) {
|
|
38
|
+
this._time = 0;
|
|
39
|
+
this._teamOne = one;
|
|
40
|
+
this._teamTwo = two;
|
|
41
|
+
this._result = new FootballResult_1.FootballResult(this._teamOne.id, this._teamTwo.id);
|
|
42
|
+
this._breakLeft = 0;
|
|
43
|
+
this._halftimeDone = false;
|
|
44
|
+
this._extraTime = false;
|
|
45
|
+
this._penalties = false;
|
|
46
|
+
this._penaltiesTaken = 0;
|
|
47
|
+
}
|
|
48
|
+
get isFinished() {
|
|
49
|
+
if (!this._result || !this._teamOne || !this._teamTwo)
|
|
50
|
+
return false;
|
|
51
|
+
/*
|
|
52
|
+
* Durante los penales, el partido termina cuando un equipo
|
|
53
|
+
* tiene más penales convertidos que el otro una vez agotada
|
|
54
|
+
* la ronda correspondiente.
|
|
55
|
+
*/
|
|
56
|
+
if (this._penalties)
|
|
57
|
+
return this.penaltiesHaveWinner();
|
|
58
|
+
/*
|
|
59
|
+
* Tiempo extra pendiente.
|
|
60
|
+
*/
|
|
61
|
+
if (this._extraTime)
|
|
62
|
+
return false;
|
|
63
|
+
/*
|
|
64
|
+
* El tiempo reglamentario todavía no terminó.
|
|
65
|
+
*/
|
|
66
|
+
if (this._time < FootballMatchPlay.REGULAR_TIME)
|
|
67
|
+
return false;
|
|
68
|
+
/*
|
|
69
|
+
* Partido independiente o sin resultado anterior:
|
|
70
|
+
* puede terminar empatado.
|
|
71
|
+
*/
|
|
72
|
+
if (!this.mustPlayExtraTime())
|
|
73
|
+
return true;
|
|
74
|
+
/*
|
|
75
|
+
* Si corresponde tiempo extra, todavía no terminó el partido.
|
|
76
|
+
*/
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
advance() {
|
|
80
|
+
if (!this._result || !this._teamOne || !this._teamTwo)
|
|
81
|
+
throw new Error("No se inició el match");
|
|
82
|
+
if (this.isFinished)
|
|
83
|
+
return;
|
|
84
|
+
/*
|
|
85
|
+
* Tanda de penales.
|
|
86
|
+
*/
|
|
87
|
+
if (this._penalties) {
|
|
88
|
+
this.playPenalties();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
/*
|
|
92
|
+
* Durante el entretiempo no avanza el tiempo de juego.
|
|
93
|
+
*/
|
|
94
|
+
if (this._breakLeft > 0) {
|
|
95
|
+
this._breakLeft--;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
/*
|
|
99
|
+
* Comienza el entretiempo.
|
|
100
|
+
*/
|
|
101
|
+
if (!this._halftimeDone && this._time >= FootballMatchPlay.HALFTIME_AT_MINUTE) {
|
|
102
|
+
this._halftimeDone = true;
|
|
103
|
+
/*
|
|
104
|
+
* Este intervalo ya corresponde al comienzo del descanso.
|
|
105
|
+
* Los restantes se consumen en los siguientes advance().
|
|
106
|
+
*/
|
|
107
|
+
this._breakLeft = FootballMatchPlay.HALFTIME_INTERVALS - 1;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
/*
|
|
111
|
+
* Llegamos a los 80 minutos.
|
|
112
|
+
*
|
|
113
|
+
* Si no hace falta desempatar la serie, el partido termina aunque esté empatado.
|
|
114
|
+
*/
|
|
115
|
+
if (!this._extraTime && this._time >= FootballMatchPlay.REGULAR_TIME) {
|
|
116
|
+
if (!this.mustPlayExtraTime())
|
|
117
|
+
return;
|
|
118
|
+
/*
|
|
119
|
+
* Hay empate en el acumulado de la serie.
|
|
120
|
+
* Comienza el tiempo extra.
|
|
121
|
+
*/
|
|
122
|
+
this._extraTime = true;
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
/*
|
|
126
|
+
* Avanza 5 minutos de juego.
|
|
127
|
+
*/
|
|
128
|
+
this._time += 5;
|
|
129
|
+
this.playGoals();
|
|
130
|
+
/*
|
|
131
|
+
* Si terminó el tiempo extra, determinar si hacen falta penales.
|
|
132
|
+
*/
|
|
133
|
+
if (this._extraTime && this._time >= FootballMatchPlay.EXTRA_TIME) {
|
|
134
|
+
if (this.isAggregateTie()) {
|
|
135
|
+
this._penalties = true;
|
|
136
|
+
this._penaltiesTaken = 0;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Determina si la serie necesita tiempo extra.
|
|
142
|
+
*
|
|
143
|
+
* Para un partido independiente no existe un resultado anterior,
|
|
144
|
+
* por lo que el partido puede terminar empatado.
|
|
145
|
+
*
|
|
146
|
+
* En una serie de ida y vuelta, se compara el acumulado de goles.
|
|
147
|
+
*/
|
|
148
|
+
mustPlayExtraTime() {
|
|
149
|
+
const context = this.context;
|
|
150
|
+
/*
|
|
151
|
+
* Partido independiente.
|
|
152
|
+
*/
|
|
153
|
+
if (!context)
|
|
154
|
+
return false;
|
|
155
|
+
/*
|
|
156
|
+
* Primer partido de una serie.
|
|
157
|
+
* Todavía no existe un acumulado anterior.
|
|
158
|
+
*/
|
|
159
|
+
if (context.results.length === 0)
|
|
160
|
+
return false;
|
|
161
|
+
/*
|
|
162
|
+
* Actualmente solo soportamos ida y vuelta.
|
|
163
|
+
*/
|
|
164
|
+
if (context.results.length !== 1)
|
|
165
|
+
throw new Error("Unsupported series context");
|
|
166
|
+
return this.isAggregateTie();
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Determina si el acumulado de la serie está empatado.
|
|
170
|
+
*
|
|
171
|
+
* Se suma el marcador del partido anterior y el marcador
|
|
172
|
+
* del partido actual.
|
|
173
|
+
*/
|
|
174
|
+
isAggregateTie() {
|
|
175
|
+
const context = this.context;
|
|
176
|
+
if (!context || context.results.length === 0)
|
|
177
|
+
return false;
|
|
178
|
+
if (context.results.length !== 1)
|
|
179
|
+
throw new Error("Unsupported series context");
|
|
180
|
+
const previousResult = context.results[0];
|
|
181
|
+
const previousOne = previousResult.getScore(this._teamOne.id);
|
|
182
|
+
const previousTwo = previousResult.getScore(this._teamTwo.id);
|
|
183
|
+
const currentResult = this._result;
|
|
184
|
+
const currentOne = currentResult.getScore(this._teamOne.id);
|
|
185
|
+
const currentTwo = currentResult.getScore(this._teamTwo.id);
|
|
186
|
+
const totalOne = previousOne.goals +
|
|
187
|
+
previousOne.penalties + // si es distinto de 0 debe dar error
|
|
188
|
+
currentOne.goals +
|
|
189
|
+
currentOne.penalties;
|
|
190
|
+
const totalTwo = previousTwo.goals +
|
|
191
|
+
previousTwo.penalties + // si es distinto de 0 debe dar error
|
|
192
|
+
currentTwo.goals +
|
|
193
|
+
currentTwo.penalties;
|
|
194
|
+
return totalOne === totalTwo;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Genera los goles de un intervalo de juego.
|
|
198
|
+
*/
|
|
199
|
+
playGoals() {
|
|
200
|
+
const result = this._result;
|
|
201
|
+
if ((0, randomSource_1.randomFloat)() < 0.10) {
|
|
202
|
+
result.addScore(this._teamOne.id, "goals");
|
|
203
|
+
}
|
|
204
|
+
if ((0, randomSource_1.randomFloat)() < 0.08) {
|
|
205
|
+
result.addScore(this._teamTwo.id, "goals");
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
playPenalties() {
|
|
209
|
+
const result = this._result;
|
|
210
|
+
const one = this._teamOne.id;
|
|
211
|
+
const two = this._teamTwo.id;
|
|
212
|
+
for (let i = 0; i < FootballMatchPlay.PENALTIES_PER_INTERVAL; i++) {
|
|
213
|
+
/*
|
|
214
|
+
* Cada ronda tiene un penal por equipo.
|
|
215
|
+
*/
|
|
216
|
+
if ((0, randomSource_1.randomFloat)() < 0.75)
|
|
217
|
+
result.addScore(one, 'penalties');
|
|
218
|
+
if ((0, randomSource_1.randomFloat)() < 0.75)
|
|
219
|
+
result.addScore(two, 'penalties');
|
|
220
|
+
this._penaltyRound++;
|
|
221
|
+
if (this.penaltiesHaveWinner())
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Determina si ya existe ganador en la tanda de penales.
|
|
227
|
+
*/
|
|
228
|
+
penaltiesHaveWinner() {
|
|
229
|
+
const result = this._result;
|
|
230
|
+
const one = result.getScore(this._teamOne.id).penalties;
|
|
231
|
+
const two = result.getScore(this._teamTwo.id).penalties;
|
|
232
|
+
/*
|
|
233
|
+
* Durante las primeras 5 rondas:
|
|
234
|
+
* comprobar si el equipo que va perdiendo ya no puede alcanzar
|
|
235
|
+
* al que va ganando.
|
|
236
|
+
* * A veces esto pasa a mitad de una ronda
|
|
237
|
+
*/
|
|
238
|
+
if (this._penaltyRound <= FootballMatchPlay.REGULAR_PENALTY_ROUNDS) {
|
|
239
|
+
const roundsRemaining = FootballMatchPlay.REGULAR_PENALTY_ROUNDS - this._penaltyRound;
|
|
240
|
+
return Math.abs(one - two) > roundsRemaining;
|
|
241
|
+
}
|
|
242
|
+
/*
|
|
243
|
+
* Después de las 5 rondas, se juega muerte súbita.
|
|
244
|
+
*
|
|
245
|
+
* Si ambos ejecutaron un penal en esta ronda y hay diferencia,
|
|
246
|
+
* hay ganador.
|
|
247
|
+
*/
|
|
248
|
+
if (one !== two)
|
|
249
|
+
return true;
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
exports.FootballMatchPlay = FootballMatchPlay;
|
|
254
|
+
/** Minuto de juego en que comienza el entretiempo. */
|
|
255
|
+
FootballMatchPlay.HALFTIME_AT_MINUTE = 40;
|
|
256
|
+
/** Intervalos de descanso del entretiempo. */
|
|
257
|
+
FootballMatchPlay.HALFTIME_INTERVALS = 3;
|
|
258
|
+
/** Final del tiempo reglamentario. */
|
|
259
|
+
FootballMatchPlay.REGULAR_TIME = 80;
|
|
260
|
+
/** Final del tiempo extra. */
|
|
261
|
+
FootballMatchPlay.EXTRA_TIME = 100;
|
|
262
|
+
/** Penales máximos de la primera ronda. */
|
|
263
|
+
FootballMatchPlay.PENALTIES_PER_INTERVAL = 2;
|
|
264
|
+
FootballMatchPlay.REGULAR_PENALTY_ROUNDS = 5;
|
|
265
|
+
//# sourceMappingURL=FootballMatchPlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FootballMatchPlay.js","sourceRoot":"","sources":["../../../src/profiles/football/FootballMatchPlay.ts"],"names":[],"mappings":";;;AAAA,+CAAiF;AAEjF,qDAAkD;AAClD,qDAAiD;AAEjD;;;;;;;;;;;;;;GAcG;AACH,MAAa,iBAAkB,SAAQ,0BAA2C;IAmChF,YAAY,eAAsD;QAChE,KAAK,CAAC,eAAe,CAAC,CAAC;QAvBzB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|
1
|
+
import { IResultInfo, ISportProfile, IMatchCreationInfo, ISerieCreationInfo, IFootballScore } from "jl-sprt-core";
|
|
2
|
+
import { FootballTeam } from './FootballTeam';
|
|
3
|
+
import { FootballRoster } from './FootballRoster';
|
|
4
|
+
import { FootballResult } from "./FootballResult";
|
|
5
|
+
import { FootballMatch } from "./FootballMatch";
|
|
6
|
+
import { FootballSerie } from "./FootballSerie";
|
|
7
|
+
import { FootballTeamTableItem, FootballMatchResults, FootballMatchPuntuations } from "./FootballTeamTableItem";
|
|
8
|
+
/**
|
|
9
|
+
* Profile para fútbol.
|
|
10
|
+
* Score: number (goles)
|
|
11
|
+
* Resultados: W (win), D (draw), L (loss)
|
|
12
|
+
* Puntuaciones: gf (goles a favor), ga (goles en contra)
|
|
13
|
+
*/
|
|
14
|
+
export declare class FootballProfile implements ISportProfile<IFootballScore, FootballMatchResults, FootballMatchPuntuations, FootballRoster> {
|
|
15
|
+
createMatch(info: IMatchCreationInfo<IFootballScore, FootballRoster>): FootballMatch;
|
|
16
|
+
createSerie(info: ISerieCreationInfo<FootballRoster>): FootballSerie;
|
|
17
|
+
createResult(teamOneId: string, teamTwoId: string): FootballResult;
|
|
18
|
+
createTableItem(team: FootballTeam, bsId: string): FootballTeamTableItem;
|
|
19
|
+
updateTableFromResult(tti: FootballTeamTableItem, resultInfo: IResultInfo<IFootballScore>): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FootballProfile = void 0;
|
|
4
|
+
const FootballResult_1 = require("./FootballResult");
|
|
5
|
+
const FootballMatch_1 = require("./FootballMatch");
|
|
6
|
+
const FootballSerie_1 = require("./FootballSerie");
|
|
7
|
+
const FootballTeamTableItem_1 = require("./FootballTeamTableItem");
|
|
8
|
+
/**
|
|
9
|
+
* Profile para fútbol.
|
|
10
|
+
* Score: number (goles)
|
|
11
|
+
* Resultados: W (win), D (draw), L (loss)
|
|
12
|
+
* Puntuaciones: gf (goles a favor), ga (goles en contra)
|
|
13
|
+
*/
|
|
14
|
+
class FootballProfile {
|
|
15
|
+
createMatch(info) {
|
|
16
|
+
return new FootballMatch_1.FootballMatch(info);
|
|
17
|
+
}
|
|
18
|
+
createSerie(info) {
|
|
19
|
+
return new FootballSerie_1.FootballSerie(info);
|
|
20
|
+
}
|
|
21
|
+
createResult(teamOneId, teamTwoId) {
|
|
22
|
+
return new FootballResult_1.FootballResult(teamOneId, teamTwoId);
|
|
23
|
+
}
|
|
24
|
+
createTableItem(team, bsId) {
|
|
25
|
+
return new FootballTeamTableItem_1.FootballTeamTableItem(team, bsId);
|
|
26
|
+
}
|
|
27
|
+
updateTableFromResult(tti, resultInfo) {
|
|
28
|
+
const tid = tti.team.id;
|
|
29
|
+
const isHome = resultInfo.teamOneScore.team === tid;
|
|
30
|
+
const myScore = isHome
|
|
31
|
+
? resultInfo.teamOneScore.score
|
|
32
|
+
: resultInfo.teamTwoScore.score;
|
|
33
|
+
const theirScore = isHome
|
|
34
|
+
? resultInfo.teamTwoScore.score
|
|
35
|
+
: resultInfo.teamOneScore.score;
|
|
36
|
+
tti.addGf(myScore.goals);
|
|
37
|
+
tti.addGa(theirScore.goals);
|
|
38
|
+
if (resultInfo.teamWinner === tid) {
|
|
39
|
+
tti.addWM();
|
|
40
|
+
}
|
|
41
|
+
else if (resultInfo.teamLoser === tid) {
|
|
42
|
+
tti.addLM();
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
tti.addDM();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.FootballProfile = FootballProfile;
|
|
50
|
+
//# sourceMappingURL=FootballProfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FootballProfile.js","sourceRoot":"","sources":["../../../src/profiles/football/FootballProfile.ts"],"names":[],"mappings":";;;AAIA,qDAAkD;AAElD,mDAAgD;AAChD,mDAAg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AG,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAvCD,0CAuCC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { A_Result, IResultInfo, IFootballScore, IWinnerInfo } from 'jl-sprt-core';
|
|
2
|
+
type FootballScoreUpdate = 'goals' | 'penalties';
|
|
3
|
+
/**
|
|
4
|
+
* Resultado de un partido de fútbol.
|
|
5
|
+
* Score: number (goles). El ganador es quien tiene mayor cantidad de goles.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FootballResult extends A_Result<IFootballScore> {
|
|
8
|
+
constructor(one: string, two: string);
|
|
9
|
+
addScore(id: string, t: FootballScoreUpdate): void;
|
|
10
|
+
getScore(id: string): IFootballScore;
|
|
11
|
+
getResultInfo(): IResultInfo<IFootballScore>;
|
|
12
|
+
getWinnerInfo(): IWinnerInfo;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FootballResult = void 0;
|
|
4
|
+
const jl_sprt_core_1 = require("jl-sprt-core");
|
|
5
|
+
const startScore = () => {
|
|
6
|
+
return {
|
|
7
|
+
goals: 0,
|
|
8
|
+
penalties: 0
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Resultado de un partido de fútbol.
|
|
13
|
+
* Score: number (goles). El ganador es quien tiene mayor cantidad de goles.
|
|
14
|
+
*/
|
|
15
|
+
class FootballResult extends jl_sprt_core_1.A_Result {
|
|
16
|
+
constructor(one, two) {
|
|
17
|
+
super(one, two, startScore);
|
|
18
|
+
}
|
|
19
|
+
addScore(id, t) {
|
|
20
|
+
let score;
|
|
21
|
+
if (id === this._teamOneScore.team) {
|
|
22
|
+
score = this._teamOneScore.score;
|
|
23
|
+
}
|
|
24
|
+
else if (id === this._teamTwoScore.team) {
|
|
25
|
+
score = this._teamTwoScore.score;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw new Error(`en add score`);
|
|
29
|
+
}
|
|
30
|
+
score[t]++;
|
|
31
|
+
}
|
|
32
|
+
getScore(id) {
|
|
33
|
+
if (id === this._teamOneScore.team) {
|
|
34
|
+
return this._teamOneScore.score;
|
|
35
|
+
}
|
|
36
|
+
else if (id === this._teamTwoScore.team) {
|
|
37
|
+
return this._teamTwoScore.score;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
throw new Error(`en get score`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
getResultInfo() {
|
|
44
|
+
const goalsOne = this._teamOneScore.score.goals;
|
|
45
|
+
const goalsTwo = this._teamTwoScore.score.goals;
|
|
46
|
+
const winner = goalsOne > goalsTwo
|
|
47
|
+
? this._teamOneScore.team
|
|
48
|
+
: goalsTwo > goalsOne
|
|
49
|
+
? this._teamTwoScore.team
|
|
50
|
+
: 'none';
|
|
51
|
+
const loser = goalsOne < goalsTwo
|
|
52
|
+
? this._teamOneScore.team
|
|
53
|
+
: goalsTwo < goalsOne
|
|
54
|
+
? this._teamTwoScore.team
|
|
55
|
+
: 'none';
|
|
56
|
+
return {
|
|
57
|
+
teamOneScore: this._teamOneScore,
|
|
58
|
+
teamTwoScore: this._teamTwoScore,
|
|
59
|
+
teamWinner: winner,
|
|
60
|
+
teamLoser: loser,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
getWinnerInfo() {
|
|
64
|
+
const result = this.getResultInfo();
|
|
65
|
+
return {
|
|
66
|
+
teamWinner: result.teamWinner,
|
|
67
|
+
teamLoser: result.teamLoser,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.FootballResult = FootballResult;
|
|
72
|
+
//# sourceMappingURL=FootballResult.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FootballResult.js","sourceRoot":"","sources":["../../../src/profiles/football/FootballResult.ts"],"names":[],"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CAAC,KAAK,CAAC,KAAK,CAAC;QAEhD,MAAM,MAAM,GACV,QAAQ,GAAG,QAAQ;YACjB,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI;YACzB,CAAC,CAAC,QAAQ,GAAG,QAAQ;gBACnB,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI;gBACzB,CAAC,CAAC,MAAM,CAAC;QAEf,MAAM,KAAK,GACT,QAAQ,GAAG,QAAQ;YACjB,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI;YACzB,CAAC,CAAC,QAAQ,GAAG,QAAQ;gBACnB,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI;gBACzB,CAAC,CAAC,MAAM,CAAC;QAEf,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,UAAU,EAAE,MAAM;YAClB,SAAS,EAAE,KAAK;SACjB,CAAC;IACJ,CAAC;IAED,aAAa;QACX,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAEpC,OAAO;YACL,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B,CAAC;IACJ,CAAC;CACF;AA9DD,wCA8DC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FootballRoster = void 0;
|
|
4
|
+
const jl_sprt_core_1 = require("jl-sprt-core");
|
|
5
|
+
class FootballRoster extends jl_sprt_core_1.A_TeamRoster {
|
|
6
|
+
}
|
|
7
|
+
exports.FootballRoster = FootballRoster;
|
|
8
|
+
//# sourceMappingURL=FootballRoster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FootballRoster.js","sourceRoot":"","sources":["../../../src/profiles/football/FootballRoster.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAE5C,MAAa,cAAe,SAAQ,2BAAY;CAAG;AAAnD,wCAAmD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FootballScore.js","sourceRoot":"","sources":["../../../src/profiles/football/FootballScore.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { A_Serie, IFootballScore, ISerieCreationInfo } from 'jl-sprt-core';
|
|
2
|
+
import { FootballRoster } from './FootballRoster';
|
|
3
|
+
import { FootballTeam } from './FootballTeam';
|
|
4
|
+
export interface IFootballSerieCreationInfo extends ISerieCreationInfo<FootballRoster> {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Serie de Football.
|
|
8
|
+
* MatchScoreType: IFootballScore (goals + penalties)
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare class FootballSerie extends A_Serie<IFootballScore, FootballRoster> {
|
|
12
|
+
constructor(info: IFootballSerieCreationInfo);
|
|
13
|
+
get isFinished(): boolean;
|
|
14
|
+
get winner(): FootballTeam;
|
|
15
|
+
get loser(): FootballTeam;
|
|
16
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FootballSerie = void 0;
|
|
4
|
+
const jl_sprt_core_1 = require("jl-sprt-core");
|
|
5
|
+
const FootballMatch_1 = require("./FootballMatch");
|
|
6
|
+
/**
|
|
7
|
+
* Serie de Football.
|
|
8
|
+
* MatchScoreType: IFootballScore (goals + penalties)
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
class FootballSerie extends jl_sprt_core_1.A_Serie {
|
|
12
|
+
constructor(info) {
|
|
13
|
+
super(info, (mci) => { return new FootballMatch_1.FootballMatch(mci); });
|
|
14
|
+
}
|
|
15
|
+
get isFinished() {
|
|
16
|
+
return this._matches.every((m) => m.isFinished);
|
|
17
|
+
}
|
|
18
|
+
get winner() {
|
|
19
|
+
if (!this.isFinished)
|
|
20
|
+
throw new Error('La serie todavía no terminó');
|
|
21
|
+
const results = this.getResults();
|
|
22
|
+
/*
|
|
23
|
+
* Serie de un solo partido.
|
|
24
|
+
*/
|
|
25
|
+
if (results.length === 1) {
|
|
26
|
+
const winnerId = results[0].getWinnerInfo().teamWinner;
|
|
27
|
+
if (winnerId === this.teamOne.id)
|
|
28
|
+
return this.teamOne;
|
|
29
|
+
if (winnerId === this.teamTwo.id)
|
|
30
|
+
return this.teamTwo;
|
|
31
|
+
throw new Error('No hubo ganador en la serie de Football');
|
|
32
|
+
}
|
|
33
|
+
/*
|
|
34
|
+
* Actualmente solo soportamos series de ida y vuelta.
|
|
35
|
+
*/
|
|
36
|
+
if (results.length !== 2)
|
|
37
|
+
throw new Error('Unsupported Football series');
|
|
38
|
+
let teamOneTotal = 0;
|
|
39
|
+
let teamTwoTotal = 0;
|
|
40
|
+
for (const result of results) {
|
|
41
|
+
const teamOneScore = result.getScore(this.teamOne.id);
|
|
42
|
+
const teamTwoScore = result.getScore(this.teamTwo.id);
|
|
43
|
+
teamOneTotal += teamOneScore.goals + teamOneScore.penalties;
|
|
44
|
+
teamTwoTotal += teamTwoScore.goals + teamTwoScore.penalties;
|
|
45
|
+
}
|
|
46
|
+
if (teamOneTotal > teamTwoTotal)
|
|
47
|
+
return this.teamOne;
|
|
48
|
+
if (teamTwoTotal > teamOneTotal)
|
|
49
|
+
return this.teamTwo;
|
|
50
|
+
throw new Error('La serie terminó empatada');
|
|
51
|
+
}
|
|
52
|
+
get loser() {
|
|
53
|
+
return (this.winner.id === this._teamTwo.id) ? this.teamOne : this.teamTwo;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.FootballSerie = FootballSerie;
|
|
57
|
+
//# sourceMappingURL=FootballSerie.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FootballSerie.js","sourceRoot":"","sources":["../../../src/profiles/football/FootballSerie.ts"],"names":[],"mappings":";;;A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O,CAAC,EAAE,CAAC,CAAC;YACtD,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAEtD,YAAY,IAAI,YAAY,CAAC,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC;YAC5D,YAAY,IAAI,YAAY,CAAC,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC;QAC9D,CAAC;QAED,IAAI,YAAY,GAAG,YAAY;YAC7B,OAAO,IAAI,CAAC,OAAO,CAAC;QAEtB,IAAI,YAAY,GAAG,YAAY;YAC7B,OAAO,IAAI,CAAC,OAAO,CAAC;QAEtB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,KAAK;QACP,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IAC7E,CAAC;CACF;AA5DD,sCA4DC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FootballTeam = void 0;
|
|
4
|
+
const jl_sprt_core_1 = require("jl-sprt-core");
|
|
5
|
+
const FootballRoster_1 = require("./FootballRoster");
|
|
6
|
+
class FootballTeam extends jl_sprt_core_1.A_Team {
|
|
7
|
+
constructor(itc) {
|
|
8
|
+
super(itc);
|
|
9
|
+
}
|
|
10
|
+
getTeamMatch() {
|
|
11
|
+
return new FootballRoster_1.FootballRoster(this.id);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.FootballTeam = FootballTeam;
|
|
15
|
+
//# sourceMappingURL=FootballTeam.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FootballTeam.js","sourceRoot":"","sources":["../../../src/profiles/football/FootballTeam.ts"],"names":[],"mappings":";;;AAAA,+CAAkD;AAClD,qDAAgD;AAEhD,MAAa,YAAa,SAAQ,qBAAsB;IACtD,YAAY,GAAiB;QAC3B,KAAK,CAAC,GAAG,CAAC,CAAA;IACZ,CAAC;IAED,YAAY;QACV,OAAO,IAAI,+BAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;CACF;AARD,oCAQC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { A_TeamTableItem, AnyTeamTableItem, IA_TeamTableItemBase, SortFunc } from "jl-sprt-core";
|
|
2
|
+
import { FootballTeam } from './FootballTeam';
|
|
3
|
+
export type FootballMatchResults = 'W' | 'D' | 'L';
|
|
4
|
+
export type FootballMatchPuntuations = 'gf' | 'ga';
|
|
5
|
+
export type IFootballTeamTableItem = IA_TeamTableItemBase & {
|
|
6
|
+
W: number;
|
|
7
|
+
D: number;
|
|
8
|
+
L: number;
|
|
9
|
+
gf: number;
|
|
10
|
+
ga: number;
|
|
11
|
+
sg: number;
|
|
12
|
+
};
|
|
13
|
+
export declare class FootballTeamTableItem extends A_TeamTableItem<FootballMatchResults, FootballMatchPuntuations> {
|
|
14
|
+
constructor(t: FootballTeam, bsId: string);
|
|
15
|
+
get ps(): number;
|
|
16
|
+
getInitialCountOfMathResults(): {
|
|
17
|
+
[k in FootballMatchResults]: number;
|
|
18
|
+
};
|
|
19
|
+
getInitialCountOfMathPuntuations(): {
|
|
20
|
+
[k in FootballMatchPuntuations]: number;
|
|
21
|
+
};
|
|
22
|
+
get W(): number;
|
|
23
|
+
get D(): number;
|
|
24
|
+
get L(): number;
|
|
25
|
+
get gf(): number;
|
|
26
|
+
get ga(): number;
|
|
27
|
+
get sg(): number;
|
|
28
|
+
addWM(): void;
|
|
29
|
+
addDM(): void;
|
|
30
|
+
addLM(): void;
|
|
31
|
+
addGf(g: number): void;
|
|
32
|
+
addGa(g: number): void;
|
|
33
|
+
getSortFunc(): SortFunc<AnyTeamTableItem>;
|
|
34
|
+
getInterface(): IFootballTeamTableItem;
|
|
35
|
+
}
|
|
36
|
+
export declare const footballSortFunc: SortFunc<FootballTeamTableItem>;
|