Removed getter and setter methods

This change removes the separate getter and setter methods and is causing a lot of errors.
To fix errors you'll now need to use the actual field name.

Example:
OLD:
$reader->getTournament()->getRounds()[0]->getGames()[0]->getBlack()->getPlayer()->getName();

NEW:
$reader->Tournament->Rounds[0]->Games[0]->Black->Player->Name;
This commit is contained in:
Jeroen De Meerleer 2019-11-15 17:16:38 +01:00
parent 1474ad6629
commit eae66f92f5
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
9 changed files with 517 additions and 1655 deletions

View File

@ -29,30 +29,37 @@ use DateTime;
class Game
{
/** @var Pairing | null */
private $White;
public $White;
/** @var Pairing | null */
private $Black;
public $Black;
/** @var GameResult | null */
private $Result;
private $CalculatedResult;
/** @var int */
private $Board;
public $Board;
public function __get(string $Key)
{
if ($Key == 'Result') {
return $this->calculateResult();
}
}
/**
* Returns the result for the game
*
* @return Gameresult
*/
public function getResult(): Gameresult
private function calculateResult(): Gameresult
{
if (!is_null($this->Result)) {
return $this->Result;
if (!is_null($this->CalculatedResult)) {
return $this->CalculatedResult;
}
$whiteResult = $this->getWhite()->getResult();
$blackResult = $this->getBlack()->getResult();
$whiteResult = $this->White->Result;
$blackResult = $this->Black->Result;
$whitesplit = explode(" ", $whiteResult);
$blacksplit = explode(" ", $blackResult);
@ -71,84 +78,8 @@ class Game
$blacksplit[0] = '';
}
$result = new Gameresult($whitesplit[0] . '-' . $blacksplit[0] . $special);
$this->setResult($result);
$this->CalculatedResult = $result;
return $result;
}
/**
* Returns the pairing for white player
*
* @return Pairing | null
*/
public function getWhite(): ?Pairing
{
return $this->White;
}
/**
* Sets pairing for white player
*
* @param Pairing | null $White
* @return Game
*/
public function setWhite(?Pairing $White): Game
{
$this->White = $White;
return $this;
}
/**
* Returns the pairing for black player
*
* @return Pairing | null
*/
public function getBlack(): ?Pairing
{
return $this->Black;
}
/**
* Sets pairing for black player
*
* @param Pairing | null $Black
* @return Game
*/
public function setBlack(?Pairing $Black): Game
{
$this->Black = $Black;
return $this;
}
/**
* Sets result for game
*
* @param Gameresult | null $Result
* @return Game
*/
public function setResult(?Gameresult $Result): Game
{
$this->Result = $Result;
return $this;
}
/**
* Sets the board no of the game
*
* @return int
*/
public function getBoard(): int
{
return $this->Board;
}
/**
* Returns the board no of the game
*
* @param int $Board
*/
public function setBoard(int $Board): void
{
$this->Board = $Board;
}
}

View File

@ -33,11 +33,4 @@ interface ReaderInterface
* @return ReaderInterface
*/
public function read(string $filename): ReaderInterface;
/**
* Gets the tournament out of $filename
*
* @return Tournament
*/
public function getTournament(): Tournament;
}

View File

@ -28,150 +28,20 @@ use JeroenED\Libpairtwo\Enums\Result;
class Pairing
{
/** @var Player | null */
private $Player;
public $Player;
/** @var Player | null */
private $Opponent;
public $Opponent;
/** @var Color */
private $Color;
public $Color;
/** @var Result */
private $Result;
public $Result;
/** @var int */
private $Round;
public $Round;
/** @var int */
private $Board;
/**
* Returns the player of the pairing
*
* @return Player | null
*/
public function getPlayer(): ?Player
{
return $this->Player;
}
/**
* Sets the player of the pairing
*
* @param Player | null $Player
* @return Pairing
*/
public function setPlayer(?Player $Player): Pairing
{
$this->Player = $Player;
return $this;
}
/**
* Returns the opponent of the pairing
*
* @return Player | null
*/
public function getOpponent(): ?Player
{
return $this->Opponent;
}
/**
* Sets the opponent of the pairing
*
* @param Player | null $Opponent
* @return Pairing
*/
public function setOpponent(?Player $Opponent): Pairing
{
$this->Opponent = $Opponent;
return $this;
}
/**
* Returns the color of the pairing
*
* @return Color
*/
public function getColor(): Color
{
return $this->Color;
}
/**
* Sets the color of the pairing
*
* @param Color $Color
* @return Pairing
*/
public function setColor(Color $Color): Pairing
{
$this->Color = $Color;
return $this;
}
/**
* Returns the individual result of the pairing
*
* @return Result
*/
public function getResult(): Result
{
return $this->Result;
}
/**
* Sets the individual result of the pairing
*
* @param Result $Result
* @return Pairing
*/
public function setResult(Result $Result): Pairing
{
$this->Result = $Result;
return $this;
}
/**
* Returns the round number of the pairing
*
* @return int
*/
public function getRound(): int
{
return $this->Round;
}
/**
* Sets the round number of the pairing
*
* @param int $Round
* @return Pairing
*/
public function setRound(int $Round): Pairing
{
$this->Round = $Round;
return $this;
}
/**
* Sets the board no of the pairing
*
* @return int
*/
public function getBoard(): int
{
return $this->Board;
}
/**
* Returns the board no of the pairing
*
* @param int $Board
*/
public function setBoard(int $Board): void
{
$this->Board = $Board;
}
public $Board;
}

View File

@ -29,35 +29,35 @@ use DateTime;
class Player
{
/** @var string */
private $Name;
public $Name;
/** @var int[] */
private $Ids;
public $Ids;
/** @var int[] */
private $Elos;
public $Elos;
/** @var DateTime */
private $DateOfBirth;
public $DateOfBirth;
/** @var float[] */
private $Tiebreaks = [];
public $Tiebreaks = [];
/** @var string */
private $Nation;
public $Nation;
// TODO: Implement categories
/** @var string */
private $Category;
public $Category;
/** @var Title */
private $Title;
public $Title;
/** @var Gender */
private $Gender;
public $Gender;
/** @var Pairing[] */
private $Pairings = [];
public $Pairings = [];
/** @var bool|DateTime|int|string[] */
private $BinaryData;
@ -70,9 +70,9 @@ class Player
*/
public function addPairing(Pairing $pairing): Player
{
$newArray = $this->GetPairings();
$newArray = $this->Pairings;
$newArray[] = $pairing;
$this->setPairings($newArray);
$this->Pairings = $newArray;
return $this;
}
@ -86,13 +86,13 @@ class Player
public static function getPlayersByName(string $search, Tournament $tournament): array
{
/** @var Player[] */
$players = $tournament->getPlayers();
$players = $tournament->Players;
/** @var Player[] */
$return = [];
foreach ($players as $player) {
if (fnmatch($search, $player->getName())) {
if (fnmatch($search, $player->Name)) {
$return[] = $player;
}
}
@ -107,7 +107,7 @@ class Player
*/
public function getElo(string $type): int
{
return $this->getElos()[$type];
return $this->Elos[$type];
}
/**
@ -117,12 +117,11 @@ class Player
* @param int $value
* @return Player
*/
public function setElo(string $type, int $value): Player
public function setElo(string $type, int $value): void
{
$currentElos = $this->getElos();
$currentElos = $this->Elos;
$currentElos[$type] = $value;
$this->setElos($currentElos);
return $this;
$this->Elos = $currentElos;
}
/**
@ -135,7 +134,7 @@ class Player
*/
public function getId(string $type): string
{
return $this->getIds()[$type];
return $this->Ids[$type];
}
/**
@ -147,12 +146,11 @@ class Player
* @param string $value
* @return Player
*/
public function setId(string $type, string $value): Player
public function setId(string $type, string $value): void
{
$currentIds = $this->getIds();
$currentIds = $this->Ids;
$currentIds[$type] = $value;
$this->setIds($currentIds);
return $this;
$this->Ids = $currentIds;
}
/**
@ -163,8 +161,8 @@ class Player
public function getNoOfWins(): int
{
$wins = 0;
foreach ($this->getPairings() as $pairing) {
if (array_search($pairing->getResult(), Constants::Won) !== false) {
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::Won) !== false) {
$wins++;
}
}
@ -179,13 +177,13 @@ class Player
*
* @return float
*/
public function getPoints(): float
public function calculatePoints(): float
{
$points = 0;
foreach ($this->getPairings() as $pairing) {
if (array_search($pairing->getResult(), Constants::Won) !== false) {
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::Won) !== false) {
$points = $points + 1;
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
$points = $points + 0.5;
}
}
@ -204,12 +202,12 @@ class Player
public function getPointsForBuchholz(): float
{
$points = 0;
foreach ($this->getPairings() as $pairing) {
if (array_search($pairing->getResult(), Constants::NotPlayed) !== false) {
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::NotPlayed) !== false) {
$points = $points + 0.5;
} elseif (array_search($pairing->getResult(), Constants::Won) !== false) {
} elseif (array_search($pairing->Result, Constants::Won) !== false) {
$points = $points + 1;
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
$points = $points + 0.5;
}
}
@ -226,15 +224,15 @@ class Player
{
$total = 0;
$opponents = 0;
foreach ($this->getPairings() as $pairing) {
if (array_search($pairing->getResult(), Constants::NotPlayed) === false) {
$opponentElo = $pairing->getOpponent()->getElo($type);
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::NotPlayed) === false) {
$opponentElo = $pairing->Opponent->getElo($type);
$opponentElo = $opponentElo != 0 ? $opponentElo : $unratedElo;
if (array_search($pairing->getResult(), Constants::Won) !== false) {
if (array_search($pairing->Result, Constants::Won) !== false) {
$total += $opponentElo + 400;
} elseif (array_search($pairing->getResult(), Constants::Lost) !== false) {
} elseif (array_search($pairing->Result, Constants::Lost) !== false) {
$total += $opponentElo - 400;
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
$total += $opponentElo;
}
$opponents++;
@ -252,8 +250,8 @@ class Player
public function getPlayedGames(): int
{
$total = 0;
foreach ($this->getPairings() as $pairing) {
if (array_search($pairing->getResult(), Constants::Played) !== false) {
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::Played) !== false) {
$total++;
}
}
@ -261,234 +259,12 @@ class Player
}
/**
* Returns the name of the player
*
* @return string
*/
public function getName(): string
{
return $this->Name;
}
/**
* Sets the name of the player
*
* @param string $Name
* @return Player
*/
public function setName(string $Name): Player
{
$this->Name = $Name;
return $this;
}
/**
* Returns an array of all ID's of the player
*
* @return string[]
*/
public function getIds(): ?array
{
return $this->Ids;
}
/**
* Sets an array of all ID's of the player
*
* @param string[] $Ids
* @return Player
*/
public function setIds(array $Ids): Player
{
$this->Ids = $Ids;
return $this;
}
/**
* Returns an array of all elos of the player
*
* @return int[]
*/
public function getElos(): ?array
{
return $this->Elos;
}
/**
* Sets an array of all elos of the player
*
* @param int[] $Elos
* @return Player
*/
public function setElos(array $Elos): Player
{
$this->Elos = $Elos;
return $this;
}
/**
* Returns the date of birth of the player
*
* @return DateTime
*/
public function getDateOfBirth(): DateTime
{
return $this->DateOfBirth;
}
/**
* Sets the date of birth of the player
*
* @param DateTime $DateOfBirth
* @return Player
*/
public function setDateOfBirth(DateTime $DateOfBirth): Player
{
$this->DateOfBirth = $DateOfBirth;
return $this;
}
/**
* Returns an array of all tiebreaks for the player
*
* @return float[]
*/
public function getTiebreaks(): array
{
return $this->Tiebreaks;
}
/**
* Sets an array of all tiebreaks for the player
*
* @param float[] $Tiebreaks
* @return Player
*/
public function setTiebreaks(array $Tiebreaks): Player
{
$this->Tiebreaks = $Tiebreaks;
return $this;
}
/**
* Returns the nation of the player
* example value: BEL
*
* @return string
*/
public function getNation(): string
{
return $this->Nation;
}
/**
* Sets the nation of the player
* example value: BEL
*
* @param string $Nation
* @return Player
*/
public function setNation(string $Nation): Player
{
$this->Nation = $Nation;
return $this;
}
/**
* Returns the category of the player
*
* @return string
*/
public function getCategory(): string
{
return $this->Category;
}
/**
* Sets the category of the player
*
* @param string $Category
* @return Player
*/
public function setCategory(string $Category): Player
{
$this->Category = $Category;
return $this;
}
/**
* Returns the title of the player
*
* @return Title
*/
public function getTitle(): Title
{
return $this->Title;
}
/**
* Sets the title of the player
*
* @param Title $Title
* @return Player
*/
public function setTitle(Title $Title): Player
{
$this->Title = $Title;
return $this;
}
/**
* Returns the gender of the player
*
* @return Gender
*/
public function getGender(): Gender
{
return $this->Gender;
}
/**
* Sets the gender of the player
*
* @param Gender $Gender
* @return Player
*/
public function setGender(Gender $Gender): Player
{
$this->Gender = $Gender;
return $this;
}
/**
* Returns an array of all pairings of the player
*
* @return Pairing[]
*/
public function getPairings(): array
{
return $this->Pairings;
}
/**
* Sets an array of all pairings of the player
*
* @param Pairing[] $Pairings
* @return Player
*/
public function setPairings(array $Pairings): Player
{
$this->Pairings = $Pairings;
return $this;
}
/**
* Returns binary data that was read out the pairtwo file but was not needed immediately
* Returns binary data that was read out the pairing file but was not needed immediately
*
* @param string $Key
* @return bool|DateTime|int|string|null
*/
public function getBinaryData(string $Key)
public function __get(string $Key)
{
if (isset($this->BinaryData[$Key])) {
return $this->BinaryData[$Key];
@ -497,13 +273,13 @@ class Player
}
/**
* Sets binary data that is read out the pairtwo file but is not needed immediately
* Sets binary data that is read out the pairing file but is not needed immediately
*
* @param string $Key
* @param bool|int|DateTime|string $Value
* @return Player
*/
public function setBinaryData(string $Key, $Value): Player
public function __set(string $Key, $Value): Player
{
$this->BinaryData[$Key] = $Value;
return $this;

View File

@ -46,66 +46,21 @@ class Pairtwo6 implements ReaderInterface
private const CompatibleVersions = ['6.', '5.'];
/** @var string */
private $Release;
public $Release;
/** @var Tournament */
private $Tournament;
public $Tournament;
/** @var bool|DateTime|int|string[] */
private $BinaryData;
/**
* Returns the version tag of Pairtwo which created the pairtwo file
*
* @return string
*/
public function getRelease(): string
{
return $this->Release;
}
/**
* Sets the version tag of Pairtwo which created the pairtwo file
*
* @param string $Release
* @return Pairtwo6
*/
public function setRelease(string $Release): Pairtwo6
{
$this->Release = $Release;
return $this;
}
/**
* Returns the tournament that was read out of the pairtwo file
*
* @return Tournament
*/
public function getTournament(): Tournament
{
return $this->Tournament;
}
/**
* Sets the tournament that was read out of the pairtwo file
*
* @param Tournament $Tournament
* @return Pairtwo6
*/
public function setTournament(Tournament $Tournament): Pairtwo6
{
$this->Tournament = $Tournament;
return $this;
}
/**
* Returns binary data that was read out the pairtwo file but was not needed immediately
*
* @param string $Key
* @return bool|DateTime|int|string|null
*/
public function getBinaryData(string $Key)
public function __get(string $Key)
{
if (isset($this->BinaryData[$Key])) {
return $this->BinaryData[$Key];
@ -113,18 +68,16 @@ class Pairtwo6 implements ReaderInterface
return null;
}
/**
* Sets binary data that is read out the pairtwo file but is not needed immediately
*
* @param string $Key
* @param bool|int|DateTime|string $Value
* @return Pairtwo6
* @return void
*/
public function setBinaryData(string $Key, $Value): Pairtwo6
public function __set(string $Key, $Value): void
{
$this->BinaryData[$Key] = $Value;
return $this;
}
/**
@ -144,154 +97,154 @@ class Pairtwo6 implements ReaderInterface
$length = 4;
$this->setRelease($this->readData('String', substr($swscontents, $offset, $length)));
$this->Release = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
if (array_search(substr($this->getRelease(), 0, 2), self::CompatibleVersions) === false) {
if (array_search(substr($this->Release, 0, 2), self::CompatibleVersions) === false) {
throw new IncompatibleReaderException("This file was not created with Pairtwo 5 or higher");
}
$this->setTournament(new Tournament());
$this->getTournament()->setPriorityElo('Nation');
$this->getTournament()->setPriorityId('Nation');
$this->Tournament = new Tournament();
$this->Tournament->PriorityElo = 'Nation';
$this->Tournament->PriorityId = 'Nation';
// UserCountry
$length = 4;
$this->setBinaryData("UserCountry", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->UserCountry = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// SavedOffset
$length = 4;
$this->setBinaryData("SavedOffset", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->SavedOffset = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// NewPlayer
$length = 4;
$this->setBinaryData("NewPlayer", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->NewPlayer = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// AmericanHandicap
$length = 4;
$this->setBinaryData("AmericanHandicap", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->AmericanHandicap = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// LowOrder
$length = 4;
$this->setBinaryData("LowOrder", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->LowOrder = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// PairingMethod
$length = 4;
$this->setBinaryData("PairingMethod", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->PairingMethod = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// AmericanPresence
$length = 4;
$this->setBinaryData("AmericanPresence", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->AmericanPresence = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// CheckSameClub
$length = 4;
$this->setBinaryData("CheckSameClub", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->CheckSameClub = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// NoColorCheck
$length = 4;
$this->setBinaryData("NoColorCheck", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->NoColorCheck = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// SeparateCategories
$length = 4;
$this->setBinaryData("SeparateCategories", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->SeparateCategories = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// EloUsed
$length = 4;
$this->setBinaryData("EloUsed", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->EloUsed = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// AlternateColors
$length = 4;
$this->setBinaryData("AlternateColors", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->AlternateColors = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// MaxMeetings
$length = 4;
$this->setBinaryData("MaxMeetings", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->MaxMeetings = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// MaxDistance
$length = 4;
$this->setBinaryData("MaxDistance", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->MaxDistance = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// MinimizeKeizer
$length = 4;
$this->setBinaryData("MinimizeKeizer", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->MinimizeKeizer = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// MinRoundsMeetings
$length = 4;
$this->setBinaryData("MinRoundsMeetings", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->MinRoundsMeetings = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// MaxRoundsAbsent
$length = 4;
$this->setBinaryData("MaxRoundsAbsent", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->MaxRoundsAbsent = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// SpecialPoints
$length = 4 * 6;
$this->setBinaryData("SpecialPoints", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->SpecialPoints = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// NewNamePos
$length = 4;
$this->setBinaryData("NewNamePos", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->NewNamePos = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// CurrentRound
$length = 4;
$this->setBinaryData("CurrentRound", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->CurrentRound = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// CreatedRounds
$length = 4;
$this->setBinaryData("CreatedRounds", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->CreatedRounds = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// CreatedPlayers
$length = 4;
$this->setBinaryData("CreatedPlayers", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->CreatedPlayers = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// MaxSelection
$length = 4;
$this->setBinaryData("MaxSelection", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->MaxSelection = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// NumberOfRounds
$length = 4;
$this->setBinaryData("NumberOfRounds", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->NumberOfRounds = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// NumberOfPairings
$length = 4;
$this->setBinaryData("NumberOfPairings", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->NumberOfPairings = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// CreatedPairings
$length = 4;
$this->setBinaryData("CreatedPairings", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->CreatedPairings = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// PairingElems
$length = 4;
$this->setBinaryData("PairingElems", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->PairingElems = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// RandomSeed
$length = 4;
$this->setBinaryData("RandomSeed", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->RandomSeed = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// TieOrder
@ -348,44 +301,44 @@ class Pairtwo6 implements ReaderInterface
$tiebreak = Tiebreak::None;
break;
}
$this->getTournament()->addTieBreak(new Tiebreak($tiebreak));
$this->Tournament->addTieBreak(new Tiebreak($tiebreak));
$offset += $length;
}
// Categorie
$length = 4 * 10;
$this->setBinaryData("Categorie", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->Categorie = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// ExtraPoints
$length = 4 * 20;
$this->setBinaryData("ExtraPoints", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->ExtraPoints = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// SelectP
$length = 4 * 20;
$this->setBinaryData("SelectP", $this->readData('Int', substr($swscontents, $offset, $length)));
$this->SelectP = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// Players
for ($i = 0; $i < $this->getBinaryData("NewPlayer"); $i++) {
for ($i = 0; $i < $this->NewPlayer; $i++) {
$player = new Player();
// Rank (Unused value)
$length = 4;
$player->setBinaryData("Rank", $this->readData('Int', substr($swscontents, $offset, $length)));
$player->Rank = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$length = 4;
$player->setBinaryData("NamePos", $this->readData('Int', substr($swscontents, $offset, $length)));
$player->NamePos = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$length = 4;
$player->setId('Fide', $this->readData('Int', substr($swscontents, $offset, $length) . ""));
$player->setId('Fide', $this->readData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$player->setBinaryData("ExtraPts", $this->readData('Int', substr($swscontents, $offset, $length)));
$player->ExtraPts = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$length = 4;
@ -401,7 +354,7 @@ class Pairtwo6 implements ReaderInterface
$offset += $length;
$length = 4;
$player->setBinaryData("Points", $this->readData('Int', substr($swscontents, $offset, $length)) / 2);
$player->Points = $this->readData('Int', substr($swscontents, $offset, $length)) / 2;
$offset += $length;
$length = 4;
@ -409,15 +362,15 @@ class Pairtwo6 implements ReaderInterface
$offset += $length;
$length = 4;
$player->setBinaryData("ScoreBuchholz", $this->readData('Int', substr($swscontents, $offset, $length)) / 2);
$player->ScoreBuchholz = $this->readData('Int', substr($swscontents, $offset, $length)) / 2;
$offset += $length;
$length = 4;
$player->setBinaryData("ScoreAmerican", $this->readData('Int', substr($swscontents, $offset, $length)) / 2);
$player->ScoreAmerican = $this->readData('Int', substr($swscontents, $offset, $length)) / 2;
$offset += $length;
$length = 4;
$player->setBinaryData("HelpValue", $this->readData('Int', substr($swscontents, $offset, $length)));
$player->HelpValue = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$length = 4;
@ -425,15 +378,15 @@ class Pairtwo6 implements ReaderInterface
$offset += $length;
$length = 1;
$player->setBinaryData("NameLength", $this->readData('Int', substr($swscontents, $offset, $length)));
$player->NameLength = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$length = 3;
$player->setNation($this->readData('String', substr($swscontents, $offset, $length)));
$player->Nation = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
$length = 1;
$player->setCategory($this->readData('String', substr($swscontents, $offset, $length)));
$player->Category = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
$length = 1;
@ -479,7 +432,7 @@ class Pairtwo6 implements ReaderInterface
$title = Title::NONE;
break;
}
$player->setTitle(new Title($title));
$player->Title = new Title($title);
$offset += $length;
$length = 1;
@ -494,129 +447,129 @@ class Pairtwo6 implements ReaderInterface
$gender = Gender::Neutral;
break;
}
$player->setGender(new Gender($gender));
$player->Gender = new Gender($gender);
$offset += $length;
$length = 1;
$player->setBinaryData('NumberOfTies', $this->readData('Int', substr($swscontents, $offset, $length)));
$player->NumberOfTies = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$length = 1;
$player->setBinaryData('Absent', $this->readData('Bool', substr($swscontents, $offset, $length)));
$player->Absent = $this->readData('Bool', substr($swscontents, $offset, $length));
$offset += $length;
$length = 1;
$player->setBinaryData("ColorDiff", $this->readData('Int', substr($swscontents, $offset, $length)));
$player->ColorDiff = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$length = 1;
$player->setBinaryData("ColorPref", $this->readData('Int', substr($swscontents, $offset, $length)));
$player->ColorPref = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$length = 1;
$player->setBinaryData("Paired", $this->readData('Int', substr($swscontents, $offset, $length)));
$player->Paired = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$length = 1;
$player->setBinaryData("Float", $this->readData('Int', substr($swscontents, $offset, $length)));
$player->Float = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$length = 1;
$player->setBinaryData("FloatPrev", $this->readData('Int', substr($swscontents, $offset, $length)));
$player->FloatPrev = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$length = 1;
$player->setBinaryData("FloatBefore", $this->readData('Int', substr($swscontents, $offset, $length)));
$player->FloatBefore = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$length = 1;
$player->setBinaryData("TieMatch", $this->readData('Int', substr($swscontents, $offset, $length)));
$player->TieMatch = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
$this->getTournament()->addPlayer($player);
$this->Tournament->addPlayer($player);
}
// PlayerNames
$length = (Integer)$this->getBinaryData("NewNamePos") + 0;
$this->setBinaryData("PlayerNames", substr($swscontents, $offset, $length));
$length = (Integer)$this->NewNamePos + 0;
$this->PlayerNames = substr($swscontents, $offset, $length);
$offset += $length;
for ($i = 0; $i < $this->getBinaryData("NewPlayer"); $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)));
for ($i = 0; $i < $this->NewPlayer; $i++) {
$player = $this->Tournament->getPlayerById($i);
$namelength = $player->NameLength;
$nameoffset = $player->NamePos;
$player->Name = $this->readData("String", substr($this->PlayerNames, $nameoffset, $namelength));
$this->getTournament()->updatePlayer($i, $player);
$this->Tournament->updatePlayer($i, $player);
}
// TournamentName
$length = 80;
$this->getTournament()->setName($this->readData('String', substr($swscontents, $offset, $length)));
$this->Tournament->Name = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
// TournamentOrganiser
$length = 50;
$this->getTournament()->setOrganiser($this->readData('String', substr($swscontents, $offset, $length)));
$this->Tournament->Organiser = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
// TournamentTempo
$length = 50;
$this->getTournament()->setTempo($this->readData('String', substr($swscontents, $offset, $length)));
$this->Tournament->Tempo = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
// TournamentCountry
$length = 32;
$this->getTournament()->setOrganiserCountry($this->readData('String', substr($swscontents, $offset, $length)));
$this->Tournament->OrganiserCountry = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
// Arbiters
$length = 128;
$this->getTournament()->setArbiter($this->readData('String', substr($swscontents, $offset, $length)), 0);
$this->Tournament->addArbiter($this->readData('String', substr($swscontents, $offset, $length)));
$offset += $length;
// Rounds
$length = 4;
$this->getTournament()->setNoOfRounds($this->readData('Int', substr($swscontents, $offset, $length)));
$this->Tournament->NoOfRounds = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// Participants
$length = 4;
$this->setBinaryData('Participants', $this->readData('Int', substr($swscontents, $offset, $length)));
$this->Participants = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// Fidehomol
$length = 4;
$this->getTournament()->setFideHomol($this->readData('Int', substr($swscontents, $offset, $length)));
$this->Tournament->FideHomol = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// StartDate
$length = 4;
$this->getTournament()->setStartDate($this->readData('Date', substr($swscontents, $offset, $length)));
$this->Tournament->StartDate = $this->readData('Date', substr($swscontents, $offset, $length));
$offset += $length;
// EndDate
$length = 4;
$this->getTournament()->setEndDate($this->readData('Date', substr($swscontents, $offset, $length)));
$this->Tournament->EndDate = $this->readData('Date', substr($swscontents, $offset, $length));
$offset += $length;
// Place
$length = 36;
$this->getTournament()->setOrganiserPlace($this->readData('String', substr($swscontents, $offset, $length)));
$this->Tournament->OrganiserPlace = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
// First period
$length = 32;
$this->getTournament()->setFirstPeriod($this->readData('String', substr($swscontents, $offset, $length)));
$this->Tournament->FirstPeriod = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
// Second period
$length = 32;
$this->getTournament()->setSecondPeriod($this->readData('String', substr($swscontents, $offset, $length)));
$this->Tournament->SecondPeriod = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
// Unrated Elo
$length = 4;
$this->getTournament()->setNonRatedElo($this->readData('Int', substr($swscontents, $offset, $length)));
$this->Tournament->NonRatedElo = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// Type
@ -636,12 +589,12 @@ class Pairtwo6 implements ReaderInterface
$system = TournamentSystem::Swiss;
break;
}
$this->getTournament()->setSystem(new TournamentSystem($system));
$this->Tournament->System = new TournamentSystem($system);
$offset += $length;
// Federation
$length = 12;
$this->getTournament()->setFederation($this->readData('String', substr($swscontents, $offset, $length)));
$this->Tournament->Federation = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
// Soustype
@ -656,45 +609,45 @@ class Pairtwo6 implements ReaderInterface
* 1 bit = Double round robin
*/
$length = 4;
$this->setBinaryData('SousType', $this->readData('Hex', substr($swscontents, $offset, $length)));
$this->SousType = $this->readData('Hex', substr($swscontents, $offset, $length));
$offset += $length;
// Organising club no
$length = 4;
$this->getTournament()->setOrganiserClubNo($this->readData('String', substr($swscontents, $offset, $length), 0));
$this->Tournament->OrganiserClubNo = $this->readData('String', substr($swscontents, $offset, $length), 0);
$offset += $length;
// Organising club
$length = 8;
$this->getTournament()->setOrganiserClub($this->readData('String', substr($swscontents, $offset, $length)));
$this->Tournament->OrganiserClub = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
// Tournament year
$length = 4;
$this->getTournament()->setYear($this->readData('Int', substr($swscontents, $offset, $length)));
$this->Tournament->Year = $this->readData('Int', substr($swscontents, $offset, $length));
$offset += $length;
// Round dates
for ($i = 0; $i < $this->getTournament()->getNoOfRounds(); $i++) {
for ($i = 0; $i < $this->Tournament->NoOfRounds; $i++) {
$length = 4;
$round = new Round();
$round->setRoundNo($i);
$round->setDate($this->readData('Date', substr($swscontents, $offset, $length)));
$this->getTournament()->addRound($round);
$round->RoundNo = $i;
$round->Date = $this->readData('Date', substr($swscontents, $offset, $length));
$this->Tournament->addRound($round);
$offset += $length;
}
if ($this->getBinaryData("CurrentRound") > 0) {
for ($i = 0; $i < $this->getBinaryData("NewPlayer"); $i++) {
for ($x = 0; $x < $this->getBinaryData("CreatedRounds"); $x++) {
if ($this->CurrentRound > 0) {
for ($i = 0; $i < $this->NewPlayer; $i++) {
for ($x = 0; $x < $this->CreatedRounds; $x++) {
$pairing = new Pairing();
$pairing->setPlayer($this->getTournament()->getPlayerById($i));
$pairing->Player = $this->Tournament->getPlayerById($i);
$length = 4;
$opponent = $this->readData('Int', substr($swscontents, $offset, $length));
if ($opponent != 4294967295) {
$pairing->setOpponent($this->getTournament()->getPlayerById($opponent));
$pairing->Opponent = $this->Tournament->getPlayerById($opponent);
}
$offset += $length;
@ -714,7 +667,7 @@ class Pairtwo6 implements ReaderInterface
$color = Color::None;
break;
}
$pairing->setColor(new Color($color));
$pairing->Color = new Color($color);
$offset += $length;
$length = 1;
@ -754,15 +707,15 @@ class Pairtwo6 implements ReaderInterface
$result = Result::None;
break;
}
$pairing->setResult(new Result($result));
$pairing->Result = new Result($result);
$offset += $length;
$pairing->setRound($x);
$pairing->Round = $x;
$offset += 2;
$pairing->setBoard(-1);
if ($x < $this->getBinaryData("CurrentRound")) {
$this->getTournament()->addPairing($pairing);
$pairing->Board = -1;
if ($x < $this->CurrentRound) {
$this->Tournament->addPairing($pairing);
}
}
}
@ -770,7 +723,7 @@ class Pairtwo6 implements ReaderInterface
$this->addTiebreaks();
$this->getTournament()->pairingsToRounds();
$this->Tournament->pairingsToRounds();
return $this;
}
@ -882,7 +835,7 @@ class Pairtwo6 implements ReaderInterface
*/
private function addTiebreaks(): Pairtwo6
{
switch ($this->getTournament()->getSystem()) {
switch ($this->Tournament->System) {
case TournamentSystem::Keizer:
$firstElement = new Tiebreak(Tiebreak::Keizer);
break;
@ -892,9 +845,9 @@ class Pairtwo6 implements ReaderInterface
$firstElement = new Tiebreak(Tiebreak::Points);
break;
}
$tiebreaks = $this->getTournament()->getTiebreaks();
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
$this->getTournament()->setTiebreaks($tiebreaks);
$this->Tournament->Tiebreaks = $tiebreaks;
return $this;
}
}

View File

@ -34,14 +34,14 @@ use DateTime;
class Swar4 implements ReaderInterface
{
/** @var Tournament */
private $tournament;
public $Tournament;
/** @var string */
public $Release;
/** @var bool|int|DateTime|string[] */
private $BinaryData;
/** @var string */
private $Release;
/** @var array */
private const CompatibleVersions = ['v4.'];
@ -113,46 +113,49 @@ class Swar4 implements ReaderInterface
{
$swshandle = fopen($filename, 'rb');
$this->setRelease($this->readData('String', $swshandle));
if (array_search(substr($this->getRelease(), 0, 3), self::CompatibleVersions) === false) {
$this->Release = $this->readData('String', $swshandle);
if (array_search(substr($this->Release, 0, 3), self::CompatibleVersions) === false) {
throw new IncompatibleReaderException("This file was not created with Swar 4");
}
$this->setTournament(new Tournament());
$this->Tournament = new Tournament();
$this->setBinaryData('Guid', $this->readData('String', $swshandle));
$this->setBinaryData('MacAddress', $this->readData('String', $swshandle));
$this->setBinaryData('[Tournoi]', $this->readData('String', $swshandle));
$this->getTournament()->setName($this->readData('String', $swshandle));
$this->getTournament()->setOrganiser($this->readData('String', $swshandle));
$this->getTournament()->setOrganiserClub($this->readData('String', $swshandle));
$this->getTournament()->setOrganiserPlace($this->readData('String', $swshandle));
$this->Guid = $this->readData('String', $swshandle);
$this->MacAddress = $this->readData('String', $swshandle);
$this->getTournament()->setArbiter($this->readData('String', $swshandle), 0);
$this->getTournament()->setArbiter($this->readData('String', $swshandle), 1);
// [Tournoi]
$this->readData('String', $swshandle);
$this->getTournament()->setStartDate($this->readData('Date', $swshandle));
$this->getTournament()->setEndDate($this->readData('Date', $swshandle));
$this->Tournament->Name = $this->readData('String', $swshandle);
$this->Tournament->Organiser = $this->readData('String', $swshandle);
$this->Tournament->OrganiserClub = $this->readData('String', $swshandle);
$this->Tournament->OrganiserPlace = $this->readData('String', $swshandle);
$this->Tournament->addArbiter($this->readData('String', $swshandle));
$this->Tournament->addArbiter($this->readData('String', $swshandle));
$this->Tournament->StartDate = $this->readData('Date', $swshandle);
$this->Tournament->EndDate = $this->readData('Date', $swshandle);
// Tempo string is not variable and dependant on kind of tournament
$this->getTournament()->setBinaryData('TempoIndex', $this->readData('Int', $swshandle));
$this->Tournament->TempoIndex = $this->readData('Int', $swshandle);
$this->getTournament()->setNoOfRounds($this->readData('Int', $swshandle));
$this->Tournament->NoOfRounds = $this->readData('Int', $swshandle);
$this->getTournament()->setBinaryData('FRBEfrom', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('FRBEto', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('FIDEfrom', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('FIDEto', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('CatSepares', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('AfficherEloOuPays', $this->readData('Int', $swshandle));
$this->Tournament->FRBEfrom = $this->readData('Int', $swshandle);
$this->Tournament->FRBEto = $this->readData('Int', $swshandle);
$this->Tournament->FIDEfrom = $this->readData('Int', $swshandle);
$this->Tournament->FIDEto = $this->readData('Int', $swshandle);
$this->Tournament->CatSepares = $this->readData('Int', $swshandle);
$this->Tournament->AfficherEloOuPays = $this->readData('Int', $swshandle);
$this->getTournament()->setFideHomol($this->readData('Int', $swshandle));
$this->Tournament->FideHomol = $this->readData('Int', $swshandle);
$this->getTournament()->setBinaryData('FideId', $this->readData('String', $swshandle));
$this->getTournament()->setBinaryData('FideArbitre1', $this->readData('String', $swshandle));
$this->getTournament()->setBinaryData('FideArbitre2', $this->readData('String', $swshandle));
$this->getTournament()->setBinaryData('FideEmail', $this->readData('String', $swshandle));
$this->getTournament()->setBinaryData('FideRemarques', $this->readData('String', $swshandle));
$this->Tournament->FideId = $this->readData('String', $swshandle);
$this->Tournament->FideArbitre1 = $this->readData('String', $swshandle);
$this->Tournament->FideArbitre2 = $this->readData('String', $swshandle);
$this->Tournament->FideEmail = $this->readData('String', $swshandle);
$this->Tournament->FideRemarques = $this->readData('String', $swshandle);
switch ($this->readData('Int', $swshandle)) {
case 0:
@ -173,26 +176,26 @@ class Swar4 implements ReaderInterface
$system = TournamentSystem::American;
break;
}
$this->getTournament()->setSystem(new TournamentSystem($system));
$this->Tournament->System = new TournamentSystem($system);
$this->getTournament()->setBinaryData('Dummy1', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('Dummy2', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('SW_AmerPresence', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('Plusieurs', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('FirstTable', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('SW321_Win', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('SW321_Nul', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('SW321_Los', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('SW321_Bye', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('SW321_Pre', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('EloUsed', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('TournoiStd', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('TbPersonel', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('ApparOrder', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('EloEqual', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('ByeValue', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('AbsValue', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('FF_Value', $this->readData('Int', $swshandle));
$this->Tournament->Dummy1 = $this->readData('Int', $swshandle);
$this->Tournament->Dummy2 = $this->readData('Int', $swshandle);
$this->Tournament->SW_AmerPresence = $this->readData('Int', $swshandle);
$this->Tournament->Plusieurs = $this->readData('Int', $swshandle);
$this->Tournament->FirstTable = $this->readData('Int', $swshandle);
$this->Tournament->SW321_Win = $this->readData('Int', $swshandle);
$this->Tournament->SW321_Nul = $this->readData('Int', $swshandle);
$this->Tournament->SW321_Los = $this->readData('Int', $swshandle);
$this->Tournament->SW321_Bye = $this->readData('Int', $swshandle);
$this->Tournament->SW321_Pre = $this->readData('Int', $swshandle);
$this->Tournament->EloUsed = $this->readData('Int', $swshandle);
$this->Tournament->TournoiStd = $this->readData('Int', $swshandle);
$this->Tournament->TbPersonel = $this->readData('Int', $swshandle);
$this->Tournament->ApparOrder = $this->readData('Int', $swshandle);
$this->Tournament->EloEqual = $this->readData('Int', $swshandle);
$this->Tournament->ByeValue = $this->readData('Int', $swshandle);
$this->Tournament->AbsValue = $this->readData('Int', $swshandle);
$this->Tournament->FF_Value = $this->readData('Int', $swshandle);
switch ($this->readData('Int', $swshandle)) {
case 0:
@ -218,21 +221,23 @@ class Swar4 implements ReaderInterface
$federation = 'FIDE';
break;
}
$this->getTournament()->setFederation($federation);
$this->getTournament()->setNonRatedElo(0);
$this->getTournament()->setOrganiserClubNo(0);
$this->getTournament()->setBinaryData('[DATES]', $this->readData('String', $swshandle));
$this->Tournament->Federation = $federation;
$this->Tournament->NonRatedElo = 0;
$this->Tournament->OrganiserClubNo = 0;
// [DATES]
$this->readData('String', $swshandle);
$this->getTournament()->setTempo(Self::Tempos[$this->getTournament()->getBinaryData('TournoiStd')][$this->getTournament()->getBinaryData('TempoIndex')]);
$this->Tournament->Tempo = Self::Tempos[$this->Tournament->TournoiStd][$this->Tournament->TempoIndex];
for ($i = 0; $i < $this->getTournament()->getNoOfRounds(); $i++) {
for ($i = 0; $i < $this->Tournament->NoOfRounds; $i++) {
$round = new Round();
$round->setRoundNo($i);
$round->setDate($this->readData('Date', $swshandle));
$this->getTournament()->addRound($round);
$round->RoundNo = $i;
$round->Date = $this->readData('Date', $swshandle);
$this->Tournament->addRound($round);
}
$this->getTournament()->setBinaryData('[TIE_BREAK]', $this->readData('String', $swshandle));
// [TIE_BREAK]
$this->readData('String', $swshandle);
$tiebreaks = [];
for ($i = 0; $i < 5; $i++) {
@ -289,45 +294,49 @@ class Swar4 implements ReaderInterface
}
$tiebreaks[] = new Tiebreak($tiebreak);
}
$this->getTournament()->setTiebreaks($tiebreaks);
$this->Tournament->Tiebreaks = $tiebreaks;
$this->getTournament()->setBinaryData('[EXCLUSION]', $this->readData('String', $swshandle));
$this->getTournament()->setBinaryData('ExclusionType', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('ExclusionValue', $this->readData('String', $swshandle));
// [EXCLUSION]
$this->readData('String', $swshandle);
$this->Tournament->ExclusionType = $this->readData('Int', $swshandle);
$this->Tournament->ExclusionValue = $this->readData('String', $swshandle);
$this->getTournament()->setBinaryData('[CATEGORIES]', $this->readData('String', $swshandle));
// [CATEGORIES]
$this->readData('String', $swshandle);
$this->getTournament()->setBinaryData('Catogory_type', $this->readData('Int', $swshandle));
$this->Tournament->Catogory_type = $this->readData('Int', $swshandle);
for ($i = 0; $i <= 12; $i++) {
$this->getTournament()->setBinaryData('Category_' . $i . '_Cat1', $this->readData('String', $swshandle));
$this->Tournament->Category[$i]['Cat1'] =$this->readData('String', $swshandle);
}
for ($i = 0; $i <= 12; $i++) {
$this->getTournament()->setBinaryData('Category_' . $i . '_Cat2', $this->readData('String', $swshandle));
$this->Tournament->Category[$i]['Cat2'] =$this->readData('String', $swshandle);
}
$this->getTournament()->setBinaryData('[XTRA_POINTS]', $this->readData('String', $swshandle));
// [XTRA_POINTS]
$this->readData('String', $swshandle);
for ($i = 0; $i < 4; $i++) {
$this->getTournament()->setBinaryData('Extrapoints_' . $i . '_pts', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('Extrapoints_' . $i . '_elo', $this->readData('Int', $swshandle));
$this->Tournament->Extrapoints[$i]['pts'] =$this->readData('Int', $swshandle);
$this->Tournament->Extrapoints[$i]['elo'] =$this->readData('Int', $swshandle);
}
$this->getTournament()->setBinaryData('[JOUEURS]', $this->readData('String', $swshandle));
// [JOUEURS]
$this->readData('String', $swshandle);
$roundNo = 0;
$playerNo = 0;
$this->getTournament()->setBinaryData('NumberOfPlayers', $this->readData('Int', $swshandle));
$this->Tournament->NumberOfPlayers = $this->readData('Int', $swshandle);
$pt = 0;
for ($i = 0; $i < $this->getTournament()->getBinaryData('NumberOfPlayers'); $i++) {
for ($i = 0; $i < $this->Tournament->NumberOfPlayers; $i++) {
$player = new Player();
$player->setBinaryData('Classement', $this->readData('Int', $swshandle));
$player->setName($this->readData('String', $swshandle));
$player->Classement = $this->readData('Int', $swshandle);
$player->Name = $this->readData('String', $swshandle);
$inscriptionNos[$this->readData('Int', $swshandle)] = $i;
$player->setBinaryData('Rank', $this->readData('Int', $swshandle));
$player->setBinaryData('CatIndex', $this->readData('Int', $swshandle));
$player->setDateOfBirth($this->readData('Date', $swshandle));
$player->Rank = $this->readData('Int', $swshandle);
$player->CatIndex = $this->readData('Int', $swshandle);
$player->DateOfBirth = $this->readData('Date', $swshandle);
switch ($this->readData('Int', $swshandle)) {
case 1:
$gender = Gender::Male;
@ -339,12 +348,12 @@ class Swar4 implements ReaderInterface
$gender = Gender::Neutral;
break;
}
$player->setGender(new Gender($gender));
$player->Gender = new Gender($gender);
$player->setNation($this->readData('String', $swshandle));
$player->Nation = $this->readData('String', $swshandle);
$player->setId('Nation', $this->readData('Int', $swshandle));
$player->setId('Fide', $this->readData('Int', $swshandle));
$player->setBinaryData('Affliation', $this->readData('Int', $swshandle));
$player->Affliation = $this->readData('Int', $swshandle);
$player->setElo('Nation', $this->readData('Int', $swshandle));
$player->setElo('Fide', $this->readData('Int', $swshandle));
switch ($this->readData('Int', $swshandle)) {
@ -383,52 +392,53 @@ class Swar4 implements ReaderInterface
$title = Title::NONE;
break;
}
$player->setTitle(new Title($title));
$player->Title = new Title($title);
$player->setId('Club', $this->readData('Int', $swshandle));
$player->setBinaryData('ClubName', $this->readData('String', $swshandle));
$player->setBinaryData('NoOfMatchesNoBye', $this->readData('Int', $swshandle));
$player->setBinaryData('Points', $this->readData('Int', $swshandle)); // To Calculate by libpairtwo
$player->setBinaryData('AmericanPoints', $this->readData('Int', $swshandle)); // To Calculate by libpairtwo
$player->ClubName = $this->readData('String', $swshandle);
$player->NoOfMatchesNoBye = $this->readData('Int', $swshandle);
$player->Points = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
$player->AmericanPoints = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
for ($t = 0; $t < 5; $t++) {
$player->setBinaryData('Tiebreak_' . $t, $this->readData('Int', $swshandle)); // To Calculate by libpairtwo
$player->Tiebreak[$t] = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
}
$player->setBinaryData('Performance', $this->readData('Int', $swshandle)); // To Calculate by libpairtwo
$player->setBinaryData('Absent', $this->readData('Int', $swshandle));
$player->setBinaryData('AbsentRounds', $this->readData('String', $swshandle));
$player->setBinaryData('ExtraPoints', $this->readData('Int', $swshandle));
$player->setBinaryData('SpecialPoints', $this->readData('Int', $swshandle));
$player->setBinaryData('AllocatedRounds', $this->readData('Int', $swshandle));
$player->setBinaryData('[RONDE]', $this->readData('String', $swshandle));
$player->Performance = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
$player->Absent = $this->readData('Int', $swshandle);
$player->AbsentRounds = $this->readData('String', $swshandle);
$player->ExtraPoints = $this->readData('Int', $swshandle);
$player->SpecialPoints = $this->readData('Int', $swshandle);
$player->AllocatedRounds = $this->readData('Int', $swshandle);
// [RONDE]
$this->readData('String', $swshandle);
if ($player->getBinaryData('AllocatedRounds') != 0) {
for ($j = 0; $j < $player->getBinaryData('AllocatedRounds'); $j++) {
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_player', $i);
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_round', $this->readData('Int', $swshandle) - 1);
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_table', $this->readData('Int', $swshandle) - 1);
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_opponent', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_result', $this->readData('Hex', $swshandle));
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_color', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_float', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_extrapoints', $this->readData('Int', $swshandle));
if ($player->AllocatedRounds != 0) {
for ($j = 0; $j < $player->AllocatedRounds; $j++) {
$this->Tournament->Pairing[$pt]['player'] =$i;
$this->Tournament->Pairing[$pt]['round'] =$this->readData('Int', $swshandle) - 1;
$this->Tournament->Pairing[$pt]['table'] =$this->readData('Int', $swshandle) - 1;
$this->Tournament->Pairing[$pt]['opponent'] =$this->readData('Int', $swshandle);
$this->Tournament->Pairing[$pt]['result'] =$this->readData('Hex', $swshandle);
$this->Tournament->Pairing[$pt]['color'] =$this->readData('Int', $swshandle);
$this->Tournament->Pairing[$pt]['float'] =$this->readData('Int', $swshandle);
$this->Tournament->Pairing[$pt]['extrapoints'] =$this->readData('Int', $swshandle);
$pt++;
}
}
$this->getTournament()->addPlayer($player);
$this->Tournament->addPlayer($player);
}
$ptn = 0;
while (null !== $this->getTournament()->getBinaryData('Pairing_' . $ptn . '_round')) {
while (null !== $this->Tournament->Pairing[$ptn]['round']) {
$pairing = new Pairing();
$pairing->setPlayer($this->getTournament()->getPlayerById($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_player')));
$pairing->setRound($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_round'));
if ($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_opponent') != 4294967295) {
$pairing->setOpponent($this->getTournament()->getPlayerById($inscriptionNos[$this->getTournament()->getBinaryData('Pairing_' . $ptn . '_opponent')]));
$pairing->Player = $this->Tournament->getPlayerById($this->Tournament->Pairing[$ptn]['player']);
$pairing->Round = $this->Tournament->Pairing[$ptn]['round'];
if ($this->Tournament->Pairing[$ptn]['opponent'] != 4294967295) {
$pairing->Opponent = $this->Tournament->getPlayerById($inscriptionNos[$this->Tournament->Pairing[$ptn]['opponent']]);
}
switch ($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_result')) {
switch ($this->Tournament->Pairing[$ptn]['result']) {
case '1000':
$result = Result::Lost;
break;
@ -455,12 +465,12 @@ class Swar4 implements ReaderInterface
$result = Result::None;
break;
}
if (array_search($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_table'), [ 16383, 8191 ]) !== false) {
if (array_search($this->Tournament->Pairing[$ptn]['table'], [ 16383, 8191 ]) !== false) {
$result = Result::Absent;
}
$pairing->setResult(new Result($result));
$pairing->Result = new Result($result);
switch ($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_color')) {
switch ($this->Tournament->Pairing[$ptn]['color']) {
case 4294967295:
$color = Color::Black;
break;
@ -472,35 +482,18 @@ class Swar4 implements ReaderInterface
$color = Color::None;
break;
}
$pairing->setColor(new Color($color));
$pairing->Color = new Color($color);
$pairing->setBoard($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_table'));
$pairing->Board = $this->Tournament->Pairing[$ptn]['table'];
$ptn++;
$this->getTournament()->addPairing($pairing);
$this->Tournament->addPairing($pairing);
}
fclose($swshandle);
$this->getTournament()->pairingsToRounds();
$this->Tournament->pairingsToRounds();
$this->addTiebreaks();
return $this;
}
/**
* @return Tournament
*/
public function getTournament(): Tournament
{
return $this->tournament;
}
/**
* @param Tournament $tournament
*/
public function setTournament(Tournament $tournament): void
{
$this->tournament = $tournament;
}
/**
* @param string $type
* @param $handle
@ -568,29 +561,13 @@ class Swar4 implements ReaderInterface
return false;
}
/**
* @return string
*/
public function getRelease(): string
{
return $this->Release;
}
/**
* @param string $Release
*/
public function setRelease(string $Release): void
{
$this->Release = $Release;
}
/**
* Returns binary data that was read out the swar file but was not needed immediately
*
* @param string $Key
* @return bool|DateTime|int|string|null
*/
public function getBinaryData(string $Key)
public function __get(string $Key)
{
if (isset($this->BinaryData[$Key])) {
return $this->BinaryData[$Key];
@ -603,12 +580,11 @@ class Swar4 implements ReaderInterface
*
* @param string $Key
* @param bool|int|DateTime|string $Value
* @return Pairtwo6
* @return void
*/
public function setBinaryData(string $Key, $Value): Swar4
public function __set(string $Key, $Value): void
{
$this->BinaryData[$Key] = $Value;
return $this;
}
/**
@ -629,16 +605,16 @@ class Swar4 implements ReaderInterface
*/
private function addTiebreaks(): Swar4
{
switch ($this->getTournament()->getSystem()) {
switch ($this->Tournament->System) {
case TournamentSystem::American:
case TournamentSystem::Closed:
case TournamentSystem::Swiss:
default:
$firstElement = new Tiebreak(Tiebreak::Points);
}
$tiebreaks = $this->getTournament()->getTiebreaks();
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
$this->getTournament()->setTiebreaks($tiebreaks);
$this->Tournament->Tiebreaks = $tiebreaks;
return $this;
}
}

View File

@ -32,28 +32,28 @@ class Round
*
* @var DateTime
*/
private $Date;
public $Date;
/**
* Array of all games
*
* @var Game[]
*/
private $Games = [];
public $Games = [];
/**
* Number of the round
*
* @var int
*/
private $RoundNo;
public $RoundNo;
/**
* Array of all pairings for this round
*
* @var Pairing[]
*/
private $Pairings = [];
public $Pairings = [];
/**
* Adds a game to the round
@ -63,9 +63,9 @@ class Round
*/
public function addGame(Game $game): Round
{
$newarray = $this->getGames();
$newarray = $this->Games;
$newarray[] = $game;
$this->setGames($newarray);
$this->Games = $newarray;
return $this;
}
@ -77,9 +77,9 @@ class Round
*/
public function addPairing(Pairing $pairing): Round
{
$newarray = $this->getPairings();
$newarray = $this->Pairings;
$newarray[] = $pairing;
$this->setPairings($newarray);
$this->Pairings = $newarray;
return $this;
}
@ -90,10 +90,10 @@ class Round
*/
public function getBye(): array
{
$allPairings = $this->getPairings();
$allPairings = $this->Pairings;
$byePairings = [];
foreach ($allPairings as $pairing) {
if ($pairing->getResult() == Result::WonBye) {
if ($pairing->Result == Result::WonBye) {
$byePairings[] = $pairing;
}
}
@ -107,10 +107,10 @@ class Round
*/
public function getAbsent(): array
{
$allPairings = $this->getPairings();
$allPairings = $this->Pairings;
$absentPairings = [];
foreach ($allPairings as $pairing) {
if ($pairing->getResult() == Result::Absent) {
if ($pairing->Result == Result::Absent) {
$absentPairings[] = $pairing;
}
}
@ -124,7 +124,7 @@ class Round
*/
public function getGamesByBoard(): array
{
$allGames = $this->getGames();
$allGames = $this->Games;
usort($allGames, array($this, 'sortByBoard'));
return $allGames;
}
@ -138,96 +138,9 @@ class Round
*/
private function sortByBoard(Game $a, Game $b): int
{
if (($a->getBoard() == $b->getBoard()) || ($a->getBoard() === false) || ($b->getBoard() === false)) {
if (($a->Board == $b->Board) || ($a->Board === false) || ($b->Board === false)) {
return 0;
}
return ($a->getBoard() > $b->getBoard()) ? +1 : -1;
}
/**
* Returns the date of the round
*
* @return DateTime
*/
public function getDate(): DateTime
{
return $this->Date;
}
/**
* Sets the date of the round
*
* @param DateTime $Date
* @return Round
*/
public function setDate(DateTime $Date): Round
{
$this->Date = $Date;
return $this;
}
/**
* Returns an array of all games for the round
*
* @return Game[]
*/
public function getGames(): array
{
return $this->Games;
}
/**
* Sets an array of all games for the round
*
* @param Game[] $Games
* @return Round
*/
public function setGames(array $Games): Round
{
$this->Games = $Games;
return $this;
}
/**
* Returns the round number of the round
*
* @return int
*/
public function getRoundNo(): int
{
return $this->RoundNo;
}
/**
* Sets the round number of the round
*
* @param int $RoundNo
* @return Round
*/
public function setRoundNo(int $RoundNo): Round
{
$this->RoundNo = $RoundNo;
return $this;
}
/**
* Returns an array of all pairings for the round
*
* @return Pairing[]
*/
public function getPairings(): array
{
return $this->Pairings;
}
/**
* Sets an array of all pairings for the round
*
* @param Pairing[] $Pairings
* @return Round
*/
public function setPairings(array $Pairings): Round
{
$this->Pairings = $Pairings;
return $this;
return ($a->Board > $b->Board) ? +1 : -1;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -30,62 +30,62 @@ require_once '../vendor/autoload.php';
$sws = IOFactory::createReader('Swar-4');
$sws->read('../res/testswar.swar');
echo "Release: " . $sws->getRelease() . PHP_EOL;
echo "Name: " . $sws->getTournament()->getName() . PHP_EOL;
echo "Organiser: " . $sws->getTournament()->getOrganiser(). PHP_EOL;
echo "TempoIndex: " . $sws->getTournament()->getBinaryData('TempoIndex') . PHP_EOL;
echo "TempoType: " . $sws->getTournament()->getBinaryData('TournoiStd') . PHP_EOL;
echo "Tempo: " . $sws->getTournament()->getTempo() . PHP_EOL;
echo "Place: " . $sws->getTournament()->getOrganiserPlace() . PHP_EOL;
echo "Arbiter 1: " . $sws->getTournament()->getArbiter(0) . PHP_EOL;
echo "Arbiter 2: " . $sws->getTournament()->getArbiter(1) . PHP_EOL;
echo "Rounds: " . $sws->getTournament()->getNoOfRounds() . PHP_EOL;
echo "Fidehomol: " . $sws->getTournament()->getFideHomol() . PHP_EOL;
echo "Start-Date: " . $sws->getTournament()->getStartDate()->format('d/m/Y') . PHP_EOL;
echo "End-Date: " . $sws->getTournament()->getEndDate()->format('d/m/Y') . PHP_EOL;
echo "System: " . $sws->getTournament()->getSystem()->getKey() . PHP_EOL;
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)->getElo('Fide') . PHP_EOL;
echo "Fide Elo P2: " . $sws->getTournament()->getPlayerById(1)->getElo('Fide') . PHP_EOL;
echo "Fide Elo P3: " . $sws->getTournament()->getPlayerById(2)->getElo('Fide') . PHP_EOL;
echo "KBSB Elo P1: " . $sws->getTournament()->getPlayerById(0)->getElo('Nation') . PHP_EOL;
echo "KBSB Elo P2: " . $sws->getTournament()->getPlayerById(1)->getElo('Nation') . PHP_EOL;
echo "KBSB Elo P3: " . $sws->getTournament()->getPlayerById(2)->getElo('Nation') . 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)->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;
echo "Game Round 1: " . $sws->getTournament()->getRoundByNo(0)->getGames()[0]->getResult()->getValue() . PHP_EOL;
echo "Game Round 2: " . $sws->getTournament()->getRoundByNo(1)->getGames()[0]->getResult()->getValue() . PHP_EOL;
echo "Game Round 3: " . $sws->getTournament()->getRoundByNo(2)->getGames()[0]->getResult()->getValue() . PHP_EOL;
echo "Color Pairing 1: " . $sws->getTournament()->getPairings()[1]->getColor()->getKey() . PHP_EOL;
echo "Color Pairing 2: " . $sws->getTournament()->getPairings()[2]->getColor()->getKey() . PHP_EOL;
echo "Color Pairing 3: " . $sws->getTournament()->getPairings()[3]->getColor()->getKey() . PHP_EOL;
echo "Player Pairing 1: " . $sws->getTournament()->getPairings()[0]->getPlayer()->getName() . PHP_EOL;
echo "Player Pairing 2: " . $sws->getTournament()->getPairings()[1]->getPlayer()->getName() . PHP_EOL;
echo "Player Pairing 3: " . $sws->getTournament()->getPairings()[2]->getPlayer()->getName() . PHP_EOL;
echo "Bye Round 1: " . $sws->getTournament()->getRoundByNo(2)->getBye()[0]->getPlayer()->getName() . PHP_EOL;
echo "Absent Round 1: " . $sws->getTournament()->getRoundByNo(2)->getAbsent()[0]->getPlayer()->getName() . PHP_EOL;
echo "Tiebreak 1: " . $sws->getTournament()->getTiebreaks()[0]->getValue() . PHP_EOL;
echo "Tiebreak 2: " . $sws->getTournament()->getTiebreaks()[1]->getValue() . PHP_EOL;
echo "Tiebreak 3: " . $sws->getTournament()->getTiebreaks()[2]->getValue() . PHP_EOL;
echo "Tiebreak 4: " . $sws->getTournament()->getTiebreaks()[3]->getValue() . PHP_EOL;
echo "Tiebreak 5: " . $sws->getTournament()->getTiebreaks()[4]->getValue() . PHP_EOL;
echo "Tiebreak 6: " . $sws->getTournament()->getTiebreaks()[5]->getValue() . PHP_EOL;
echo "Average Elo: " . $sws->getTournament()->getAverageElo() . PHP_EOL;
foreach ($sws->getTournament()->getRanking() as $player) {
echo str_pad($player->getName() . '(' . $player->getElo($sws->getTournament()->getPriorityElo()) . ') ', 35) . implode_pad(' ', $player->getTiebreaks(), 5, ' ') . PHP_EOL;
echo "Release: " . $sws->Release() . PHP_EOL;
echo "Name: " . $sws->Tournament()->Name . PHP_EOL;
echo "Organiser: " . $sws->Tournament()->Organiser. PHP_EOL;
echo "TempoIndex: " . $sws->Tournament()->TempoIndex . PHP_EOL;
echo "TempoType: " . $sws->Tournament()->TournoiStd . PHP_EOL;
echo "Tempo: " . $sws->Tournament()->Tempo . PHP_EOL;
echo "Place: " . $sws->Tournament()->OrganiserPlace . PHP_EOL;
echo "Arbiter 1: " . $sws->Tournament()->getArbiter(0) . PHP_EOL;
echo "Arbiter 2: " . $sws->Tournament()->getArbiter(1) . PHP_EOL;
echo "Rounds: " . $sws->Tournament()->NoOfRounds . PHP_EOL;
echo "Fidehomol: " . $sws->Tournament()->FideHomol . PHP_EOL;
echo "Start-Date: " . $sws->Tournament()->StartDate->format('d/m/Y') . PHP_EOL;
echo "End-Date: " . $sws->Tournament()->EndDate->format('d/m/Y') . PHP_EOL;
echo "System: " . $sws->Tournament()->System->getKey() . PHP_EOL;
echo "Place: " . $sws->Tournament()->OrganiserPlace . PHP_EOL;
echo "Unrated-Elo: " . $sws->Tournament()->NonRatedElo . PHP_EOL;
echo "Federation: " . $sws->Tournament()->Federation . PHP_EOL;
echo "Organiser: " . $sws->Tournament()->OrganiserClubNo . PHP_EOL;
echo "Fide Elo P1: " . $sws->Tournament()->getPlayerById(0)->getElo('Fide') . PHP_EOL;
echo "Fide Elo P2: " . $sws->Tournament()->getPlayerById(1)->getElo('Fide') . PHP_EOL;
echo "Fide Elo P3: " . $sws->Tournament()->getPlayerById(2)->getElo('Fide') . PHP_EOL;
echo "KBSB Elo P1: " . $sws->Tournament()->getPlayerById(0)->getElo('Nation') . PHP_EOL;
echo "KBSB Elo P2: " . $sws->Tournament()->getPlayerById(1)->getElo('Nation') . PHP_EOL;
echo "KBSB Elo P3: " . $sws->Tournament()->getPlayerById(2)->getElo('Nation') . PHP_EOL;
echo "Name P1: " . $sws->Tournament()->getPlayerById(0)->Name . PHP_EOL;
echo "Name P2: " . $sws->Tournament()->getPlayerById(1)->Name . PHP_EOL;
echo "Name P3: " . $sws->Tournament()->getPlayerById(2)->Name . PHP_EOL;
echo "Gender P1: " . $sws->Tournament()->getPlayerById(0)->Gender->getKey() . PHP_EOL;
echo "Gender P2: " . $sws->Tournament()->getPlayerById(1)->Gender->getKey() . PHP_EOL;
echo "Gender P3: " . $sws->Tournament()->getPlayerById(2)->Gender->getKey() . PHP_EOL;
echo "Absent P1: " . $sws->Tournament()->getPlayerById(0)->Absent . PHP_EOL;
echo "Absent P2: " . $sws->Tournament()->getPlayerById(1)->Absent . PHP_EOL;
echo "Absent P3: " . $sws->Tournament()->getPlayerById(2)->Absent . PHP_EOL;
echo "Date Round 1: " . $sws->Tournament()->getRoundByNo(0)->Date->format('d/m/Y') . PHP_EOL;
echo "Date Round 2: " . $sws->Tournament()->getRoundByNo(1)->Date->format('d/m/Y') . PHP_EOL;
echo "Date Round 3: " . $sws->Tournament()->getRoundByNo(2)->Date->format('d/m/Y') . PHP_EOL;
echo "Game Round 1: " . $sws->Tournament()->getRoundByNo(0)->Games[0]->Result->getValue() . PHP_EOL;
echo "Game Round 2: " . $sws->Tournament()->getRoundByNo(1)->Games[0]->Result->getValue() . PHP_EOL;
echo "Game Round 3: " . $sws->Tournament()->getRoundByNo(2)->Games[0]->Result->getValue() . PHP_EOL;
echo "Color Pairing 1: " . $sws->Tournament()->Pairings[1]->Color->getKey() . PHP_EOL;
echo "Color Pairing 2: " . $sws->Tournament()->Pairings[2]->Color->getKey() . PHP_EOL;
echo "Color Pairing 3: " . $sws->Tournament()->Pairings[3]->Color->getKey() . PHP_EOL;
echo "Player Pairing 1: " . $sws->Tournament()->Pairings[0]->Player->Name . PHP_EOL;
echo "Player Pairing 2: " . $sws->Tournament()->Pairings[1]->Player->Name . PHP_EOL;
echo "Player Pairing 3: " . $sws->Tournament()->Pairings[2]->Player->Name . PHP_EOL;
echo "Bye Round 1: " . $sws->Tournament()->getRoundByNo(2)->Bye[0]->Player->Name . PHP_EOL;
echo "Absent Round 1: " . $sws->Tournament()->getRoundByNo(2)->Absent[0]->Player->Name . PHP_EOL;
echo "Tiebreak 1: " . $sws->Tournament()->Tiebreaks[0]->getValue() . PHP_EOL;
echo "Tiebreak 2: " . $sws->Tournament()->Tiebreaks[1]->getValue() . PHP_EOL;
echo "Tiebreak 3: " . $sws->Tournament()->Tiebreaks[2]->getValue() . PHP_EOL;
echo "Tiebreak 4: " . $sws->Tournament()->Tiebreaks[3]->getValue() . PHP_EOL;
echo "Tiebreak 5: " . $sws->Tournament()->Tiebreaks[4]->getValue() . PHP_EOL;
echo "Tiebreak 6: " . $sws->Tournament()->Tiebreaks[5]->getValue() . PHP_EOL;
echo "Average Elo: " . $sws->Tournament()->AverageElo . PHP_EOL;
foreach ($sws->Tournament()->Ranking as $player) {
echo str_pad($player->Name . '(' . $player->getElo($sws->Tournament()->PriorityElo) . ') ', 35) . implode_pad(' ', $player->Tiebreaks, 5, ' ') . PHP_EOL;
}
function implode_pad($glue, $collection, $padlength, $padstring): string