Implemented koya tiebreak

This commit is contained in:
Jeroen De Meerleer 2019-05-30 21:07:05 +02:00
parent 4672c91298
commit 6d4eeff234
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
2 changed files with 19 additions and 0 deletions

View File

@ -144,4 +144,20 @@ abstract class Tiebreaks extends Tournament
$allratings = array_slice($allratings, $cut); $allratings = array_slice($allratings, $cut);
return round(array_sum($allratings) / count($allratings)); 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;
}
} }

View File

@ -296,6 +296,9 @@ class Tournament extends Tiebreaks
case Tiebreak::AroCut: case Tiebreak::AroCut:
return $this->calculateAverageRating($player, 1); return $this->calculateAverageRating($player, 1);
break; break;
case Tiebreak::Koya:
return $this->calculateKoya($player);
break;
default: default:
return null; return null;
} }