mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-10-31 20:56:08 +01:00
Implemented koya tiebreak
This commit is contained in:
parent
7f642b905e
commit
56e831b372
@ -144,4 +144,20 @@ abstract class Tiebreaks extends Tournament
|
||||
$allratings = array_slice($allratings, $cut);
|
||||
return round(array_sum($allratings) / count($allratings));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @param int $cut
|
||||
* @return int
|
||||
*/
|
||||
protected function calculateKoya(Player $player, int $cut = 50)
|
||||
{
|
||||
$tiebreak = 0;
|
||||
foreach ($player->getPairings() as $plkey=>$plpairing) {
|
||||
if (($plpairing->getOpponent()->getNoOfWins() / count($plpairing->getOpponent()->getPairings()) * 100) >= $cut) {
|
||||
$tiebreak += $plpairing->getOpponent()->getNoOfWins();
|
||||
}
|
||||
}
|
||||
return $tiebreak;
|
||||
}
|
||||
}
|
||||
|
@ -296,6 +296,9 @@ class Tournament extends Tiebreaks
|
||||
case Tiebreak::AroCut:
|
||||
return $this->calculateAverageRating($player, 1);
|
||||
break;
|
||||
case Tiebreak::Koya:
|
||||
return $this->calculateKoya($player);
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user