From 82370b25d7014a8a9c8f646628a8431b652915d7 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Wed, 6 Feb 2019 17:23:37 +0100 Subject: [PATCH] Added a reading of rounds not finished yet --- src/Game.php | 16 +++++++++++++++ src/Models/Game.php | 15 ++++++++++++++ src/Models/Round.php | 48 ++++++++++++++++++++++++++++++++++++++++++++ src/Round.php | 16 +++++++++++++++ src/Sws.php | 22 ++++++++++++++++++++ src/Tournament.php | 11 ++++++++++ 6 files changed, 128 insertions(+) create mode 100644 src/Game.php create mode 100644 src/Models/Game.php create mode 100644 src/Models/Round.php create mode 100644 src/Round.php diff --git a/src/Game.php b/src/Game.php new file mode 100644 index 0000000..5aef00c --- /dev/null +++ b/src/Game.php @@ -0,0 +1,16 @@ +date; + } + + /** + * @param \DateTime $date + */ + public function setDate($date): void + { + $this->date = $date; + } + + /** + * @return Game[] + */ + public function getGames() + { + return $this->games; + } + + /** + * @param Game[] $games + */ + public function setGames($games): void + { + $this->games = $games; + } +} diff --git a/src/Round.php b/src/Round.php new file mode 100644 index 0000000..5a721d8 --- /dev/null +++ b/src/Round.php @@ -0,0 +1,16 @@ +setFideElo(self::ReadData('Int', substr($swscontents, $offset, $length))); + echo "offset: " . $offset . PHP_EOL; + echo "length: " . $length . PHP_EOL; $offset += $length; $length = 1; @@ -457,6 +459,26 @@ class Sws extends SwsModel $sws->getTournament()->setOrganiserClub(self::ReadData('String', substr($swscontents, $offset, $length))); $offset += $length; + echo dechex($offset) . PHP_EOL; + if ($sws->getBinaryData("CurrentRound") > 0) { + echo "go" . PHP_EOL; + for ($i = 0; $i < $sws->getBinaryData("CreatedRounds"); $i++) { + $game = new Game(); + + $length = 4; + echo $offset . "Opponent: " . self::ReadData('String', substr($swscontents, $offset, $length)) . PHP_EOL; + $offset += $length; + + $length = 1; + echo $offset . "Color: " . self::ReadData('String', substr($swscontents, $offset, $length)) . PHP_EOL; + $offset += $length; + + $length = 1; + echo $offset . "Result: " . self::ReadData('String', substr($swscontents, $offset, $length)) . PHP_EOL; + $offset += $length; + } + + } return $sws; } diff --git a/src/Tournament.php b/src/Tournament.php index 4bf37c4..cd48506 100644 --- a/src/Tournament.php +++ b/src/Tournament.php @@ -41,4 +41,15 @@ class Tournament extends TournamentModel $newArray[$id] = $player; $this->setPlayers($newArray); } + + /** + * @param Round $round + */ + public function addRound(Round $round) + { + $newArray = $this->GetRounds(); + $newArray[] = $round; + $this->setRounds($newArray); + } + }