Removed some fields that are not interesting enough

This commit is contained in:
Jeroen De Meerleer 2019-05-28 15:30:55 +02:00
parent aeb9f76adb
commit 4f15eb0c9f
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
4 changed files with 95 additions and 254 deletions

View File

@ -8,6 +8,9 @@ use MyCLabs\Enum\Enum;
class Tiebreak extends Enum class Tiebreak extends Enum
{ {
const None = ""; const None = "";
const Keizer = "Keizer";
const Points = "Points";
const American = "American";
const Buchholz = "Buchholz"; const Buchholz = "Buchholz";
const BuchholzMed = "Buchholz Median"; const BuchholzMed = "Buchholz Median";
const BuchholzCut = "Buchholz Cut"; const BuchholzCut = "Buchholz Cut";
@ -16,7 +19,7 @@ class Tiebreak extends Enum
const Cumulative = "Cumulative"; const Cumulative = "Cumulative";
const Between = "Mutual Result"; const Between = "Mutual Result";
const Koya = "Koya"; const Koya = "Koya";
const Baumbach = "Baumbach"; const Baumbach = "Most wins"; // Ref: https://en.wikipedia.org/wiki/Tie-breaking_in_Swiss-system_tournaments#Most_wins_(Baumbach) Please tell me why?
const Performance = "Performance"; const Performance = "Performance";
const Aro = "Average Rating"; const Aro = "Average Rating";
const AroCut = "Average Rating Cut"; const AroCut = "Average Rating Cut";

View File

@ -18,42 +18,22 @@ abstract class Player
/** @var string */ /** @var string */
private $Name; private $Name;
/** @var int */ /** @var int[] */
private $Rank; private $Ids;
/** @var int */ /** @var int[] */
private $FideId; private $Elos;
/** @var int */
private $ExtraPts;
/** @var int */
private $KbsbElo;
/** @var DateTime */ /** @var DateTime */
private $dateofbirth; private $DateOfBirth;
/** @var int */ /** @var float[] */
private $KbsbID; private $Tiebreaks;
/** @var float */
private $Points;
/** @var int */
private $ClubNr;
/** @var float */
private $ScoreBucholtz;
/** @var float */
private $ScoreAmerican;
/** @var int */
private $FideElo;
/** @var string */ /** @var string */
private $Nation; private $Nation;
// TODO: Implement categories
/** @var string */ /** @var string */
private $Category; private $Category;
@ -63,15 +43,12 @@ abstract class Player
/** @var Gender */ /** @var Gender */
private $Gender; private $Gender;
/** @var int */
private $NumberOfTies;
/** @var bool */
private $Absent;
/** @var Pairing[] */ /** @var Pairing[] */
private $Pairings = []; private $Pairings = [];
/** @var bool|DateTime|int|string[] */
private $BinaryData;
/** /**
* @return string * @return string
*/ */
@ -91,200 +68,74 @@ abstract class Player
} }
/** /**
* @return int * @return int[]
*/ */
public function getRank(): int public function getIds(): array
{ {
return $this->Rank; return $this->Ids;
} }
/** /**
* @param int $Rank * @param int[] $Ids
* @return Player * @return Player
*/ */
public function setRank(int $Rank): Player public function setIds(array $Ids): Player
{ {
$this->Rank = $Rank; $this->Ids = $Ids;
return $this; return $this;
} }
/** /**
* @return int * @return int[]
*/ */
public function getFideId(): int public function getElos(): array
{ {
return $this->FideId; return $this->Elos;
} }
/** /**
* @param int $FideId * @param int[] $Elos
* @return Player * @return Player
*/ */
public function setFideId(int $FideId): Player public function setElos(array $Elos): Player
{ {
$this->FideId = $FideId; $this->Elos = $Elos;
return $this; return $this;
} }
/** /**
* @return int * @return \DateTime
*/ */
public function getExtraPts(): int public function getDateOfBirth(): \DateTime
{ {
return $this->ExtraPts; return $this->DateOfBirth;
} }
/** /**
* @param int $ExtraPts * @param \DateTime $DateOfBirth
* @return Player * @return Player
*/ */
public function setExtraPts(int $ExtraPts): Player public function setDateOfBirth(\DateTime $DateOfBirth): Player
{ {
$this->ExtraPts = $ExtraPts; $this->DateOfBirth = $DateOfBirth;
return $this; return $this;
} }
/** /**
* @return int * @return float[]
*/ */
public function getKbsbElo(): int public function getTiebreaks(): array
{ {
return $this->KbsbElo; return $this->Tiebreaks;
} }
/** /**
* @param int $KbsbElo * @param float[] $Tiebreaks
* @return Player * @return Player
*/ */
public function setKbsbElo(int $KbsbElo): Player public function setTiebreaks(array $Tiebreaks): Player
{ {
$this->KbsbElo = $KbsbElo; $this->Tiebreaks = $Tiebreaks;
return $this;
}
/**
* @return DateTime
*/
public function getDateofbirth(): DateTime
{
return $this->dateofbirth;
}
/**
* @param DateTime $dateofbirth
* @return Player
*/
public function setDateofbirth(DateTime $dateofbirth): Player
{
$this->dateofbirth = $dateofbirth;
return $this;
}
/**
* @return int
*/
public function getKbsbID(): int
{
return $this->KbsbID;
}
/**
* @param int $KbsbID
* @return Player
*/
public function setKbsbID(int $KbsbID): Player
{
$this->KbsbID = $KbsbID;
return $this;
}
/**
* @return float
*/
public function getPoints(): float
{
return $this->Points;
}
/**
* @param float $Points
* @return Player
*/
public function setPoints(float $Points): Player
{
$this->Points = $Points;
return $this;
}
/**
* @return int
*/
public function getClubNr(): int
{
return $this->ClubNr;
}
/**
* @param int $ClubNr
* @return Player
*/
public function setClubNr(int $ClubNr): Player
{
$this->ClubNr = $ClubNr;
return $this;
}
/**
* @return float
*/
public function getScoreBucholtz(): float
{
return $this->ScoreBucholtz;
}
/**
* @param float $ScoreBucholtz
* @return Player
*/
public function setScoreBucholtz(float $ScoreBucholtz): Player
{
$this->ScoreBucholtz = $ScoreBucholtz;
return $this;
}
/**
* @return float
*/
public function getScoreAmerican(): float
{
return $this->ScoreAmerican;
}
/**
* @param float $ScoreAmerican
* @return Player
*/
public function setScoreAmerican(float $ScoreAmerican): Player
{
$this->ScoreAmerican = $ScoreAmerican;
return $this;
}
/**
* @return int
*/
public function getFideElo(): int
{
return $this->FideElo;
}
/**
* @param int $FideElo
* @return Player
*/
public function setFideElo(int $FideElo): Player
{
$this->FideElo = $FideElo;
return $this; return $this;
} }
@ -364,42 +215,6 @@ abstract class Player
return $this; return $this;
} }
/**
* @return int
*/
public function getNumberOfTies(): int
{
return $this->NumberOfTies;
}
/**
* @param int $NumberOfTies
* @return Player
*/
public function setNumberOfTies(int $NumberOfTies): Player
{
$this->NumberOfTies = $NumberOfTies;
return $this;
}
/**
* @return bool
*/
public function isAbsent(): bool
{
return $this->Absent;
}
/**
* @param bool $Absent
* @return Player
*/
public function setAbsent(bool $Absent): Player
{
$this->Absent = $Absent;
return $this;
}
/** /**
* @return Pairing[] * @return Pairing[]
*/ */
@ -417,4 +232,24 @@ abstract class Player
$this->Pairings = $Pairings; $this->Pairings = $Pairings;
return $this; return $this;
} }
/**
* @param string $Key
* @return bool|DateTime|int|string
*/
public function getBinaryData(string $Key)
{
return $this->BinaryData[$Key];
}
/**
* @param string $Key
* @param bool|int|DateTime|string $Value
* @return Player
*/
public function setBinaryData(string $Key, $Value): Player
{
$this->BinaryData[$Key] = $Value;
return $this;
}
} }

View File

@ -296,24 +296,25 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
for ($i = 0; $i < $this->getBinaryData("NewPlayer"); $i++) { for ($i = 0; $i < $this->getBinaryData("NewPlayer"); $i++) {
$player = new Player(); $player = new Player();
// Rank (Unused value)
$length = 4; $length = 4;
$player->SetRank($this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData("Rank", $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 4; $length = 4;
$this->setBinaryData("Players($i)_NamePos", $this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData("NamePos", $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 4; $length = 4;
$player->SetFideId($this->readData('Int', substr($swscontents, $offset, $length))); $ids['fide'] = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length; $offset += $length;
$length = 4; $length = 4;
$player->SetExtraPts($this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData("ExtraPts", $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 4; $length = 4;
$player->SetKbsbElo($this->readData('Int', substr($swscontents, $offset, $length))); $elos['kbsb'] = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length; $offset += $length;
$length = 4; $length = 4;
@ -321,35 +322,35 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
$offset += $length; $offset += $length;
$length = 4; $length = 4;
$player->setKbsbID($this->readData('Int', substr($swscontents, $offset, $length))); $ids['kbsb'] = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length; $offset += $length;
$length = 4; $length = 4;
$player->setPoints($this->readData('Int', substr($swscontents, $offset, $length)) / 2); $player->setBinaryData("Points", $this->readData('Int', substr($swscontents, $offset, $length)) / 2);
$offset += $length; $offset += $length;
$length = 4; $length = 4;
$player->setClubNr($this->readData('Int', substr($swscontents, $offset, $length))); $ids['club'] = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length; $offset += $length;
$length = 4; $length = 4;
$player->setScoreBucholtz($this->readData('Int', substr($swscontents, $offset, $length)) / 2); $player->setBinaryData("ScoreBuchholz", $this->readData('Int', substr($swscontents, $offset, $length)) / 2);
$offset += $length; $offset += $length;
$length = 4; $length = 4;
$player->setScoreAmerican($this->readData('Int', substr($swscontents, $offset, $length)) / 2); $player->setBinaryData("ScoreAmerican", $this->readData('Int', substr($swscontents, $offset, $length)) / 2);
$offset += $length; $offset += $length;
$length = 4; $length = 4;
$this->setBinaryData("Players($i)_HelpValue", $this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData("HelpValue", $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 4; $length = 4;
$player->setFideElo($this->readData('Int', substr($swscontents, $offset, $length))); $elos['fide'] = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$this->setBinaryData("Players($i)_NameLength", $this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData("NameLength", $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 3; $length = 3;
@ -422,41 +423,43 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$player->setNumberOfTies($this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData('NumberOfTies', $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$player->setAbsent($this->readData('Bool', substr($swscontents, $offset, $length))); $player->setBinaryData('Absent', $this->readData('Bool', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$this->setBinaryData("Players($i)_ColorDiff", $this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData("ColorDiff", $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$this->setBinaryData("Players($i)_ColorPref", $this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData("ColorPref", $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$this->setBinaryData("Players($i)_Paired", $this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData("Paired", $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$this->setBinaryData("Players($i)_Float", $this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData("Float", $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$this->setBinaryData("Players($i)_FloatPrev", $this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData("FloatPrev", $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$this->setBinaryData("Players($i)_FloatBefore", $this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData("FloatBefore", $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$this->setBinaryData("Players($i)_TieMatch", $this->readData('Int', substr($swscontents, $offset, $length))); $player->setBinaryData("TieMatch", $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$player->setElos($elos);
$player->setIds($ids);
$this->getTournament()->addPlayer($player); $this->getTournament()->addPlayer($player);
} }
// PlayerNames // PlayerNames
@ -465,9 +468,9 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
$offset += $length; $offset += $length;
for ($i = 0; $i < $this->getBinaryData("NewPlayer"); $i++) { for ($i = 0; $i < $this->getBinaryData("NewPlayer"); $i++) {
$namelength = $this->getBinaryData("Players($i)_NameLength");
$nameoffset = $this->getBinaryData("Players($i)_NamePos");
$player = $this->getTournament()->getPlayerById($i); $player = $this->getTournament()->getPlayerById($i);
$namelength = $player->getBinaryData("NameLength");
$nameoffset = $player->getBinaryData("NamePos");
$player->setName($this->readData("String", substr($this->getBinaryData("PlayerNames"), $nameoffset, $namelength))); $player->setName($this->readData("String", substr($this->getBinaryData("PlayerNames"), $nameoffset, $namelength)));
$this->getTournament()->updatePlayer($i, $player); $this->getTournament()->updatePlayer($i, $player);

View File

@ -46,21 +46,21 @@ echo "Place: " . $sws->getTournament()->getOrganiserPlace() . PHP_EOL;
echo "Unrated-Elo: " . $sws->getTournament()->getNonRatedElo() . PHP_EOL; echo "Unrated-Elo: " . $sws->getTournament()->getNonRatedElo() . PHP_EOL;
echo "Federation: " . $sws->getTournament()->getFederation() . PHP_EOL; echo "Federation: " . $sws->getTournament()->getFederation() . PHP_EOL;
echo "Organiser: " . $sws->getTournament()->getOrganiserClubNo() . PHP_EOL; echo "Organiser: " . $sws->getTournament()->getOrganiserClubNo() . PHP_EOL;
echo "Fide Elo P1: " . $sws->getTournament()->getPlayerById(0)->getFideElo() . PHP_EOL; echo "Fide Elo P1: " . $sws->getTournament()->getPlayerById(0)->getElos()['fide'] . PHP_EOL;
echo "Fide Elo P2: " . $sws->getTournament()->getPlayerById(1)->getFideElo() . PHP_EOL; echo "Fide Elo P2: " . $sws->getTournament()->getPlayerById(1)->getElos()['fide'] . PHP_EOL;
echo "Fide Elo P3: " . $sws->getTournament()->getPlayerById(2)->getFideElo() . PHP_EOL; echo "Fide Elo P3: " . $sws->getTournament()->getPlayerById(2)->getElos()['fide'] . PHP_EOL;
echo "KBSB Elo P1: " . $sws->getTournament()->getPlayerById(0)->getKbsbElo() . PHP_EOL; echo "KBSB Elo P1: " . $sws->getTournament()->getPlayerById(0)->getElos()['kbsb'] . PHP_EOL;
echo "KBSB Elo P2: " . $sws->getTournament()->getPlayerById(1)->getKbsbElo() . PHP_EOL; echo "KBSB Elo P2: " . $sws->getTournament()->getPlayerById(1)->getElos()['kbsb'] . PHP_EOL;
echo "KBSB Elo P3: " . $sws->getTournament()->getPlayerById(2)->getKbsbElo() . PHP_EOL; echo "KBSB Elo P3: " . $sws->getTournament()->getPlayerById(2)->getElos()['kbsb'] . PHP_EOL;
echo "Name P1: " . $sws->getTournament()->getPlayerById(0)->getName() . PHP_EOL; echo "Name P1: " . $sws->getTournament()->getPlayerById(0)->getName() . PHP_EOL;
echo "Name P2: " . $sws->getTournament()->getPlayerById(1)->getName() . PHP_EOL; echo "Name P2: " . $sws->getTournament()->getPlayerById(1)->getName() . PHP_EOL;
echo "Name P3: " . $sws->getTournament()->getPlayerById(2)->getName() . PHP_EOL; echo "Name P3: " . $sws->getTournament()->getPlayerById(2)->getName() . PHP_EOL;
echo "Gender P1: " . $sws->getTournament()->getPlayerById(0)->getGender()->getKey() . PHP_EOL; echo "Gender P1: " . $sws->getTournament()->getPlayerById(0)->getGender()->getKey() . PHP_EOL;
echo "Gender P2: " . $sws->getTournament()->getPlayerById(1)->getGender()->getKey() . PHP_EOL; echo "Gender P2: " . $sws->getTournament()->getPlayerById(1)->getGender()->getKey() . PHP_EOL;
echo "Gender P3: " . $sws->getTournament()->getPlayerById(2)->getGender()->getKey() . PHP_EOL; echo "Gender P3: " . $sws->getTournament()->getPlayerById(2)->getGender()->getKey() . PHP_EOL;
echo "Absent P1: " . $sws->getTournament()->getPlayerById(0)->isAbsent() . PHP_EOL; echo "Absent P1: " . $sws->getTournament()->getPlayerById(0)->getBinaryData("absent") . PHP_EOL;
echo "Absent P2: " . $sws->getTournament()->getPlayerById(1)->isAbsent() . PHP_EOL; echo "Absent P2: " . $sws->getTournament()->getPlayerById(1)->getBinaryData("absent") . PHP_EOL;
echo "Absent P3: " . $sws->getTournament()->getPlayerById(2)->isAbsent() . PHP_EOL; echo "Absent P3: " . $sws->getTournament()->getPlayerById(2)->getBinaryData("absent") . PHP_EOL;
echo "Date Round 1: " . $sws->getTournament()->getRoundByNo(0)->getDate()->format('d/m/Y') . PHP_EOL; echo "Date Round 1: " . $sws->getTournament()->getRoundByNo(0)->getDate()->format('d/m/Y') . PHP_EOL;
echo "Date Round 2: " . $sws->getTournament()->getRoundByNo(1)->getDate()->format('d/m/Y') . PHP_EOL; echo "Date Round 2: " . $sws->getTournament()->getRoundByNo(1)->getDate()->format('d/m/Y') . PHP_EOL;
echo "Date Round 3: " . $sws->getTournament()->getRoundByNo(2)->getDate()->format('d/m/Y') . PHP_EOL; echo "Date Round 3: " . $sws->getTournament()->getRoundByNo(2)->getDate()->format('d/m/Y') . PHP_EOL;