volleyballsimtypes 0.0.214 → 0.0.215
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.
|
@@ -33,26 +33,20 @@ class Match {
|
|
|
33
33
|
return `${this.getTeamSets(match_team_1.MatchTeam.HOME)}-${this.getTeamSets(match_team_1.MatchTeam.AWAY)}`;
|
|
34
34
|
}
|
|
35
35
|
isOver() {
|
|
36
|
+
if (this.status === data_1.StatusEnum.COMPLETE)
|
|
37
|
+
return true;
|
|
36
38
|
const setsToWin = 3;
|
|
37
39
|
const homeSets = this.getTeamSets(match_team_1.MatchTeam.HOME);
|
|
38
40
|
const awaySets = this.getTeamSets(match_team_1.MatchTeam.AWAY);
|
|
39
41
|
return !(homeSets < setsToWin && awaySets < setsToWin);
|
|
40
42
|
}
|
|
41
43
|
getWinner() {
|
|
42
|
-
if (!this.isOver())
|
|
43
|
-
throw new Error(
|
|
44
|
+
if (!this.isOver()) {
|
|
45
|
+
throw new Error(`UNFINISHED_MATCH: ${this.id}, homeSets=[${this.sets.map(s => s.homeScore).join(', ')}], awaySets=[${this.sets.map(s => s.awayScore).join(', ')}], status=${this.status}`);
|
|
46
|
+
}
|
|
44
47
|
const homeSets = this.getTeamSets(match_team_1.MatchTeam.HOME);
|
|
45
48
|
const awaySets = this.getTeamSets(match_team_1.MatchTeam.AWAY);
|
|
46
49
|
return homeSets > awaySets ? this.homeTeam : this.awayTeam;
|
|
47
50
|
}
|
|
48
|
-
isWinner(team) {
|
|
49
|
-
if (team === match_team_1.MatchTeam.HOME && this.getWinner() === this.homeTeam)
|
|
50
|
-
return true;
|
|
51
|
-
else
|
|
52
|
-
return team === match_team_1.MatchTeam.AWAY && this.getWinner() === this.awayTeam;
|
|
53
|
-
}
|
|
54
|
-
isSimulated() {
|
|
55
|
-
return this.status === data_1.StatusEnum.COMPLETE;
|
|
56
|
-
}
|
|
57
51
|
}
|
|
58
52
|
exports.Match = Match;
|
|
@@ -30,25 +30,19 @@ export class Match {
|
|
|
30
30
|
return `${this.getTeamSets(MatchTeam.HOME)}-${this.getTeamSets(MatchTeam.AWAY)}`;
|
|
31
31
|
}
|
|
32
32
|
isOver() {
|
|
33
|
+
if (this.status === StatusEnum.COMPLETE)
|
|
34
|
+
return true;
|
|
33
35
|
const setsToWin = 3;
|
|
34
36
|
const homeSets = this.getTeamSets(MatchTeam.HOME);
|
|
35
37
|
const awaySets = this.getTeamSets(MatchTeam.AWAY);
|
|
36
38
|
return !(homeSets < setsToWin && awaySets < setsToWin);
|
|
37
39
|
}
|
|
38
40
|
getWinner() {
|
|
39
|
-
if (!this.isOver())
|
|
40
|
-
throw new Error(
|
|
41
|
+
if (!this.isOver()) {
|
|
42
|
+
throw new Error(`UNFINISHED_MATCH: ${this.id}, homeSets=[${this.sets.map(s => s.homeScore).join(', ')}], awaySets=[${this.sets.map(s => s.awayScore).join(', ')}], status=${this.status}`);
|
|
43
|
+
}
|
|
41
44
|
const homeSets = this.getTeamSets(MatchTeam.HOME);
|
|
42
45
|
const awaySets = this.getTeamSets(MatchTeam.AWAY);
|
|
43
46
|
return homeSets > awaySets ? this.homeTeam : this.awayTeam;
|
|
44
47
|
}
|
|
45
|
-
isWinner(team) {
|
|
46
|
-
if (team === MatchTeam.HOME && this.getWinner() === this.homeTeam)
|
|
47
|
-
return true;
|
|
48
|
-
else
|
|
49
|
-
return team === MatchTeam.AWAY && this.getWinner() === this.awayTeam;
|
|
50
|
-
}
|
|
51
|
-
isSimulated() {
|
|
52
|
-
return this.status === StatusEnum.COMPLETE;
|
|
53
|
-
}
|
|
54
48
|
}
|