mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-12-22 04:11:22 +01:00
Reimplemented official kashdan tiebreak
This commit is contained in:
parent
21d105627e
commit
91ea4c7a64
@ -251,7 +251,7 @@ abstract class Tiebreaks extends Tournament
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateKashdan(Player $player): ?float
|
||||
protected function calculateSoccerKashdan(Player $player): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
@ -272,6 +272,32 @@ abstract class Tiebreaks extends Tournament
|
||||
return $tiebreak; // - $player->getNoOfWins();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateKashdan(Player $player): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
$toadd = 0;
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$toadd = 4;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
|
||||
$toadd = 2;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Lost) !== false) {
|
||||
$toadd = 1;
|
||||
}
|
||||
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) !== false) {
|
||||
$toadd = 0;
|
||||
}
|
||||
$tiebreak += $toadd;
|
||||
}
|
||||
return $tiebreak; // - $player->getNoOfWins();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
|
Loading…
Reference in New Issue
Block a user