BUGFIX: Tournament::calculateAverageRating() returned NaN if no games

This commit is contained in:
Jeroen De Meerleer 2019-09-27 18:02:43 +02:00
parent dfea5a3cfb
commit b445f2f301
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
2 changed files with 6 additions and 1 deletions

View File

@ -9,6 +9,7 @@
* BUGFIX: `Tournament::calculateBuchholz()` did not return the correct score when player had unplayed rounds * BUGFIX: `Tournament::calculateBuchholz()` did not return the correct score when player had unplayed rounds
* BUGFIX: `Tournament::calculateMutualResult()` returned NULL if result was invalid * BUGFIX: `Tournament::calculateMutualResult()` returned NULL if result was invalid
* BUGFIX: `Tournament::calculateBaumbach()` treated bye as won * BUGFIX: `Tournament::calculateBaumbach()` treated bye as won
* BUGFIX: `Tournament::calculateAverageRating()` returned NaN if no games were played
## v1.1.2 (Release: 21-jun-2019) ## v1.1.2 (Release: 21-jun-2019)
* ENHANCEMENT: Added update section to dist/readme.md * ENHANCEMENT: Added update section to dist/readme.md

View File

@ -650,7 +650,11 @@ class Tournament
} }
sort($allratings); sort($allratings);
$allratings = array_slice($allratings, $cut); $allratings = array_slice($allratings, $cut);
return round(array_sum($allratings) / count($allratings)); $tiebreak = 0;
if (count($allratings) > 0) {
$tiebreak = round(array_sum($allratings) / count($allratings));
}
return $tiebreak;
} }