mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-22 06:26:57 +01:00
Added function to calcultate buchholz score
This commit is contained in:
parent
b30bc7d256
commit
00c79b347c
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user