Added a reading of rounds

not finished yet
This commit is contained in:
Jeroen De Meerleer 2019-02-06 17:23:37 +01:00
parent 830b21afa2
commit 82370b25d7
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
6 changed files with 128 additions and 0 deletions

16
src/Game.php Normal file
View File

@ -0,0 +1,16 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 1/02/19
* Time: 17:17
*/
namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Models\Game as GameModel;
class Game extends GameModel
{
}

15
src/Models/Game.php Normal file
View File

@ -0,0 +1,15 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 1/02/19
* Time: 17:16
*/
namespace JeroenED\Libpairtwo\Models;
class Game
{
}

48
src/Models/Round.php Normal file
View File

@ -0,0 +1,48 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 1/02/19
* Time: 17:13
*/
namespace JeroenED\Libpairtwo\Models;
class Round
{
private $date;
private $games;
/**
* @return \DateTime
*
*/
public function getDate()
{
return $this->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;
}
}

16
src/Round.php Normal file
View File

@ -0,0 +1,16 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 1/02/19
* Time: 17:16
*/
namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Models\Round as RoundModel;
class Round extends RoundModel
{
}

View File

@ -278,6 +278,8 @@ class Sws extends SwsModel
$length = 4; $length = 4;
$player->setFideElo(self::ReadData('Int', substr($swscontents, $offset, $length))); $player->setFideElo(self::ReadData('Int', substr($swscontents, $offset, $length)));
echo "offset: " . $offset . PHP_EOL;
echo "length: " . $length . PHP_EOL;
$offset += $length; $offset += $length;
$length = 1; $length = 1;
@ -457,6 +459,26 @@ class Sws extends SwsModel
$sws->getTournament()->setOrganiserClub(self::ReadData('String', substr($swscontents, $offset, $length))); $sws->getTournament()->setOrganiserClub(self::ReadData('String', substr($swscontents, $offset, $length)));
$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; return $sws;
} }

View File

@ -41,4 +41,15 @@ class Tournament extends TournamentModel
$newArray[$id] = $player; $newArray[$id] = $player;
$this->setPlayers($newArray); $this->setPlayers($newArray);
} }
/**
* @param Round $round
*/
public function addRound(Round $round)
{
$newArray = $this->GetRounds();
$newArray[] = $round;
$this->setRounds($newArray);
}
} }