Added function to calcultate buchholz score

This commit is contained in:
Jeroen De Meerleer 2019-09-27 16:27:04 +02:00
parent b30bc7d256
commit 00c79b347c
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

View File

@ -192,7 +192,29 @@ class Player
return $points;
}
/**
* Returns the points of the player that should be used for buchholz.
*
* 1 Point is awarded for winning
* 0.5 points are awarded for draw
* 0.5 points for not played
*
* @return float
*/
public function getPointsForBuchholz(): float
{
$points = 0;
foreach ($this->getPairings() as $pairing) {
if (array_search($pairing->getResult(), Constants::NotPlayed) !== false) {
$points = $points + 0.5;
} elseif (array_search($pairing->getResult(), Constants::Won) !== false) {
$points = $points + 1;
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
$points = $points + 0.5;
}
}
return $points;
}
/**
* Returns the performance rating of the player
*