diff --git a/src/Player.php b/src/Player.php index a0995b2..73998f9 100644 --- a/src/Player.php +++ b/src/Player.php @@ -137,7 +137,7 @@ class Player extends PlayerModel $opponents = 0; foreach ($this->getPairings() as $pairing) { if (array_search($pairing->getResult(), Constants::Notplayed)) { - $opponentElo = $pairing->getOpponent()->getElo('home'); + $opponentElo = $pairing->getOpponent()->getElo('Nation'); $opponentElo = $opponentElo != 0 ? $opponentElo : $this->getUnratedElo(); if (array_search(self::Won, $pairing->getResult())) { $total += $opponentElo + 400; diff --git a/src/Readers/Pairtwo6.php b/src/Readers/Pairtwo6.php index 208e017..2ad8cc5 100644 --- a/src/Readers/Pairtwo6.php +++ b/src/Readers/Pairtwo6.php @@ -306,7 +306,7 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface $offset += $length; $length = 4; - $player->setId('world', $this->readData('Int', substr($swscontents, $offset, $length) . "")); + $player->setId('Fide', $this->readData('Int', substr($swscontents, $offset, $length) . "")); $offset += $length; $length = 4; @@ -314,7 +314,7 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface $offset += $length; $length = 4; - $player->setElo('home', $this->readData('Int', substr($swscontents, $offset, $length))); + $player->setElo('Nation', $this->readData('Int', substr($swscontents, $offset, $length))); $offset += $length; $length = 4; @@ -322,7 +322,7 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface $offset += $length; $length = 4; - $player->setId('home', $this->readData('Int', substr($swscontents, $offset, $length))); + $player->setId('Nation', $this->readData('Int', substr($swscontents, $offset, $length))); $offset += $length; $length = 4; @@ -330,7 +330,7 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface $offset += $length; $length = 4; - $player->setId('club', $this->readData('Int', substr($swscontents, $offset, $length))); + $player->setId('Club', $this->readData('Int', substr($swscontents, $offset, $length))); $offset += $length; $length = 4; @@ -346,7 +346,7 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface $offset += $length; $length = 4; - $player->setElo('world', $this->readData('Int', substr($swscontents, $offset, $length))); + $player->setElo('Fide', $this->readData('Int', substr($swscontents, $offset, $length))); $offset += $length; $length = 1; diff --git a/src/Tiebreaks.php b/src/Tiebreaks.php index 234e27c..d051c82 100644 --- a/src/Tiebreaks.php +++ b/src/Tiebreaks.php @@ -136,7 +136,7 @@ abstract class Tiebreaks extends Tournament $allratings = []; foreach ($pairings as $pairing) { if (array_search($pairing->getResult(), Constants::NotPlayed) === false) { - $toadd = $pairing->getOpponent()->getElos()['home']; + $toadd = $pairing->getOpponent()->getElo('Nation'); if ($toadd != 0) { $allratings[] = $toadd; } @@ -159,7 +159,7 @@ abstract class Tiebreaks extends Tournament $allratings = []; foreach ($pairings as $pairing) { if (array_search($pairing->getResult(), Constants::NotPlayed) === false) { - $toadd = $pairing->getOpponent()->getPerformance(); + $toadd = $pairing->getOpponent()->getPerformance('Nation'); if ($toadd != 0) { $allratings[] = $toadd; } @@ -200,10 +200,17 @@ abstract class Tiebreaks extends Tournament $intpairings = $player->getPairings(); usort($intpairings, function ($a, $b) { - if ($b->getOpponent()->getElo('home') == $a->getOpponent()->getElo('home')) { + if (is_null($a->getOpponent())) { + return -1; + } + if (is_null($b->getOpponent())) { + return 1; + } + + if ($b->getOpponent()->getElo('Nation') == $a->getOpponent()->getElo('Nation')) { return 0; } - return ($b->getOpponent()->getElo('home') > $a->getOpponent()->getElo('home')) ? 1 : -1; + return ($b->getOpponent()->getElo('Nation') > $a->getOpponent()->getElo('Nation')) ? 1 : -1; }); array_splice($intpairings, $cutlowest); @@ -224,10 +231,12 @@ abstract class Tiebreaks extends Tournament { $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; + if ($pairing->getOpponent()) { + 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;