mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-22 06:26:57 +01:00
Implemented koya tiebreak
This commit is contained in:
parent
4672c91298
commit
6d4eeff234
@ -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