mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-21 22:17:41 +01:00
Merge branch 'bugfix/performance-priority' into bugfix/performance-tiebreak
This commit is contained in:
commit
c82e380b73
@ -131,13 +131,13 @@ class Player extends PlayerModel
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPerformance(): int
|
||||
public function getPerformance(string $type) : int
|
||||
{
|
||||
$total = 0;
|
||||
$opponents = 0;
|
||||
foreach ($this->getPairings() as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::Notplayed)) {
|
||||
$opponentElo = $pairing->getOpponent()->getElo('Nation');
|
||||
$opponentElo = $pairing->getOpponent()->getElo($type);
|
||||
$opponentElo = $opponentElo != 0 ? $opponentElo : $this->getUnratedElo();
|
||||
if (array_search(self::Won, $pairing->getResult())) {
|
||||
$total += $opponentElo + 400;
|
||||
|
@ -128,15 +128,13 @@ abstract class Tiebreaks extends Tournament
|
||||
* @param int $cut
|
||||
* @return float
|
||||
*/
|
||||
protected function calculateAverageRating(Player $player, int $cut = 0): ?float
|
||||
protected function calculateAverageRating(Player $player, string $type, int $cut = 0): ?float
|
||||
{
|
||||
$pairings = $player->getPairings();
|
||||
$totalrating = 0;
|
||||
$totalopponents = 0;
|
||||
$allratings = [];
|
||||
foreach ($pairings as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) === false) {
|
||||
$toadd = $pairing->getOpponent()->getElo('Nation');
|
||||
$toadd = $pairing->getOpponent()->getElo($type);
|
||||
if ($toadd != 0) {
|
||||
$allratings[] = $toadd;
|
||||
}
|
||||
@ -153,13 +151,13 @@ abstract class Tiebreaks extends Tournament
|
||||
* @param int $cut
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateAveragePerformance(Player $player, int $cut = 0): ?float
|
||||
protected function calculateAveragePerformance(Player $player, string $type, int $cut = 0): ?float
|
||||
{
|
||||
$pairings = $player->getPairings();
|
||||
$allratings = [];
|
||||
foreach ($pairings as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) === false) {
|
||||
$toadd = $pairing->getOpponent()->getPerformance('Nation');
|
||||
$toadd = $pairing->getOpponent()->getPerformance($type);
|
||||
if ($toadd != 0) {
|
||||
$allratings[] = $toadd;
|
||||
}
|
||||
|
@ -291,10 +291,10 @@ class Tournament extends Tiebreaks
|
||||
return $this->calculateMutualResult($player, $this->getPlayers(), $tbkey);
|
||||
break;
|
||||
case Tiebreak::Aro:
|
||||
return $this->calculateAverageRating($player);
|
||||
return $this->calculateAverageRating($player, $this->getPriorityElo());
|
||||
break;
|
||||
case Tiebreak::AroCut:
|
||||
return $this->calculateAverageRating($player, 1);
|
||||
return $this->calculateAverageRating($player, $this->getPriorityElo(), 1);
|
||||
break;
|
||||
case Tiebreak::Koya:
|
||||
return $this->calculateKoya($player);
|
||||
@ -318,7 +318,7 @@ class Tournament extends Tiebreaks
|
||||
return $this->calculateCumulative($player);
|
||||
break;
|
||||
case Tiebreak::AveragePerformance:
|
||||
return $this->calculateAveragePerformance($player);
|
||||
return $this->calculateAveragePerformance($player, $this->getPriorityElo());
|
||||
break;
|
||||
case Tiebreak::Performance:
|
||||
return $player->getPerformance($this->getPriorityElo());
|
||||
|
Loading…
Reference in New Issue
Block a user