mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-12-22 04:11:22 +01:00
Better names for ids and elos
Also fixed some bugs
This commit is contained in:
parent
a1c669780e
commit
c9a19bbcb2
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user