mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-10-31 20:56:08 +01:00
Working ARO tiebreak
This commit is contained in:
parent
fbdd9a097f
commit
a0e36ec0be
@ -9,10 +9,10 @@ use JeroenED\Libpairtwo\Enums\Result;
|
|||||||
|
|
||||||
abstract class Tiebreaks extends Tournament
|
abstract class Tiebreaks extends Tournament
|
||||||
{
|
{
|
||||||
|
|
||||||
private const Won = [ Result::won, Result::wonforfait, Result::wonbye, Result::wonadjourned ];
|
private const Won = [ Result::won, Result::wonforfait, Result::wonbye, Result::wonadjourned ];
|
||||||
private const Draw = [ Result::draw, Result::drawadjourned];
|
private const Draw = [ Result::draw, Result::drawadjourned];
|
||||||
private const Lost = [ Result::absent, Result::bye, Result::lost, Result::adjourned ];
|
private const Lost = [ Result::absent, Result::bye, Result::lost, Result::adjourned ];
|
||||||
|
private const NotPlayed = [ Result::bye, Result::wonbye, Result::absent ];
|
||||||
private const Black = [ Color::black ];
|
private const Black = [ Color::black ];
|
||||||
private const White = [ Color::white ];
|
private const White = [ Color::white ];
|
||||||
|
|
||||||
@ -137,12 +137,24 @@ abstract class Tiebreaks extends Tournament
|
|||||||
return $points;
|
return $points;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function calculateAverageRating(Player $player) {
|
/**
|
||||||
|
* @param Player $player
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
protected function calculateAverageRating(Player $player)
|
||||||
|
{
|
||||||
$pairings = $player->getPairings();
|
$pairings = $player->getPairings();
|
||||||
$totalrating = 0;
|
$totalrating = 0;
|
||||||
$opponents;
|
$totalopponents = 0;
|
||||||
foreach ($pairings as $pairing) {
|
foreach ($pairings as $pairing) {
|
||||||
if ($pairing->getOpponent()->getElos['national'])
|
if (array_search($pairing->getResult(), self::NotPlayed) === false) {
|
||||||
|
$toadd = $pairing->getOpponent()->getElos()['home'];
|
||||||
|
if ($toadd != 0) {
|
||||||
|
$totalrating += $toadd;
|
||||||
|
$totalopponents++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return round($totalrating / $totalopponents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,6 +290,9 @@ class Tournament extends Tiebreaks
|
|||||||
case Tiebreak::Between:
|
case Tiebreak::Between:
|
||||||
return $this->calculateMutualResult($player, $this->getPlayers(), $tbkey);
|
return $this->calculateMutualResult($player, $this->getPlayers(), $tbkey);
|
||||||
break;
|
break;
|
||||||
|
case Tiebreak::Aro:
|
||||||
|
return $this->calculateAverageRating($player);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user