diff --git a/src/Player.php b/src/Player.php index 01a7034..2828e99 100644 --- a/src/Player.php +++ b/src/Player.php @@ -131,24 +131,24 @@ class Player extends PlayerModel /** * @return int */ - public function getPerformance(string $type) : int + public function getPerformance(string $type, int $unratedElo) : float { $total = 0; $opponents = 0; foreach ($this->getPairings() as $pairing) { - if (array_search($pairing->getResult(), Constants::Notplayed)) { + if (array_search($pairing->getResult(), Constants::NotPlayed) === false) { $opponentElo = $pairing->getOpponent()->getElo($type); - $opponentElo = $opponentElo != 0 ? $opponentElo : $this->getUnratedElo(); - if (array_search(self::Won, $pairing->getResult())) { + $opponentElo = $opponentElo != 0 ? $opponentElo : $unratedElo; + if (array_search($pairing->getResult(), Constants::Won) !== false) { $total += $opponentElo + 400; - } elseif (array_search(self::Lost, $pairing->getResult())) { + } elseif (array_search($pairing->getResult(), Constants::Lost) !== false) { $total += $opponentElo - 400; - } elseif (array_search(self::Draw, $pairing->getResult())) { + } elseif (array_search($pairing->getResult(), Constants::Draw) !== false) { $total += $opponentElo; } $opponents++; } - return round($total / $opponents); } + return round($total / $opponents); } } diff --git a/src/Readers/Pairtwo6.php b/src/Readers/Pairtwo6.php index 6189cba..1a7ea16 100644 --- a/src/Readers/Pairtwo6.php +++ b/src/Readers/Pairtwo6.php @@ -79,7 +79,7 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface $this->setTournament(new Tournament()); $this->getTournament()->setPriorityElo('Nation'); - $this->getTournament()->setPriorityId('Nation'); + $this->getTournament()->setPriorityId('Nation'); // UserCountry $length = 4; $this->setBinaryData("UserCountry", $this->readData('Int', substr($swscontents, $offset, $length))); diff --git a/src/Tiebreaks.php b/src/Tiebreaks.php index d862e1a..15e8a7c 100644 --- a/src/Tiebreaks.php +++ b/src/Tiebreaks.php @@ -157,7 +157,7 @@ abstract class Tiebreaks extends Tournament $allratings = []; foreach ($pairings as $pairing) { if (array_search($pairing->getResult(), Constants::NotPlayed) === false) { - $toadd = $pairing->getOpponent()->getPerformance($type); + $toadd = $pairing->getOpponent()->getPerformance($type, $this->getNonRatedElo()); if ($toadd != 0) { $allratings[] = $toadd; } @@ -215,9 +215,10 @@ abstract class Tiebreaks extends Tournament array_slice($intpairings, 0 - $cuthighest); foreach ($intpairings as $intkey => $intpairing) { - if(!is_null($intpairing->getOpponent())){ - $tiebreak += $intpairing->getOpponent()->getPoints(); - }} + if (!is_null($intpairing->getOpponent())) { + $tiebreak += $intpairing->getOpponent()->getPoints(); + } + } return $tiebreak; } diff --git a/src/Tournament.php b/src/Tournament.php index f66beca..1a46af8 100644 --- a/src/Tournament.php +++ b/src/Tournament.php @@ -321,7 +321,7 @@ class Tournament extends Tiebreaks return $this->calculateAveragePerformance($player, $this->getPriorityElo()); break; case Tiebreak::Performance: - return $player->getPerformance($this->getPriorityElo()); + return $player->getPerformance($this->getPriorityElo(), $this->getNonRatedElo()); break; default: return null;