mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-22 06:26:57 +01:00
Implemented Sonneborn-Berger
This commit is contained in:
parent
eba962a11c
commit
5128d2762e
@ -153,7 +153,7 @@ abstract class Tiebreaks extends Tournament
|
|||||||
protected function calculateKoya(Player $player, int $cut = 50)
|
protected function calculateKoya(Player $player, int $cut = 50)
|
||||||
{
|
{
|
||||||
$tiebreak = 0;
|
$tiebreak = 0;
|
||||||
foreach ($player->getPairings() as $plkey=>$plpairing) {
|
foreach ($player->getPairings() as $plkey => $plpairing) {
|
||||||
if (($plpairing->getOpponent()->getNoOfWins() / count($plpairing->getOpponent()->getPairings()) * 100) >= $cut) {
|
if (($plpairing->getOpponent()->getNoOfWins() / count($plpairing->getOpponent()->getPairings()) * 100) >= $cut) {
|
||||||
$tiebreak += $plpairing->getOpponent()->getNoOfWins();
|
$tiebreak += $plpairing->getOpponent()->getNoOfWins();
|
||||||
}
|
}
|
||||||
@ -183,9 +183,27 @@ abstract class Tiebreaks extends Tournament
|
|||||||
array_splice($intpairings, $cutlowest);
|
array_splice($intpairings, $cutlowest);
|
||||||
array_splice($intpairings, 0 - $cuthighest);
|
array_splice($intpairings, 0 - $cuthighest);
|
||||||
|
|
||||||
foreach ($intpairings as $intkey=>$intpairing) {
|
foreach ($intpairings as $intkey => $intpairing) {
|
||||||
$tiebreak += $intpairing->getOpponent()->getPoints();
|
$tiebreak += $intpairing->getOpponent()->getPoints();
|
||||||
}
|
}
|
||||||
return $tiebreak;
|
return $tiebreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Player $player
|
||||||
|
* @return float|int|null
|
||||||
|
*/
|
||||||
|
protected function calculateSonneborn(Player $player)
|
||||||
|
{
|
||||||
|
$tiebreak = 0;
|
||||||
|
foreach ($player->getPairings() as $key => $pairing) {
|
||||||
|
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||||
|
$tiebreak += $pairing->getOpponent()->getPoints();
|
||||||
|
} elseif (array_search($pairing->getResult(), Constants::draw) !== false) {
|
||||||
|
$tiebreak += $pairing->getOpponent()->getPoints() / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $tiebreak;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,6 +308,9 @@ class Tournament extends Tiebreaks
|
|||||||
case Tiebreak::BuchholzMed:
|
case Tiebreak::BuchholzMed:
|
||||||
return $this->calculateBuchholz($player, 1, 1);
|
return $this->calculateBuchholz($player, 1, 1);
|
||||||
break;
|
break;
|
||||||
|
case Tiebreak::Sonneborn:
|
||||||
|
return $this->calculateSonneborn($player);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user