mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-12-22 04:11:22 +01:00
Removed some fields that are not interesting enough
This commit is contained in:
parent
aeb9f76adb
commit
4f15eb0c9f
@ -8,6 +8,9 @@ use MyCLabs\Enum\Enum;
|
||||
class Tiebreak extends Enum
|
||||
{
|
||||
const None = "";
|
||||
const Keizer = "Keizer";
|
||||
const Points = "Points";
|
||||
const American = "American";
|
||||
const Buchholz = "Buchholz";
|
||||
const BuchholzMed = "Buchholz Median";
|
||||
const BuchholzCut = "Buchholz Cut";
|
||||
@ -16,7 +19,7 @@ class Tiebreak extends Enum
|
||||
const Cumulative = "Cumulative";
|
||||
const Between = "Mutual Result";
|
||||
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 Aro = "Average Rating";
|
||||
const AroCut = "Average Rating Cut";
|
||||
|
@ -18,42 +18,22 @@ abstract class Player
|
||||
/** @var string */
|
||||
private $Name;
|
||||
|
||||
/** @var int */
|
||||
private $Rank;
|
||||
/** @var int[] */
|
||||
private $Ids;
|
||||
|
||||
/** @var int */
|
||||
private $FideId;
|
||||
|
||||
/** @var int */
|
||||
private $ExtraPts;
|
||||
|
||||
/** @var int */
|
||||
private $KbsbElo;
|
||||
/** @var int[] */
|
||||
private $Elos;
|
||||
|
||||
/** @var DateTime */
|
||||
private $dateofbirth;
|
||||
private $DateOfBirth;
|
||||
|
||||
/** @var int */
|
||||
private $KbsbID;
|
||||
|
||||
/** @var float */
|
||||
private $Points;
|
||||
|
||||
/** @var int */
|
||||
private $ClubNr;
|
||||
|
||||
/** @var float */
|
||||
private $ScoreBucholtz;
|
||||
|
||||
/** @var float */
|
||||
private $ScoreAmerican;
|
||||
|
||||
/** @var int */
|
||||
private $FideElo;
|
||||
/** @var float[] */
|
||||
private $Tiebreaks;
|
||||
|
||||
/** @var string */
|
||||
private $Nation;
|
||||
|
||||
// TODO: Implement categories
|
||||
/** @var string */
|
||||
private $Category;
|
||||
|
||||
@ -63,15 +43,12 @@ abstract class Player
|
||||
/** @var Gender */
|
||||
private $Gender;
|
||||
|
||||
/** @var int */
|
||||
private $NumberOfTies;
|
||||
|
||||
/** @var bool */
|
||||
private $Absent;
|
||||
|
||||
/** @var Pairing[] */
|
||||
private $Pairings = [];
|
||||
|
||||
/** @var bool|DateTime|int|string[] */
|
||||
private $BinaryData;
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
public function setRank(int $Rank): Player
|
||||
public function setIds(array $Ids): Player
|
||||
{
|
||||
$this->Rank = $Rank;
|
||||
$this->Ids = $Ids;
|
||||
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
|
||||
*/
|
||||
public function setFideId(int $FideId): Player
|
||||
public function setElos(array $Elos): Player
|
||||
{
|
||||
$this->FideId = $FideId;
|
||||
$this->Elos = $Elos;
|
||||
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
|
||||
*/
|
||||
public function setExtraPts(int $ExtraPts): Player
|
||||
public function setDateOfBirth(\DateTime $DateOfBirth): Player
|
||||
{
|
||||
$this->ExtraPts = $ExtraPts;
|
||||
$this->DateOfBirth = $DateOfBirth;
|
||||
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
|
||||
*/
|
||||
public function setKbsbElo(int $KbsbElo): Player
|
||||
public function setTiebreaks(array $Tiebreaks): Player
|
||||
{
|
||||
$this->KbsbElo = $KbsbElo;
|
||||
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;
|
||||
$this->Tiebreaks = $Tiebreaks;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -364,42 +215,6 @@ abstract class Player
|
||||
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[]
|
||||
*/
|
||||
@ -417,4 +232,24 @@ abstract class Player
|
||||
$this->Pairings = $Pairings;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -296,24 +296,25 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
|
||||
for ($i = 0; $i < $this->getBinaryData("NewPlayer"); $i++) {
|
||||
$player = new Player();
|
||||
|
||||
// Rank (Unused value)
|
||||
$length = 4;
|
||||
$player->SetRank($this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$player->setBinaryData("Rank", $this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$offset += $length;
|
||||
|
||||
$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;
|
||||
|
||||
$length = 4;
|
||||
$player->SetFideId($this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$ids['fide'] = $this->readData('Int', substr($swscontents, $offset, $length));
|
||||
$offset += $length;
|
||||
|
||||
$length = 4;
|
||||
$player->SetExtraPts($this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$player->setBinaryData("ExtraPts", $this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$offset += $length;
|
||||
|
||||
$length = 4;
|
||||
$player->SetKbsbElo($this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$elos['kbsb'] = $this->readData('Int', substr($swscontents, $offset, $length));
|
||||
$offset += $length;
|
||||
|
||||
$length = 4;
|
||||
@ -321,35 +322,35 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
|
||||
$offset += $length;
|
||||
|
||||
$length = 4;
|
||||
$player->setKbsbID($this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$ids['kbsb'] = $this->readData('Int', substr($swscontents, $offset, $length));
|
||||
$offset += $length;
|
||||
|
||||
$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;
|
||||
|
||||
$length = 4;
|
||||
$player->setClubNr($this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$ids['club'] = $this->readData('Int', substr($swscontents, $offset, $length));
|
||||
$offset += $length;
|
||||
|
||||
$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;
|
||||
|
||||
$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;
|
||||
|
||||
$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;
|
||||
|
||||
$length = 4;
|
||||
$player->setFideElo($this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$elos['fide'] = $this->readData('Int', substr($swscontents, $offset, $length));
|
||||
$offset += $length;
|
||||
|
||||
$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;
|
||||
|
||||
$length = 3;
|
||||
@ -422,41 +423,43 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
|
||||
$offset += $length;
|
||||
|
||||
$length = 1;
|
||||
$player->setNumberOfTies($this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$player->setBinaryData('NumberOfTies', $this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$offset += $length;
|
||||
|
||||
$length = 1;
|
||||
$player->setAbsent($this->readData('Bool', substr($swscontents, $offset, $length)));
|
||||
$player->setBinaryData('Absent', $this->readData('Bool', substr($swscontents, $offset, $length)));
|
||||
$offset += $length;
|
||||
|
||||
$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;
|
||||
|
||||
$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;
|
||||
|
||||
$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;
|
||||
|
||||
$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;
|
||||
|
||||
$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;
|
||||
|
||||
$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;
|
||||
|
||||
$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;
|
||||
|
||||
$player->setElos($elos);
|
||||
$player->setIds($ids);
|
||||
$this->getTournament()->addPlayer($player);
|
||||
}
|
||||
// PlayerNames
|
||||
@ -465,9 +468,9 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
|
||||
$offset += $length;
|
||||
|
||||
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);
|
||||
$namelength = $player->getBinaryData("NameLength");
|
||||
$nameoffset = $player->getBinaryData("NamePos");
|
||||
$player->setName($this->readData("String", substr($this->getBinaryData("PlayerNames"), $nameoffset, $namelength)));
|
||||
|
||||
$this->getTournament()->updatePlayer($i, $player);
|
||||
|
@ -46,21 +46,21 @@ echo "Place: " . $sws->getTournament()->getOrganiserPlace() . PHP_EOL;
|
||||
echo "Unrated-Elo: " . $sws->getTournament()->getNonRatedElo() . PHP_EOL;
|
||||
echo "Federation: " . $sws->getTournament()->getFederation() . PHP_EOL;
|
||||
echo "Organiser: " . $sws->getTournament()->getOrganiserClubNo() . PHP_EOL;
|
||||
echo "Fide Elo P1: " . $sws->getTournament()->getPlayerById(0)->getFideElo() . PHP_EOL;
|
||||
echo "Fide Elo P2: " . $sws->getTournament()->getPlayerById(1)->getFideElo() . PHP_EOL;
|
||||
echo "Fide Elo P3: " . $sws->getTournament()->getPlayerById(2)->getFideElo() . PHP_EOL;
|
||||
echo "KBSB Elo P1: " . $sws->getTournament()->getPlayerById(0)->getKbsbElo() . PHP_EOL;
|
||||
echo "KBSB Elo P2: " . $sws->getTournament()->getPlayerById(1)->getKbsbElo() . PHP_EOL;
|
||||
echo "KBSB Elo P3: " . $sws->getTournament()->getPlayerById(2)->getKbsbElo() . PHP_EOL;
|
||||
echo "Fide Elo P1: " . $sws->getTournament()->getPlayerById(0)->getElos()['fide'] . PHP_EOL;
|
||||
echo "Fide Elo P2: " . $sws->getTournament()->getPlayerById(1)->getElos()['fide'] . PHP_EOL;
|
||||
echo "Fide Elo P3: " . $sws->getTournament()->getPlayerById(2)->getElos()['fide'] . PHP_EOL;
|
||||
echo "KBSB Elo P1: " . $sws->getTournament()->getPlayerById(0)->getElos()['kbsb'] . PHP_EOL;
|
||||
echo "KBSB Elo P2: " . $sws->getTournament()->getPlayerById(1)->getElos()['kbsb'] . 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 P2: " . $sws->getTournament()->getPlayerById(1)->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 P2: " . $sws->getTournament()->getPlayerById(1)->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 P2: " . $sws->getTournament()->getPlayerById(1)->isAbsent() . PHP_EOL;
|
||||
echo "Absent P3: " . $sws->getTournament()->getPlayerById(2)->isAbsent() . PHP_EOL;
|
||||
echo "Absent P1: " . $sws->getTournament()->getPlayerById(0)->getBinaryData("absent") . PHP_EOL;
|
||||
echo "Absent P2: " . $sws->getTournament()->getPlayerById(1)->getBinaryData("absent") . 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 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;
|
||||
|
Loading…
Reference in New Issue
Block a user